Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1022)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h

Issue 2702273004: bindings: Simplifies WindowProxyManager and its relation to Frame. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h b/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h
index a70c384d0242296dd1daa1e7f12bc0ca2fe7d931..f7c845d0b9bf1dbee83a32b70c6fcda333f11219 100644
--- a/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h
+++ b/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h
@@ -18,9 +18,8 @@ namespace blink {
class DOMWrapperWorld;
class SecurityOrigin;
-class ScriptController;
-class WindowProxyManagerBase : public GarbageCollected<WindowProxyManagerBase> {
+class WindowProxyManager : public GarbageCollected<WindowProxyManager> {
public:
DECLARE_TRACE();
@@ -34,18 +33,27 @@ class WindowProxyManagerBase : public GarbageCollected<WindowProxyManagerBase> {
void CORE_EXPORT
setGlobals(const HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>&);
+ Frame* frame() const { return m_frame; }
+ WindowProxy* windowProxy(DOMWrapperWorld& world) {
+ WindowProxy* windowProxy = windowProxyMaybeUninitialized(world);
+ windowProxy->initializeIfNeeded();
+ return windowProxy;
+ }
+
protected:
using IsolatedWorldMap = HeapHashMap<int, Member<WindowProxy>>;
- explicit WindowProxyManagerBase(Frame&);
-
- Frame* frame() const { return m_frame; }
- WindowProxy* mainWorldProxy() const { return m_windowProxy.get(); }
- WindowProxy* windowProxy(DOMWrapperWorld&);
+ explicit WindowProxyManager(Frame&);
IsolatedWorldMap& isolatedWorlds() { return m_isolatedWorlds; }
+ WindowProxy* mainWorldProxyMaybeUninitialized() {
+ return m_windowProxy;
+ }
+
private:
+ WindowProxy* windowProxyMaybeUninitialized(DOMWrapperWorld&);
+
v8::Isolate* const m_isolate;
const Member<Frame> m_frame;
const Member<WindowProxy> m_windowProxy;
@@ -53,22 +61,19 @@ class WindowProxyManagerBase : public GarbageCollected<WindowProxyManagerBase> {
};
template <typename FrameType, typename ProxyType>
-class WindowProxyManagerImplHelper : public WindowProxyManagerBase {
+class WindowProxyManagerImplHelper : public WindowProxyManager {
private:
- using Base = WindowProxyManagerBase;
+ using Base = WindowProxyManager;
public:
FrameType* frame() const { return static_cast<FrameType*>(Base::frame()); }
- ProxyType* mainWorldProxy() const {
- return static_cast<ProxyType*>(Base::mainWorldProxy());
- }
ProxyType* windowProxy(DOMWrapperWorld& world) {
return static_cast<ProxyType*>(Base::windowProxy(world));
}
protected:
explicit WindowProxyManagerImplHelper(Frame& frame)
- : WindowProxyManagerBase(frame) {}
+ : WindowProxyManager(frame) {}
};
class LocalWindowProxyManager
@@ -78,14 +83,17 @@ class LocalWindowProxyManager
return new LocalWindowProxyManager(frame);
}
+ LocalWindowProxy* mainWorldProxyMaybeUninitialized() {
dcheng 2017/02/22 01:07:06 I would prefer not to expose this publicly if poss
Yuki 2017/02/22 09:01:33 Hmm, I added WindowProxy::isInitialized() and chan
+ return static_cast<LocalWindowProxy*>(
+ WindowProxyManagerImplHelper<LocalFrame, LocalWindowProxy>::
+ mainWorldProxyMaybeUninitialized());
+ }
+
// Sets the given security origin to the main world's context. Also updates
// the security origin of the context for each isolated world.
void updateSecurityOrigin(SecurityOrigin*);
private:
- // TODO(dcheng): Merge LocalWindowProxyManager and ScriptController?
- friend class ScriptController;
-
explicit LocalWindowProxyManager(LocalFrame& frame)
: WindowProxyManagerImplHelper<LocalFrame, LocalWindowProxy>(frame) {}
};

Powered by Google App Engine
This is Rietveld 408576698