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

Side by Side Diff: Source/bindings/core/v8/ScriptState.h

Issue 1111163003: Replace v8::Handle<> with v8::Local<> in bindings/core/v8/* (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « Source/bindings/core/v8/ScriptPromiseTest.cpp ('k') | Source/bindings/core/v8/ScriptState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ScriptState_h 5 #ifndef ScriptState_h
6 #define ScriptState_h 6 #define ScriptState_h
7 7
8 #include "bindings/core/v8/ScopedPersistent.h" 8 #include "bindings/core/v8/ScopedPersistent.h"
9 #include "bindings/core/v8/V8PerContextData.h" 9 #include "bindings/core/v8/V8PerContextData.h"
10 #include "core/CoreExport.h" 10 #include "core/CoreExport.h"
(...skipping 26 matching lines...) Expand all
37 m_context->Enter(); 37 m_context->Enter();
38 } 38 }
39 39
40 ~Scope() 40 ~Scope()
41 { 41 {
42 m_context->Exit(); 42 m_context->Exit();
43 } 43 }
44 44
45 private: 45 private:
46 v8::HandleScope m_handleScope; 46 v8::HandleScope m_handleScope;
47 v8::Handle<v8::Context> m_context; 47 v8::Local<v8::Context> m_context;
48 }; 48 };
49 49
50 static PassRefPtr<ScriptState> create(v8::Handle<v8::Context>, PassRefPtr<DO MWrapperWorld>); 50 static PassRefPtr<ScriptState> create(v8::Local<v8::Context>, PassRefPtr<DOM WrapperWorld>);
51 virtual ~ScriptState(); 51 virtual ~ScriptState();
52 52
53 static ScriptState* current(v8::Isolate* isolate) 53 static ScriptState* current(v8::Isolate* isolate)
54 { 54 {
55 return from(isolate->GetCurrentContext()); 55 return from(isolate->GetCurrentContext());
56 } 56 }
57 57
58 static ScriptState* from(v8::Handle<v8::Context> context) 58 static ScriptState* from(v8::Local<v8::Context> context)
59 { 59 {
60 ASSERT(!context.IsEmpty()); 60 ASSERT(!context.IsEmpty());
61 ScriptState* scriptState = static_cast<ScriptState*>(context->GetAligned PointerFromEmbedderData(v8ContextPerContextDataIndex)); 61 ScriptState* scriptState = static_cast<ScriptState*>(context->GetAligned PointerFromEmbedderData(v8ContextPerContextDataIndex));
62 // ScriptState::from() must not be called for a context that does not ha ve 62 // ScriptState::from() must not be called for a context that does not ha ve
63 // valid embedder data in the embedder field. 63 // valid embedder data in the embedder field.
64 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptState); 64 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptState);
65 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptState->context() == conte xt); 65 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptState->context() == conte xt);
66 return scriptState; 66 return scriptState;
67 } 67 }
68 68
69 static ScriptState* forMainWorld(LocalFrame*); 69 static ScriptState* forMainWorld(LocalFrame*);
70 70
71 v8::Isolate* isolate() const { return m_isolate; } 71 v8::Isolate* isolate() const { return m_isolate; }
72 DOMWrapperWorld& world() const { return *m_world; } 72 DOMWrapperWorld& world() const { return *m_world; }
73 LocalDOMWindow* domWindow() const; 73 LocalDOMWindow* domWindow() const;
74 virtual ExecutionContext* executionContext() const; 74 virtual ExecutionContext* executionContext() const;
75 virtual void setExecutionContext(ExecutionContext*); 75 virtual void setExecutionContext(ExecutionContext*);
76 76
77 // This can return an empty handle if the v8::Context is gone. 77 // This can return an empty handle if the v8::Context is gone.
78 v8::Handle<v8::Context> context() const { return m_context.newLocal(m_isolat e); } 78 v8::Local<v8::Context> context() const { return m_context.newLocal(m_isolate ); }
79 bool contextIsValid() const { return !m_context.isEmpty() && m_perContextDat a; } 79 bool contextIsValid() const { return !m_context.isEmpty() && m_perContextDat a; }
80 void detachGlobalObject(); 80 void detachGlobalObject();
81 void clearContext() { return m_context.clear(); } 81 void clearContext() { return m_context.clear(); }
82 #if ENABLE(ASSERT) 82 #if ENABLE(ASSERT)
83 bool isGlobalObjectDetached() const { return m_globalObjectDetached; } 83 bool isGlobalObjectDetached() const { return m_globalObjectDetached; }
84 #endif 84 #endif
85 85
86 V8PerContextData* perContextData() const { return m_perContextData.get(); } 86 V8PerContextData* perContextData() const { return m_perContextData.get(); }
87 void disposePerContextData(); 87 void disposePerContextData();
88 88
89 class Observer { 89 class Observer {
90 public: 90 public:
91 virtual ~Observer() { } 91 virtual ~Observer() { }
92 virtual void willDisposeScriptState(ScriptState*) = 0; 92 virtual void willDisposeScriptState(ScriptState*) = 0;
93 }; 93 };
94 void addObserver(Observer*); 94 void addObserver(Observer*);
95 void removeObserver(Observer*); 95 void removeObserver(Observer*);
96 96
97 bool evalEnabled() const; 97 bool evalEnabled() const;
98 void setEvalEnabled(bool); 98 void setEvalEnabled(bool);
99 ScriptValue getFromGlobalObject(const char* name); 99 ScriptValue getFromGlobalObject(const char* name);
100 100
101 protected: 101 protected:
102 ScriptState(v8::Handle<v8::Context>, PassRefPtr<DOMWrapperWorld>); 102 ScriptState(v8::Local<v8::Context>, PassRefPtr<DOMWrapperWorld>);
103 103
104 private: 104 private:
105 v8::Isolate* m_isolate; 105 v8::Isolate* m_isolate;
106 // This persistent handle is weak. 106 // This persistent handle is weak.
107 ScopedPersistent<v8::Context> m_context; 107 ScopedPersistent<v8::Context> m_context;
108 108
109 // This RefPtr doesn't cause a cycle because all persistent handles that DOM WrapperWorld holds are weak. 109 // This RefPtr doesn't cause a cycle because all persistent handles that DOM WrapperWorld holds are weak.
110 RefPtr<DOMWrapperWorld> m_world; 110 RefPtr<DOMWrapperWorld> m_world;
111 111
112 // This OwnPtr causes a cycle: 112 // This OwnPtr causes a cycle:
(...skipping 29 matching lines...) Expand all
142 } 142 }
143 143
144 private: 144 private:
145 RefPtr<ScriptState> m_scriptState; 145 RefPtr<ScriptState> m_scriptState;
146 ScopedPersistent<v8::Context> m_context; 146 ScopedPersistent<v8::Context> m_context;
147 }; 147 };
148 148
149 } 149 }
150 150
151 #endif // ScriptState_h 151 #endif // ScriptState_h
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/ScriptPromiseTest.cpp ('k') | Source/bindings/core/v8/ScriptState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698