// Copyright (c) 2020 Slack Technologies, Inc. // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. #ifndef SHELL_RENDERER_API_CONTEXT_BRIDGE_OBJECT_CACHE_H_ #define SHELL_RENDERER_API_CONTEXT_BRIDGE_OBJECT_CACHE_H_ #include #include #include "base/containers/linked_list.h" #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_frame_observer.h" #include "shell/renderer/electron_render_frame_observer.h" #include "third_party/blink/public/web/web_local_frame.h" namespace electron { namespace api { namespace context_bridge { using ObjectCachePair = std::pair, v8::Local>; struct ObjectCachePairNode : public base::LinkNode { explicit ObjectCachePairNode(ObjectCachePair&& pair); ~ObjectCachePairNode(); ObjectCachePair pair; }; class ObjectCache final { public: ObjectCache(); ~ObjectCache(); void CacheProxiedObject(v8::Local from, v8::Local proxy_value); v8::MaybeLocal GetCachedProxiedObject( v8::Local from) const; private: // object_identity ==> [from_value, proxy_value] std::map> proxy_map_; }; } // namespace context_bridge } // namespace api } // namespace electron #endif // SHELL_RENDERER_API_CONTEXT_BRIDGE_OBJECT_CACHE_H_