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

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

Issue 2702273004: bindings: Simplifies WindowProxyManager and its relation to Frame. (Closed)
Patch Set: Did changes in order to keep the exactly same behavior. Created 3 years, 9 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 f05f501ed29d34552f860647dd7446eedfb9b473..be54dbd10734357a42f0a8e2858efafcaa2ca960 100644
--- a/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h
+++ b/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h
@@ -19,9 +19,8 @@ namespace blink {
class DOMWrapperWorld;
class SecurityOrigin;
-class ScriptController;
-class WindowProxyManagerBase : public GarbageCollected<WindowProxyManagerBase> {
+class WindowProxyManager : public GarbageCollected<WindowProxyManager> {
public:
DECLARE_TRACE();
@@ -35,32 +34,44 @@ class WindowProxyManagerBase : public GarbageCollected<WindowProxyManagerBase> {
void CORE_EXPORT
setGlobals(const HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>&);
- protected:
- using IsolatedWorldMap = HeapHashMap<int, Member<WindowProxy>>;
+ bool isMainWorldContextInitialized() const {
+ return !m_windowProxy->contextIfInitialized().IsEmpty();
dcheng 2017/03/10 09:52:13 Can we move this to LocalWindowProxyManager, since
Yuki 2017/03/10 15:21:51 Done.
+ }
- explicit WindowProxyManagerBase(Frame&);
+ WindowProxy* mainWorldProxy() {
+ m_windowProxy->initializeIfNeeded();
+ return m_windowProxy;
+ }
- Frame* frame() const { return m_frame; }
- WindowProxy* mainWorldProxy() const { return m_windowProxy.get(); }
- WindowProxy* windowProxy(DOMWrapperWorld&);
+ WindowProxy* windowProxy(DOMWrapperWorld& world) {
dcheng 2017/03/10 09:52:13 It's not necessary to do it now, but maybe there i
Yuki 2017/03/10 15:21:51 Acknowledged.
+ WindowProxy* windowProxy = windowProxyMaybeUninitialized(world);
+ windowProxy->initializeIfNeeded();
+ return windowProxy;
+ }
+
+ protected:
+ using IsolatedWorldMap = HeapHashMap<int, Member<WindowProxy>>;
- IsolatedWorldMap& isolatedWorlds() { return m_isolatedWorlds; }
+ explicit WindowProxyManager(Frame&);
private:
+ WindowProxy* windowProxyMaybeUninitialized(DOMWrapperWorld&);
+
v8::Isolate* const m_isolate;
const Member<Frame> m_frame;
+
+ protected:
const Member<WindowProxy> m_windowProxy;
IsolatedWorldMap m_isolatedWorlds;
};
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 {
+ ProxyType* mainWorldProxy() {
return static_cast<ProxyType*>(Base::mainWorldProxy());
}
ProxyType* windowProxy(DOMWrapperWorld& world) {
@@ -69,7 +80,7 @@ class WindowProxyManagerImplHelper : public WindowProxyManagerBase {
protected:
explicit WindowProxyManagerImplHelper(Frame& frame)
- : WindowProxyManagerBase(frame) {}
+ : WindowProxyManager(frame) {}
};
class LocalWindowProxyManager
@@ -79,14 +90,16 @@ class LocalWindowProxyManager
return new LocalWindowProxyManager(frame);
}
+ // TODO(yukishiino): Remove this method.
+ LocalWindowProxy* mainWorldProxyMaybeUninitialized() {
+ return static_cast<LocalWindowProxy*>(m_windowProxy.get());
+ }
+
// 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