OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 ScriptModule_h | 5 #ifndef ScriptModule_h |
6 #define ScriptModule_h | 6 #define ScriptModule_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "platform/bindings/ScriptState.h" | 9 #include "platform/bindings/ScriptState.h" |
10 #include "platform/bindings/SharedPersistent.h" | 10 #include "platform/bindings/SharedPersistent.h" |
11 #include "platform/loader/fetch/AccessControlStatus.h" | 11 #include "platform/loader/fetch/AccessControlStatus.h" |
12 #include "platform/wtf/Allocator.h" | 12 #include "platform/wtf/Allocator.h" |
13 #include "platform/wtf/Vector.h" | 13 #include "platform/wtf/Vector.h" |
| 14 #include "platform/wtf/text/TextPosition.h" |
14 #include "platform/wtf/text/WTFString.h" | 15 #include "platform/wtf/text/WTFString.h" |
15 #include "v8/include/v8.h" | 16 #include "v8/include/v8.h" |
16 | 17 |
17 namespace blink { | 18 namespace blink { |
18 | 19 |
19 // ScriptModule wraps a handle to a v8::Module for use in core. | 20 // ScriptModule wraps a handle to a v8::Module for use in core. |
20 // | 21 // |
21 // Using ScriptModules needs a ScriptState and its scope to operate in. You | 22 // Using ScriptModules needs a ScriptState and its scope to operate in. You |
22 // should always provide the same ScriptState and not try to reuse ScriptModules | 23 // should always provide the same ScriptState and not try to reuse ScriptModules |
23 // across different contexts. | 24 // across different contexts. |
24 // Currently all ScriptModule users can easily access its context Modulator, so | 25 // Currently all ScriptModule users can easily access its context Modulator, so |
25 // we use it to fill ScriptState in. | 26 // we use it to fill ScriptState in. |
26 class CORE_EXPORT ScriptModule final { | 27 class CORE_EXPORT ScriptModule final { |
27 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 28 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
28 | 29 |
29 public: | 30 public: |
30 static ScriptModule Compile(v8::Isolate*, | 31 static ScriptModule Compile( |
31 const String& source, | 32 v8::Isolate*, |
32 const String& file_name, | 33 const String& source, |
33 AccessControlStatus); | 34 const String& file_name, |
| 35 AccessControlStatus, |
| 36 const TextPosition& start_position = TextPosition::MinimumPosition()); |
34 | 37 |
35 // TODO(kouhei): Remove copy ctor | 38 // TODO(kouhei): Remove copy ctor |
36 ScriptModule(); | 39 ScriptModule(); |
37 ScriptModule(WTF::HashTableDeletedValueType); | 40 ScriptModule(WTF::HashTableDeletedValueType); |
38 ~ScriptModule(); | 41 ~ScriptModule(); |
39 | 42 |
40 // Returns exception, if any. | 43 // Returns exception, if any. |
41 ScriptValue Instantiate(ScriptState*); | 44 ScriptValue Instantiate(ScriptState*); |
42 | 45 |
43 void Evaluate(ScriptState*) const; | 46 void Evaluate(ScriptState*) const; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 using Hash = blink::ScriptModuleHash; | 115 using Hash = blink::ScriptModuleHash; |
113 }; | 116 }; |
114 | 117 |
115 template <> | 118 template <> |
116 struct HashTraits<blink::ScriptModule> | 119 struct HashTraits<blink::ScriptModule> |
117 : public SimpleClassHashTraits<blink::ScriptModule> {}; | 120 : public SimpleClassHashTraits<blink::ScriptModule> {}; |
118 | 121 |
119 } // namespace WTF | 122 } // namespace WTF |
120 | 123 |
121 #endif // ScriptModule_h | 124 #endif // ScriptModule_h |
OLD | NEW |