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

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

Issue 2620313002: Refactor WindowProxy into Local and Remote subclasses. (Closed)
Patch Set: explicit Created 3 years, 11 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 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef WindowProxy_h 31 #ifndef RemoteWindowProxy_h
32 #define WindowProxy_h 32 #define RemoteWindowProxy_h
33 33
34 #include "bindings/core/v8/DOMWrapperWorld.h" 34 #include "bindings/core/v8/DOMWrapperWorld.h"
35 #include "bindings/core/v8/ScopedPersistent.h" 35 #include "core/frame/RemoteFrame.h"
36 #include "bindings/core/v8/ScriptState.h"
37 #include "platform/heap/Handle.h"
38 #include "platform/weborigin/SecurityOrigin.h"
39 #include "wtf/HashMap.h"
40 #include "wtf/PassRefPtr.h"
41 #include "wtf/RefPtr.h"
42 #include "wtf/text/AtomicString.h"
43 #include <v8.h> 36 #include <v8.h>
44 37
45 namespace blink { 38 namespace blink {
46 39
47 class Frame; 40 // Subclass of WindowProxy that only handles RemoteFrame.
48 class HTMLDocument; 41 class RemoteWindowProxy final : public WindowProxy {
49 class SecurityOrigin; 42 public:
43 static RemoteWindowProxy* create(v8::Isolate* isolate,
44 RemoteFrame& frame,
50 45
51 // WindowProxy represents all the per-global object state for a Frame that 46 RefPtr<DOMWrapperWorld> world) {
52 // persist between navigations. 47 return new RemoteWindowProxy(isolate, frame, std::move(world));
53 class WindowProxy final : public GarbageCollectedFinalized<WindowProxy> {
54 public:
55 static WindowProxy* create(v8::Isolate*, Frame*, DOMWrapperWorld&);
56
57 ~WindowProxy();
58 DECLARE_TRACE();
59
60 v8::Local<v8::Context> contextIfInitialized() const {
61 return m_scriptState ? m_scriptState->context() : v8::Local<v8::Context>();
62 } 48 }
63 ScriptState* getScriptState() const { return m_scriptState.get(); }
64
65 // Update document object of the frame.
66 void updateDocument();
67
68 void namedItemAdded(HTMLDocument*, const AtomicString&);
69 void namedItemRemoved(HTMLDocument*, const AtomicString&);
70
71 // Update the security origin of a document
72 // (e.g., after setting docoument.domain).
73 void updateSecurityOrigin(SecurityOrigin*);
74
75 void initializeIfNeeded();
76
77 void clearForNavigation();
78 void clearForClose();
79
80 v8::Local<v8::Object> globalIfNotDetached();
81 v8::Local<v8::Object> releaseGlobal();
82 void setGlobal(v8::Local<v8::Object>);
83
84 DOMWrapperWorld& world() { return *m_world; }
85 49
86 private: 50 private:
87 // A valid transition is from ContextUninitialized to ContextInitialized, 51 RemoteWindowProxy(v8::Isolate*, RemoteFrame&, RefPtr<DOMWrapperWorld>);
88 // and then ContextDetached. Other transitions are forbidden.
89 enum class Lifecycle {
90 ContextUninitialized,
91 ContextInitialized,
92 ContextDetached,
93 };
94 52
95 WindowProxy(Frame*, PassRefPtr<DOMWrapperWorld>, v8::Isolate*); 53 void initialize() override;
96 void initialize(); 54 void disposeContext(GlobalDetachmentBehavior) override;
97
98 enum GlobalDetachmentBehavior { DoNotDetachGlobal, DetachGlobal };
99 void disposeContext(GlobalDetachmentBehavior);
100
101 void setSecurityToken(SecurityOrigin*);
102
103 // The JavaScript wrapper for the document object is cached on the global
104 // object for fast access. UpdateDocumentProperty sets the wrapper
105 // for the current document on the global object.
106 void updateDocumentProperty();
107
108 // Updates Activity Logger for the current context.
109 void updateActivityLogger();
110 55
111 // Creates a new v8::Context with the window wrapper object as the global 56 // Creates a new v8::Context with the window wrapper object as the global
112 // object (aka the inner global). Note that the window wrapper and its 57 // object (aka the inner global). Note that the window wrapper and its
113 // prototype chain do not get fully initialized yet, e.g. the window 58 // prototype chain do not get fully initialized yet, e.g. the window
114 // wrapper is not yet associated with the native DOMWindow object. 59 // wrapper is not yet associated with the native DOMWindow object.
115 void createContext(); 60 void createContext();
116
117 // Associates the window wrapper and its prototype chain with the native
118 // DOMWindow object. Also does some more Window-specific initialization.
119 void setupWindowPrototypeChain();
120
121 Member<Frame> m_frame;
122 v8::Isolate* m_isolate;
123 RefPtr<ScriptState> m_scriptState;
124 RefPtr<DOMWrapperWorld> m_world;
125 ScopedPersistent<v8::Object> m_globalProxy;
126 Lifecycle m_lifecycle;
127 }; 61 };
128 62
129 } // namespace blink 63 } // namespace blink
130 64
131 #endif // WindowProxy_h 65 #endif // RemoteWindowProxy_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698