OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 SKY_ENGINE_CORE_SCRIPT_DART_CONTROLLER_H_ | 5 #ifndef SKY_ENGINE_CORE_SCRIPT_DART_CONTROLLER_H_ |
6 #define SKY_ENGINE_CORE_SCRIPT_DART_CONTROLLER_H_ | 6 #define SKY_ENGINE_CORE_SCRIPT_DART_CONTROLLER_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "dart/runtime/include/dart_api.h" | 11 #include "dart/runtime/include/dart_api.h" |
12 #include "sky/engine/wtf/OwnPtr.h" | 12 #include "sky/engine/wtf/OwnPtr.h" |
13 #include "sky/engine/wtf/text/AtomicString.h" | 13 #include "sky/engine/wtf/text/AtomicString.h" |
14 #include "sky/engine/wtf/text/TextPosition.h" | 14 #include "sky/engine/wtf/text/TextPosition.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 class AbstractModule; | 17 class AbstractModule; |
18 class BuiltinSky; | 18 class BuiltinSky; |
19 class DOMDartState; | 19 class DOMDartState; |
20 class DartValue; | 20 class DartValue; |
21 class Document; | |
22 class HTMLScriptElement; | 21 class HTMLScriptElement; |
23 class KURL; | 22 class KURL; |
24 | 23 |
25 class DartController { | 24 class DartController { |
26 public: | 25 public: |
27 DartController(); | 26 DartController(); |
28 ~DartController(); | 27 ~DartController(); |
29 | 28 |
30 static void InitVM(); | 29 static void InitVM(); |
31 | 30 |
32 typedef base::Callback<void(RefPtr<AbstractModule>, RefPtr<DartValue>)> | 31 typedef base::Callback<void(RefPtr<AbstractModule>, RefPtr<DartValue>)> |
33 LoadFinishedCallback; | 32 LoadFinishedCallback; |
34 | 33 |
35 void LoadMainLibrary(const KURL& url); | 34 void LoadMainLibrary(const KURL& url); |
36 | 35 |
37 void LoadScriptInModule(AbstractModule* module, | 36 void LoadScriptInModule(AbstractModule* module, |
38 const String& source, | 37 const String& source, |
39 const TextPosition& textPosition, | 38 const TextPosition& textPosition, |
40 const LoadFinishedCallback& load_finished_callback); | 39 const LoadFinishedCallback& load_finished_callback); |
41 void ExecuteLibraryInModule(AbstractModule* module, | 40 void ExecuteLibraryInModule(AbstractModule* module, |
42 Dart_Handle library, | 41 Dart_Handle library, |
43 HTMLScriptElement* script); | 42 HTMLScriptElement* script); |
44 | 43 |
45 void ClearForClose(); | 44 void ClearForClose(); |
46 void CreateIsolateFor(Document* document); | 45 void CreateIsolateFor(PassOwnPtr<DOMDartState> dom_dart_state, |
| 46 const KURL& url); |
47 | 47 |
48 DOMDartState* dart_state() const { return dom_dart_state_.get(); } | 48 DOMDartState* dart_state() const { return dom_dart_state_.get(); } |
49 | 49 |
50 private: | 50 private: |
51 bool ImportChildLibraries(AbstractModule* module, Dart_Handle library); | 51 bool ImportChildLibraries(AbstractModule* module, Dart_Handle library); |
52 Dart_Handle CreateLibrary(AbstractModule* module, | 52 Dart_Handle CreateLibrary(AbstractModule* module, |
53 const String& source, | 53 const String& source, |
54 const TextPosition& position); | 54 const TextPosition& position); |
55 | 55 |
56 void DidLoadMainLibrary(KURL url); | 56 void DidLoadMainLibrary(KURL url); |
57 | 57 |
58 OwnPtr<DOMDartState> dom_dart_state_; | 58 OwnPtr<DOMDartState> dom_dart_state_; |
59 OwnPtr<BuiltinSky> builtin_sky_; | 59 OwnPtr<BuiltinSky> builtin_sky_; |
60 | 60 |
61 base::WeakPtrFactory<DartController> weak_factory_; | 61 base::WeakPtrFactory<DartController> weak_factory_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(DartController); | 63 DISALLOW_COPY_AND_ASSIGN(DartController); |
64 }; | 64 }; |
65 | 65 |
66 } | 66 } |
67 | 67 |
68 #endif // SKY_ENGINE_CORE_SCRIPT_DART_CONTROLLER_H_ | 68 #endif // SKY_ENGINE_CORE_SCRIPT_DART_CONTROLLER_H_ |
OLD | NEW |