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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 // 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"
11 #include "wtf/RefCounted.h" 11 #include "wtf/RefCounted.h"
12 #include <memory>
13 #include <v8-debug.h> 12 #include <v8-debug.h>
14 #include <v8.h> 13 #include <v8.h>
15 14
16 namespace blink { 15 namespace blink {
17 16
18 class LocalDOMWindow; 17 class LocalDOMWindow;
19 class DOMWrapperWorld; 18 class DOMWrapperWorld;
20 class ExecutionContext; 19 class ExecutionContext;
21 class LocalFrame; 20 class LocalFrame;
22 class ScriptValue; 21 class ScriptValue;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 ScriptState(v8::Local<v8::Context>, PassRefPtr<DOMWrapperWorld>); 108 ScriptState(v8::Local<v8::Context>, PassRefPtr<DOMWrapperWorld>);
110 109
111 private: 110 private:
112 v8::Isolate* m_isolate; 111 v8::Isolate* m_isolate;
113 // This persistent handle is weak. 112 // This persistent handle is weak.
114 ScopedPersistent<v8::Context> m_context; 113 ScopedPersistent<v8::Context> m_context;
115 114
116 // This RefPtr doesn't cause a cycle because all persistent handles that DOM WrapperWorld holds are weak. 115 // This RefPtr doesn't cause a cycle because all persistent handles that DOM WrapperWorld holds are weak.
117 RefPtr<DOMWrapperWorld> m_world; 116 RefPtr<DOMWrapperWorld> m_world;
118 117
119 // This std::unique_ptr causes a cycle: 118 // This OwnPtr causes a cycle:
120 // V8PerContextData --(Persistent)--> v8::Context --(RefPtr)--> ScriptState --(std::unique_ptr)--> V8PerContextData 119 // V8PerContextData --(Persistent)--> v8::Context --(RefPtr)--> ScriptState --(OwnPtr)--> V8PerContextData
121 // So you must explicitly clear the std::unique_ptr by calling disposePerCon textData() 120 // So you must explicitly clear the OwnPtr by calling disposePerContextData( )
122 // once you no longer need V8PerContextData. Otherwise, the v8::Context will leak. 121 // once you no longer need V8PerContextData. Otherwise, the v8::Context will leak.
123 std::unique_ptr<V8PerContextData> m_perContextData; 122 OwnPtr<V8PerContextData> m_perContextData;
124 123
125 #if ENABLE(ASSERT) 124 #if ENABLE(ASSERT)
126 bool m_globalObjectDetached; 125 bool m_globalObjectDetached;
127 #endif 126 #endif
128 }; 127 };
129 128
130 // ScriptStateProtectingContext keeps the context associated with the ScriptStat e alive. 129 // ScriptStateProtectingContext keeps the context associated with the ScriptStat e alive.
131 // You need to call clear() once you no longer need the context. Otherwise, the context will leak. 130 // You need to call clear() once you no longer need the context. Otherwise, the context will leak.
132 class ScriptStateProtectingContext { 131 class ScriptStateProtectingContext {
133 WTF_MAKE_NONCOPYABLE(ScriptStateProtectingContext); 132 WTF_MAKE_NONCOPYABLE(ScriptStateProtectingContext);
(...skipping 15 matching lines...) Expand all
149 } 148 }
150 149
151 private: 150 private:
152 RefPtr<ScriptState> m_scriptState; 151 RefPtr<ScriptState> m_scriptState;
153 ScopedPersistent<v8::Context> m_context; 152 ScopedPersistent<v8::Context> m_context;
154 }; 153 };
155 154
156 } // namespace blink 155 } // namespace blink
157 156
158 #endif // ScriptState_h 157 #endif // ScriptState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698