OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef V8RecursionScope_h | 31 #ifndef V8RecursionScope_h |
32 #define V8RecursionScope_h | 32 #define V8RecursionScope_h |
33 | 33 |
| 34 #include "ScriptExecutionContext.h" |
34 #include "V8Binding.h" | 35 #include "V8Binding.h" |
35 | 36 |
36 namespace WebCore { | 37 namespace WebCore { |
37 | 38 |
38 class ScriptExecutionContext; | |
39 | |
40 class V8RecursionScope { | 39 class V8RecursionScope { |
41 WTF_MAKE_NONCOPYABLE(V8RecursionScope); | 40 WTF_MAKE_NONCOPYABLE(V8RecursionScope); |
42 public: | 41 public: |
43 explicit V8RecursionScope(ScriptExecutionContext* context) | 42 explicit V8RecursionScope(ScriptExecutionContext* context) |
44 : m_context(context) | 43 : m_isDocumentContext(context && context->isDocument()) |
45 { | 44 { |
46 V8BindingPerIsolateData::current()->incrementRecursionLevel(); | 45 V8BindingPerIsolateData::current()->incrementRecursionLevel(); |
47 } | 46 } |
48 | 47 |
49 ~V8RecursionScope() | 48 ~V8RecursionScope() |
50 { | 49 { |
51 if (!V8BindingPerIsolateData::current()->decrementRecursionLevel()) | 50 if (!V8BindingPerIsolateData::current()->decrementRecursionLevel()) |
52 didLeaveScriptContext(m_context); | 51 didLeaveScriptContext(); |
53 } | 52 } |
54 | 53 |
55 static int recursionLevel() { return V8BindingPerIsolateData::current()->rec
ursionLevel(); } | 54 static int recursionLevel() { return V8BindingPerIsolateData::current()->rec
ursionLevel(); } |
56 | 55 |
57 private: | 56 private: |
58 static void didLeaveScriptContext(ScriptExecutionContext*); | 57 void didLeaveScriptContext(); |
59 | 58 |
60 ScriptExecutionContext* m_context; | 59 bool m_isDocumentContext; |
61 }; | 60 }; |
62 | 61 |
63 } // namespace WebCore | 62 } // namespace WebCore |
64 | 63 |
65 #endif // V8RecursionScope_h | 64 #endif // V8RecursionScope_h |
OLD | NEW |