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

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: . 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 // * ContextUninitialized
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 // |ContextInitialized| from a point of view of call sites.
171 // - Possible next states: ContextInitialized
172 // It's possible to detach the context from a frame or navigate to a new page
173 // without initializing the WindowProxy, however, there is no transition to
174 // |ContextDetachedFromFrame| or |GlobalObjectDetached| because
175 // |disposeContext| does not change the state if the state is
176 // |ContextUninitialized|. In either case of a) the browsing context is
177 // detached from a frame or b) the page is navigated away, there must be no
178 // way for author script to access to the context of |ContextUninitialized|
haraken 2017/03/28 11:12:42 access the context
Yuki 2017/03/28 12:22:16 Done.
179 // because |ContextUninitialized| means that author script has never accessed
180 // to the context, hence there must exist no reference to the context.
haraken 2017/03/28 11:12:42 accessed the context
Yuki 2017/03/28 12:22:16 Done.
181 //
182 // * ContextInitialized
183 // The context is initialized and yet attached to a frame.
haraken 2017/03/28 11:12:42 yet => still
Yuki 2017/03/28 12:22:16 Done.
184 // - Possible next states: ContextDetachedFromFrame, GlobalObjectDetached
185 //
186 // * ContextDetachedFromFrame
187 // The context is initialized, once attached to a frame and now detached. Note
188 // that the context is still alive and author script may have references to
189 // the context and hence author script may run in the context.
190 // The spec does not support some of web features such as setTimeout, etc. on
191 // a detached window. Blink does not support more things than the spec,
haraken 2017/03/28 11:12:42 // Blink supports less things than the spec.
Yuki 2017/03/28 12:22:16 Done.
192 // though. V8PerContextData is cut off from the context.
193 // - Possible next states: n/a
haraken 2017/03/28 11:12:42 Isn't it possible to transit from ContextDetachedF
Yuki 2017/03/28 12:22:16 IIUC, no way. GlobalObjectDetached means that it'
194 //
195 // * GlobalObjectDetached
196 // The context is initialized, attached to a frame, and now navigated away.
197 // The global object (inner global) is detached from the global proxy (outer
198 // global), but the (detached) global object and context are still alive, and
199 // author script may have reference to the context.
haraken 2017/03/28 11:12:42 references
Yuki 2017/03/28 12:22:16 Done.
200 // The spec does not support some of web features as same as
201 // |ContextDetachedFromFrame|. Blink does not support this state well samely.
haraken 2017/03/28 11:12:42 // The spec does not support full web features in
Yuki 2017/03/28 12:22:16 Done.
202 // - Possible next states: ContextUninitialized
haraken 2017/03/28 11:12:42 ContextUninitialized or destructor ?
Yuki 2017/03/28 12:22:16 Ditto.
203 // This state is in the middle of navigation, so the next state is
204 // |ContextUninitialized| for a new window/context/document of a new page.
haraken 2017/03/28 11:12:42 This comment looks a bit confusing. It's possible
Yuki 2017/03/28 12:22:16 Oops, I was wrong on this point. GlobalObjectDeta
172 enum class Lifecycle { 205 enum class Lifecycle {
206 // v8::Context is not yet initialized.
173 ContextUninitialized, 207 ContextUninitialized,
208 // v8::Context is initialized.
174 ContextInitialized, 209 ContextInitialized,
175 ContextDetached, 210 // A context is detached from a frame.
211 ContextDetachedFromFrame,
212 // The global object (inner global) is detached from the global proxy.
213 GlobalObjectDetached,
176 }; 214 };
177 215
178 WindowProxy(v8::Isolate*, Frame&, RefPtr<DOMWrapperWorld>); 216 WindowProxy(v8::Isolate*, Frame&, RefPtr<DOMWrapperWorld>);
179 217
180 virtual void initialize() = 0; 218 virtual void initialize() = 0;
181 219
182 enum GlobalDetachmentBehavior { DoNotDetachGlobal, DetachGlobal }; 220 enum GlobalDetachmentBehavior { DoNotDetachGlobal, DetachGlobal };
183 virtual void disposeContext(GlobalDetachmentBehavior) = 0; 221 virtual void disposeContext(GlobalDetachmentBehavior) = 0;
184 222
185 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper( 223 WARN_UNUSED_RESULT v8::Local<v8::Object> associateWithWrapper(
(...skipping 19 matching lines...) Expand all
205 protected: 243 protected:
206 // TODO(dcheng): Consider making these private and using getters. 244 // TODO(dcheng): Consider making these private and using getters.
207 const RefPtr<DOMWrapperWorld> m_world; 245 const RefPtr<DOMWrapperWorld> m_world;
208 ScopedPersistent<v8::Object> m_globalProxy; 246 ScopedPersistent<v8::Object> m_globalProxy;
209 Lifecycle m_lifecycle; 247 Lifecycle m_lifecycle;
210 }; 248 };
211 249
212 } // namespace blink 250 } // namespace blink
213 251
214 #endif // WindowProxy_h 252 #endif // WindowProxy_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698