| OLD | NEW |
| (Empty) | |
| 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * |
| 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are |
| 6 * met: |
| 7 * |
| 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above |
| 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. |
| 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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. |
| 29 */ |
| 30 |
| 31 #ifndef V8PerContextDebugData_h |
| 32 #define V8PerContextDebugData_h |
| 33 |
| 34 #include <v8.h> |
| 35 |
| 36 namespace WebCore { |
| 37 |
| 38 enum V8ContextEmbedderDataField { |
| 39 v8ContextDebugIdIndex, |
| 40 v8ContextPerContextDataIndex, |
| 41 v8ContextIsolatedWorld, |
| 42 v8ContextCreatorIndex |
| 43 // Rather than adding more embedder data fields to v8::Context, |
| 44 // consider adding the data to V8PerContextData instead. |
| 45 }; |
| 46 |
| 47 // The web-origin of JavaScript source |
| 48 enum CompilationOriginCategory { |
| 49 CompilationOriginWeb, |
| 50 CompilationOriginExtension, |
| 51 CompilationOriginDevtools, |
| 52 CompilationOriginSystem |
| 53 }; |
| 54 |
| 55 // The target context of JavaScript source |
| 56 enum CompilationContextCategory { |
| 57 CompilationContextWebPage, |
| 58 CompilationContextContentScript, |
| 59 CompilationContextUnprivilegedExtension, |
| 60 CompilationContextPrivilegedExtension, |
| 61 CompilationContextDevtools, |
| 62 CompilationContextUtility |
| 63 }; |
| 64 |
| 65 enum CompilationRestrictions { |
| 66 CompilationRestrictionsNone, |
| 67 CompilationRestrictionsEval, // issues with naming source and numbering lin
es |
| 68 CompilationRestrictionsOneFunction, // one function must result |
| 69 CompilationRestrictionsAttributeSetEventHandler // one function must result |
| 70 }; |
| 71 |
| 72 // Common combinations used in V8ScopedCompilation |
| 73 enum ScopedCompilationCategory { |
| 74 DevtoolsScriptCompilation, // Devtools, WebPage, None |
| 75 DevtoolsFunctionCompilation, // Devtools, WebPage, OneFunction |
| 76 ExtensionAPICompilation // System, WebPage, None |
| 77 }; |
| 78 |
| 79 // ---- Permanent marks on the context ---- |
| 80 class V8PerContextDebugData { |
| 81 public: |
| 82 // Web, WebPage, None |
| 83 static void setDebugDataForPage(v8::Handle<v8::Context>, int debugId); |
| 84 // Extension, ContentScript, None |
| 85 static void setDebugDataForContentScript(v8::Handle<v8::Context>, int debugI
d); |
| 86 // System, Utility, None |
| 87 static void setDebugDataForSystemUtility(v8::Handle<v8::Context>); |
| 88 |
| 89 static int debugId(v8::Handle<v8::Context>); |
| 90 static CompilationOriginCategory compilationOriginCategory(v8::Handle<v8::Co
ntext>); |
| 91 static CompilationContextCategory compilationContextCategory(v8::Handle<v8::
Context>); |
| 92 static CompilationRestrictions compilationRestrictions(v8::Handle<v8::Contex
t>); |
| 93 |
| 94 private: |
| 95 friend class V8ScopedCompilation; |
| 96 static void setDebugData( |
| 97 v8::Handle<v8::Context> context, |
| 98 CompilationOriginCategory originCategory, |
| 99 CompilationContextCategory contextCategory, |
| 100 CompilationRestrictions restrictions, |
| 101 int debugId); |
| 102 }; |
| 103 |
| 104 // ---- Transient marks that unset when we leave the scope |
| 105 class V8ScopedCompilation { |
| 106 public: |
| 107 V8ScopedCompilation(v8::Handle<v8::Context>, ScopedCompilationCategory); |
| 108 V8ScopedCompilation(v8::Handle<v8::Context>, CompilationOriginCategory, Comp
ilationContextCategory, CompilationRestrictions); |
| 109 ~V8ScopedCompilation(); |
| 110 |
| 111 private: |
| 112 void init(CompilationOriginCategory, CompilationContextCategory, Compilation
Restrictions); |
| 113 v8::Persistent<v8::Context> m_context; |
| 114 CompilationOriginCategory m_originCategory; |
| 115 CompilationContextCategory m_contextCategory; |
| 116 CompilationRestrictions m_restrictions; |
| 117 int m_debugId; |
| 118 }; |
| 119 |
| 120 } // namespace WebCore |
| 121 |
| 122 #endif // V8PerContextDebugData_h |
| OLD | NEW |