| 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 "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 30 matching lines...) Expand all Loading... |
| 41 // } | 41 // } |
| 42 // | 42 // |
| 43 // void asynchronousMethod() { | 43 // void asynchronousMethod() { |
| 44 // if (!m_scriptState->contextIsValid()) { | 44 // if (!m_scriptState->contextIsValid()) { |
| 45 // // It's possible that the context is already gone. | 45 // // It's possible that the context is already gone. |
| 46 // return; | 46 // return; |
| 47 // } | 47 // } |
| 48 // // Enter the ScriptState. | 48 // // Enter the ScriptState. |
| 49 // ScriptState::Scope scope(m_scriptState.get()); | 49 // ScriptState::Scope scope(m_scriptState.get()); |
| 50 // // Do V8 related things. | 50 // // Do V8 related things. |
| 51 // toV8(...); | 51 // ToV8(...); |
| 52 // } | 52 // } |
| 53 // RefPtr<ScriptState> m_scriptState; | 53 // RefPtr<ScriptState> m_scriptState; |
| 54 // }; | 54 // }; |
| 55 // | 55 // |
| 56 // You should not store ScriptState on a C++ object that can be accessed | 56 // You should not store ScriptState on a C++ object that can be accessed |
| 57 // by multiple worlds. For example, you can store ScriptState on | 57 // by multiple worlds. For example, you can store ScriptState on |
| 58 // ScriptPromiseResolver, ScriptValue etc because they can be accessed from one | 58 // ScriptPromiseResolver, ScriptValue etc because they can be accessed from one |
| 59 // world. However, you cannot store ScriptState on a DOM object that has | 59 // world. However, you cannot store ScriptState on a DOM object that has |
| 60 // an IDL interface because the DOM object can be accessed from multiple | 60 // an IDL interface because the DOM object can be accessed from multiple |
| 61 // worlds. If ScriptState of one world "leak"s to another world, you will | 61 // worlds. If ScriptState of one world "leak"s to another world, you will |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 211 } |
| 212 | 212 |
| 213 private: | 213 private: |
| 214 RefPtr<ScriptState> m_scriptState; | 214 RefPtr<ScriptState> m_scriptState; |
| 215 ScopedPersistent<v8::Context> m_context; | 215 ScopedPersistent<v8::Context> m_context; |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 } // namespace blink | 218 } // namespace blink |
| 219 | 219 |
| 220 #endif // ScriptState_h | 220 #endif // ScriptState_h |
| OLD | NEW |