OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 m_exception = exception; | 56 m_exception = exception; |
57 } | 57 } |
58 v8::Local<v8::Value> exception() { return m_exception; } | 58 v8::Local<v8::Value> exception() { return m_exception; } |
59 void clearException() { m_exception.Clear(); } | 59 void clearException() { m_exception.Clear(); } |
60 | 60 |
61 v8::Local<v8::Context> context() const | 61 v8::Local<v8::Context> context() const |
62 { | 62 { |
63 return v8::Local<v8::Context>::New(m_context.get()); | 63 return v8::Local<v8::Context>::New(m_context.get()); |
64 } | 64 } |
65 | 65 |
| 66 v8::Isolate* isolate() |
| 67 { |
| 68 if (!m_isolate) |
| 69 m_isolate = v8::Isolate::GetCurrent(); |
| 70 return m_isolate; |
| 71 } |
| 72 |
66 DOMWindow* domWindow() const; | 73 DOMWindow* domWindow() const; |
67 ScriptExecutionContext* scriptExecutionContext() const; | 74 ScriptExecutionContext* scriptExecutionContext() const; |
68 | 75 |
69 static ScriptState* forContext(v8::Local<v8::Context>); | 76 static ScriptState* forContext(v8::Local<v8::Context>); |
70 static ScriptState* current(); | 77 static ScriptState* current(); |
71 | 78 |
72 protected: | 79 protected: |
73 ScriptState() { } | 80 ScriptState() { } |
74 ~ScriptState(); | 81 ~ScriptState(); |
75 | 82 |
76 private: | 83 private: |
77 friend ScriptState* mainWorldScriptState(Frame*); | 84 friend ScriptState* mainWorldScriptState(Frame*); |
78 explicit ScriptState(v8::Handle<v8::Context>); | 85 explicit ScriptState(v8::Handle<v8::Context>); |
79 | 86 |
80 static void weakReferenceCallback(v8::Persistent<v8::Value> object, void* pa
rameter); | 87 static void weakReferenceCallback(v8::Persistent<v8::Value> object, void* pa
rameter); |
81 | 88 |
82 v8::Local<v8::Value> m_exception; | 89 v8::Local<v8::Value> m_exception; |
83 ScopedPersistent<v8::Context> m_context; | 90 ScopedPersistent<v8::Context> m_context; |
| 91 v8::Isolate* m_isolate; |
84 }; | 92 }; |
85 | 93 |
86 class EmptyScriptState : public ScriptState { | 94 class EmptyScriptState : public ScriptState { |
87 public: | 95 public: |
88 EmptyScriptState() : ScriptState() { } | 96 EmptyScriptState() : ScriptState() { } |
89 ~EmptyScriptState() { } | 97 ~EmptyScriptState() { } |
90 }; | 98 }; |
91 | 99 |
92 class ScriptStateProtectedPtr { | 100 class ScriptStateProtectedPtr { |
93 WTF_MAKE_NONCOPYABLE(ScriptStateProtectedPtr); | 101 WTF_MAKE_NONCOPYABLE(ScriptStateProtectedPtr); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 #if ENABLE(WORKERS) | 134 #if ENABLE(WORKERS) |
127 ScriptState* scriptStateFromWorkerContext(WorkerContext*); | 135 ScriptState* scriptStateFromWorkerContext(WorkerContext*); |
128 #endif | 136 #endif |
129 | 137 |
130 inline DOMWrapperWorld* debuggerWorld() { return mainThreadNormalWorld(); } | 138 inline DOMWrapperWorld* debuggerWorld() { return mainThreadNormalWorld(); } |
131 inline DOMWrapperWorld* pluginWorld() { return mainThreadNormalWorld(); } | 139 inline DOMWrapperWorld* pluginWorld() { return mainThreadNormalWorld(); } |
132 | 140 |
133 } | 141 } |
134 | 142 |
135 #endif // ScriptState_h | 143 #endif // ScriptState_h |
OLD | NEW |