Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: Source/bindings/v8/V8PerContextDebugData.h

Issue 14362015: WIP enum / V8PerContextData solution (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Crash during GC Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 CompilationOriginUnset,
50 CompilationOriginWeb,
51 CompilationOriginExtension,
52 CompilationOriginDevtools,
53 CompilationOriginSystem
54 };
55
56 // The target context of JavaScript source
57 enum CompilationContextCategory {
58 CompilationContextUnset,
59 CompilationContextWebPage,
60 CompilationContextWorker,
61 CompilationContextContentScript,
62 CompilationContextUnprivilegedExtension,
63 CompilationContextPrivilegedExtension,
64 CompilationContextDevtools,
65 CompilationContextUtility
66 };
67
68 enum CompilationRestrictions {
69 CompilationRestrictionsNone,
70 CompilationRestrictionsEval, // issues with naming source and numbering lin es
71 CompilationRestrictionsOneFunction, // one function must result
72 CompilationRestrictionsAttributeSetEventHandler // one function must result
73 };
74
75 // Common combinations used in V8ScopedCompilation
76 enum ScopedCompilationCategory {
77 DevtoolsScriptCompilation, // Devtools, WebPage, None
78 DevtoolsFunctionCompilation, // Devtools, WebPage, OneFunction
79 ExtensionAPICompilation // System, WebPage, None
80 };
81
82 // ---- Permanent marks on the context ----
83 class V8PerContextDebugData {
84 public:
85 // Web, WebPage, None
86 static void setDebugDataForPage(v8::Handle<v8::Context>, int debugId);
87 // Extension, ContentScript, None
88 static void setDebugDataForContentScript(v8::Handle<v8::Context>, int debugI d);
89 // System, Utility, None
90 static void setDebugDataForSystemUtility(v8::Handle<v8::Context>);
91
92 static int debugId(v8::Handle<v8::Context>);
93 static v8::Handle<v8::Value> debugIdValue(v8::Handle<v8::Context> context);
94
95 static CompilationOriginCategory compilationOriginCategory(v8::Handle<v8::Co ntext>);
96
97 static CompilationContextCategory compilationContextCategory(v8::Handle<v8:: Context>);
98 static v8::Handle<v8::Value> compilationContextCategoryValue(v8::Handle<v8:: Context> context);
99
100 static CompilationRestrictions compilationRestrictions(v8::Handle<v8::Contex t>);
101
102 private:
103 friend class V8ScopedCompilation;
104 static void setDebugData(
105 v8::Handle<v8::Context> context,
106 CompilationOriginCategory originCategory,
107 CompilationContextCategory contextCategory,
108 CompilationRestrictions restrictions,
109 int debugId);
110 };
111
112 // ---- Transient marks that unset when we leave the scope
113 class V8ScopedCompilation {
114 public:
115 V8ScopedCompilation(v8::Handle<v8::Context>, ScopedCompilationCategory);
116 V8ScopedCompilation(v8::Handle<v8::Context>, CompilationOriginCategory, Comp ilationContextCategory, CompilationRestrictions);
117 ~V8ScopedCompilation();
118
119 private:
120 void init(CompilationOriginCategory, CompilationContextCategory, Compilation Restrictions);
121 v8::Persistent<v8::Context> m_context;
122 CompilationOriginCategory m_originCategory;
123 CompilationContextCategory m_contextCategory;
124 CompilationRestrictions m_restrictions;
125 int m_debugId;
126 };
127
128 } // namespace WebCore
129
130 #endif // V8PerContextDebugData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698