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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/WindowProxy.h

Issue 2769803003: v8binding: Initializes WindowProxy iff it's uninitialized. (Closed)
Patch Set: Synced. Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 24 matching lines...) Expand all
35 #include "bindings/core/v8/ScopedPersistent.h" 35 #include "bindings/core/v8/ScopedPersistent.h"
36 #include "core/CoreExport.h" 36 #include "core/CoreExport.h"
37 #include "platform/heap/Handle.h" 37 #include "platform/heap/Handle.h"
38 #include "v8/include/v8.h" 38 #include "v8/include/v8.h"
39 #include "wtf/RefPtr.h" 39 #include "wtf/RefPtr.h"
40 40
41 namespace blink { 41 namespace blink {
42 42
43 class DOMWindow; 43 class DOMWindow;
44 class Frame; 44 class Frame;
45 class ScriptController;
46 45
47 // WindowProxy implements the split window model of a window for a frame. In the 46 // WindowProxy implements the split window model of a window for a frame. In the
48 // HTML standard, the split window model is composed of the Window interface 47 // HTML standard, the split window model is composed of the Window interface
49 // (the inner global object) and the WindowProxy interface (the outer global 48 // (the inner global object) and the WindowProxy interface (the outer global
50 // proxy). 49 // proxy).
51 // 50 //
52 // The Window interface is backed by the Blink DOMWindow C++ implementation. 51 // The Window interface is backed by the Blink DOMWindow C++ implementation.
53 // In contrast, the WindowProxy interface does not have a corresponding 52 // In contrast, the WindowProxy interface does not have a corresponding
54 // C++ implementation in Blink: the WindowProxy class defined here only manages 53 // C++ implementation in Blink: the WindowProxy class defined here only manages
55 // context initialization and detach. Instead, the behavior of the WindowProxy 54 // context initialization and detach. Instead, the behavior of the WindowProxy
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 v8::Local<v8::Object> releaseGlobal(); 155 v8::Local<v8::Object> releaseGlobal();
157 void setGlobal(v8::Local<v8::Object>); 156 void setGlobal(v8::Local<v8::Object>);
158 157
159 // TODO(dcheng): Temporarily exposed to avoid include cycles. Remove the need 158 // TODO(dcheng): Temporarily exposed to avoid include cycles. Remove the need
160 // for this and remove this getter. 159 // for this and remove this getter.
161 DOMWrapperWorld& world() { return *m_world; } 160 DOMWrapperWorld& world() { return *m_world; }
162 161
163 virtual bool isLocal() const { return false; } 162 virtual bool isLocal() const { return false; }
164 163
165 protected: 164 protected:
166 // TODO(dcheng): Remove this friend declaration once LocalWindowProxyManager 165 // Lifecycle represents the following four states.
167 // and ScriptController are merged. 166 //
168 friend class ScriptController; 167 // * ContextIsUninitialized
169 168 // We lazily initialize WindowProxies for performance reasons, and this state
170 // A valid transition is from ContextUninitialized to ContextInitialized, 169 // is "to be initialized on demand". WindowProxy basically behaves the same as
171 // and then ContextDetached. Other transitions are forbidden. 170 // |ContextIsInitialized| from a point of view of call sites.
171 // - Possible next states: ContextIsInitialized
172 // It's possible to detach the context's frame from the DOM or navigate to a
173 // new page without initializing the WindowProxy, however, there is no
174 // transition to |FrameIsDetached| or |GlobalObjectIsDetached|
175 // because |disposeContext| does not change the state if the state is
176 // |ContextIsUninitialized|. In either case of a) the browsing context
177 // container is detached from the DOM or b) the page is navigated away, there
178 // must be no way for author script to access the context of
179 // |ContextIsUninitialized| because |ContextIsUninitialized| means that author
180 // script has never accessed the context, hence there must exist no reference
181 // to the context.
182 //
183 // * ContextIsInitialized
184 // The context is initialized and its frame is still attached to the DOM.
185 // - Possible next states: FrameIsDetached, GlobalObjectIsDetached
186 //
187 // * GlobalObjectIsDetached
188 // The context is initialized and its frame is still attached to the DOM, and
189 // the page is now navigated away. The global object (inner global) is
dcheng 2017/03/30 21:03:01 Maybe something like this would be slightly cleare
Yuki 2017/03/31 07:32:09 Done.
190 // detached from the global proxy (outer global), but the (detached) global
191 // object and context are still alive, and author script may have references
192 // to the context.
193 // The spec does not support full web features in this state. Blink supports
194 // less things than the spec.
195 // - Possible next states: ContextIsInitialized
196 // This state is in the middle of navigation. Once document loading is
197 // completed, the WindowProxy will always be reinitialized, as
198 // |DocumentLoader::installNewDocument| ends up calling to
199 // |WindowProxy::updateDocument|, which reinitializes the WindowProxy.
200 //
201 // * FrameIsDetached
202 // The context was initialized, but its frame has been detached from the DOM.
203 // Note that the context is still alive and author script may have references
204 // to the context and hence author script may run in the context.
205 // The spec does not support some of web features such as setTimeout, etc. on
206 // a detached window. Blink supports less things than the spec.
207 // V8PerContextData is cut off from the context.
208 // - Possible next states: n/a
172 enum class Lifecycle { 209 enum class Lifecycle {
173 ContextUninitialized, 210 // v8::Context is not yet initialized.
174 ContextInitialized, 211 ContextIsUninitialized,
175 ContextDetached, 212 // v8::Context is initialized.
213 ContextIsInitialized,
214 // The global object (inner global) is detached from the global proxy (outer
215 // global).
216 GlobalObjectIsDetached,
217 // The context's frame is detached from the DOM.
218 FrameIsDetached,
176 }; 219 };
177 220
178 WindowProxy(v8::Isolate*, Frame&, RefPtr<DOMWrapperWorld>); 221 WindowProxy(v8::Isolate*, Frame&, RefPtr<DOMWrapperWorld>);
179 222
180 virtual void initialize() = 0; 223 virtual void initialize() = 0;
181 224
182 enum GlobalDetachmentBehavior { DoNotDetachGlobal, DetachGlobal }; 225 enum GlobalDetachmentBehavior { DoNotDetachGlobal, DetachGlobal };
183 virtual void disposeContext(GlobalDetachmentBehavior) = 0; 226 virtual void disposeContext(GlobalDetachmentBehavior) = 0;
184 227
185 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper( 228 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper(
(...skipping 19 matching lines...) Expand all
205 protected: 248 protected:
206 // TODO(dcheng): Consider making these private and using getters. 249 // TODO(dcheng): Consider making these private and using getters.
207 const RefPtr<DOMWrapperWorld> m_world; 250 const RefPtr<DOMWrapperWorld> m_world;
208 ScopedPersistent<v8::Object> m_globalProxy; 251 ScopedPersistent<v8::Object> m_globalProxy;
209 Lifecycle m_lifecycle; 252 Lifecycle m_lifecycle;
210 }; 253 };
211 254
212 } // namespace blink 255 } // namespace blink
213 256
214 #endif // WindowProxy_h 257 #endif // WindowProxy_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698