2020-03-04 07:18:22 +00:00
|
|
|
// 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.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_RENDERER_API_CONTEXT_BRIDGE_OBJECT_CACHE_H_
|
|
|
|
#define ELECTRON_SHELL_RENDERER_API_CONTEXT_BRIDGE_OBJECT_CACHE_H_
|
2020-03-04 07:18:22 +00:00
|
|
|
|
2021-07-06 12:17:13 +00:00
|
|
|
#include <forward_list>
|
2021-02-08 20:30:25 +00:00
|
|
|
#include <unordered_map>
|
2020-03-04 07:18:22 +00:00
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
2022-06-29 19:55:47 +00:00
|
|
|
namespace electron::api::context_bridge {
|
2020-03-04 07:18:22 +00:00
|
|
|
|
|
|
|
using ObjectCachePair = std::pair<v8::Local<v8::Value>, v8::Local<v8::Value>>;
|
|
|
|
|
|
|
|
class ObjectCache final {
|
|
|
|
public:
|
|
|
|
ObjectCache();
|
|
|
|
~ObjectCache();
|
|
|
|
|
|
|
|
void CacheProxiedObject(v8::Local<v8::Value> from,
|
|
|
|
v8::Local<v8::Value> proxy_value);
|
|
|
|
v8::MaybeLocal<v8::Value> GetCachedProxiedObject(
|
|
|
|
v8::Local<v8::Value> from) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// object_identity ==> [from_value, proxy_value]
|
2021-02-08 20:30:25 +00:00
|
|
|
std::unordered_map<int, std::forward_list<ObjectCachePair>> proxy_map_;
|
2020-03-04 07:18:22 +00:00
|
|
|
};
|
|
|
|
|
2022-06-29 19:55:47 +00:00
|
|
|
} // namespace electron::api::context_bridge
|
2020-03-04 07:18:22 +00:00
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_RENDERER_API_CONTEXT_BRIDGE_OBJECT_CACHE_H_
|