OLD | NEW |
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 <memory> | 8 #include <memory> |
9 | 9 |
10 #include "bindings/core/v8/ScopedPersistent.h" | 10 #include "platform/PlatformExport.h" |
11 #include "bindings/core/v8/V8PerContextData.h" | 11 #include "platform/bindings/ScopedPersistent.h" |
12 #include "core/CoreExport.h" | 12 #include "platform/bindings/V8PerContextData.h" |
13 #include "platform/wtf/RefCounted.h" | 13 #include "platform/wtf/RefCounted.h" |
14 #include "v8/include/v8-debug.h" | 14 #include "v8/include/v8-debug.h" |
15 #include "v8/include/v8.h" | 15 #include "v8/include/v8.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 class DOMWrapperWorld; | 19 class DOMWrapperWorld; |
20 class ScriptValue; | 20 class ScriptValue; |
21 | 21 |
22 // ScriptState is an abstraction class that holds all information about script | 22 // ScriptState is an abstraction class that holds all information about script |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // world. However, you cannot store ScriptState on a DOM object that has | 57 // world. However, you cannot store ScriptState on a DOM object that has |
58 // an IDL interface because the DOM object can be accessed from multiple | 58 // an IDL interface because the DOM object can be accessed from multiple |
59 // worlds. If ScriptState of one world "leak"s to another world, you will | 59 // worlds. If ScriptState of one world "leak"s to another world, you will |
60 // end up with leaking any JavaScript objects from one Chrome extension | 60 // end up with leaking any JavaScript objects from one Chrome extension |
61 // to another Chrome extension, which is a severe security bug. | 61 // to another Chrome extension, which is a severe security bug. |
62 // | 62 // |
63 // Lifetime: | 63 // Lifetime: |
64 // ScriptState is created when v8::Context is created. | 64 // ScriptState is created when v8::Context is created. |
65 // ScriptState is destroyed when v8::Context is garbage-collected and | 65 // ScriptState is destroyed when v8::Context is garbage-collected and |
66 // all V8 proxy objects that have references to the ScriptState are destructed. | 66 // all V8 proxy objects that have references to the ScriptState are destructed. |
67 class CORE_EXPORT ScriptState : public RefCounted<ScriptState> { | 67 class PLATFORM_EXPORT ScriptState : public RefCounted<ScriptState> { |
68 WTF_MAKE_NONCOPYABLE(ScriptState); | 68 WTF_MAKE_NONCOPYABLE(ScriptState); |
69 | 69 |
70 public: | 70 public: |
71 class Scope { | 71 class Scope { |
72 STACK_ALLOCATED(); | 72 STACK_ALLOCATED(); |
73 | 73 |
74 public: | 74 public: |
75 // You need to make sure that scriptState->context() is not empty before | 75 // You need to make sure that scriptState->context() is not empty before |
76 // creating a Scope. | 76 // creating a Scope. |
77 explicit Scope(ScriptState* script_state) | 77 explicit Scope(ScriptState* script_state) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } | 192 } |
193 | 193 |
194 private: | 194 private: |
195 RefPtr<ScriptState> script_state_; | 195 RefPtr<ScriptState> script_state_; |
196 ScopedPersistent<v8::Context> context_; | 196 ScopedPersistent<v8::Context> context_; |
197 }; | 197 }; |
198 | 198 |
199 } // namespace blink | 199 } // namespace blink |
200 | 200 |
201 #endif // ScriptState_h | 201 #endif // ScriptState_h |
OLD | NEW |