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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptModule.h

Issue 2792263002: [ES6 modules] Document ScriptModule (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "bindings/core/v8/SharedPersistent.h" 9 #include "bindings/core/v8/SharedPersistent.h"
10 #include "core/CoreExport.h" 10 #include "core/CoreExport.h"
11 #include "v8/include/v8.h" 11 #include "v8/include/v8.h"
12 #include "wtf/Allocator.h" 12 #include "wtf/Allocator.h"
13 #include "wtf/text/WTFString.h" 13 #include "wtf/text/WTFString.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 // ScriptModule wraps a handle to a v8::Module for use in core.
18 //
19 // Using ScriptModules needs a ScriptState and its scope to operate in. You
20 // should always provide the same ScriptState and not try to reuse ScriptModules
21 // across different contexts.
22 // Currently all ScriptModule users can easily access its context Modulator, so
23 // we use it to fill ScriptState in.
haraken 2017/04/04 05:28:26 Would it be nicer to pass in the ScriptState to Sc
kouhei (in TOK) 2017/04/04 06:39:48 I'd like to try ScriptModule lightweight w/o Scrip
17 class CORE_EXPORT ScriptModule final { 24 class CORE_EXPORT ScriptModule final {
18 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 25 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
19 26
20 public: 27 public:
21 static ScriptModule compile(v8::Isolate*, 28 static ScriptModule compile(v8::Isolate*,
22 const String& source, 29 const String& source,
23 const String& fileName); 30 const String& fileName);
24 31
25 ScriptModule() {} 32 ScriptModule() {}
26 ScriptModule(const ScriptModule& module) : m_module(module.m_module) {} 33 ScriptModule(const ScriptModule& module) : m_module(module.m_module) {}
27 ~ScriptModule(); 34 ~ScriptModule();
28 35
29 bool instantiate(ScriptState*); 36 bool instantiate(ScriptState*);
30 void evaluate(ScriptState*); 37 void evaluate(ScriptState*);
31 38
32 bool isNull() const { return m_module->isEmpty(); } 39 bool isNull() const { return m_module->isEmpty(); }
33 40
34 private: 41 private:
35 ScriptModule(v8::Isolate*, v8::Local<v8::Module>); 42 ScriptModule(v8::Isolate*, v8::Local<v8::Module>);
36 43
37 RefPtr<SharedPersistent<v8::Module>> m_module; 44 RefPtr<SharedPersistent<v8::Module>> m_module;
38 }; 45 };
39 46
40 } // namespace blink 47 } // namespace blink
41 48
42 #endif // ScriptModule_h 49 #endif // ScriptModule_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698