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 "mojo/services/network/public/interfaces/url_loader.mojom.h" | 12 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" |
13 #include "sky/engine/wtf/OwnPtr.h" | 13 #include "sky/engine/wtf/OwnPtr.h" |
14 #include "sky/engine/wtf/text/AtomicString.h" | 14 #include "sky/engine/wtf/text/AtomicString.h" |
15 #include "sky/engine/wtf/text/TextPosition.h" | 15 #include "sky/engine/wtf/text/TextPosition.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 class AbstractModule; | 18 class AbstractModule; |
19 class BuiltinSky; | 19 class BuiltinSky; |
20 class DOMDartState; | 20 class DOMDartState; |
21 class DartLibraryProviderNetwork; | 21 class DartLibraryProvider; |
| 22 class DartLibraryProviderWebView; |
22 class DartSnapshotLoader; | 23 class DartSnapshotLoader; |
23 class DartValue; | 24 class DartValue; |
24 class HTMLScriptElement; | 25 class HTMLScriptElement; |
25 class KURL; | 26 class KURL; |
26 class View; | 27 class View; |
27 | 28 |
28 class DartController { | 29 class DartController { |
29 public: | 30 public: |
30 DartController(); | 31 DartController(); |
31 ~DartController(); | 32 ~DartController(); |
32 | 33 |
33 static void InitVM(); | 34 static void InitVM(); |
34 | 35 |
35 typedef base::Callback<void(RefPtr<AbstractModule>, RefPtr<DartValue>)> | 36 typedef base::Callback<void(RefPtr<AbstractModule>, RefPtr<DartValue>)> |
36 LoadFinishedCallback; | 37 LoadFinishedCallback; |
37 | 38 |
38 // Can either issue the url load ourselves or take an existing response: | |
39 void LoadMainLibrary(const KURL& url, mojo::URLResponsePtr response = nullptr)
; | |
40 void LoadSnapshot(const KURL& url, mojo::URLResponsePtr response = nullptr); | 39 void LoadSnapshot(const KURL& url, mojo::URLResponsePtr response = nullptr); |
41 | 40 |
| 41 void RunFromLibrary(const String& name, |
| 42 DartLibraryProvider* library_provider); |
| 43 |
42 void LoadScriptInModule(AbstractModule* module, | 44 void LoadScriptInModule(AbstractModule* module, |
43 const String& source, | 45 const String& source, |
44 const TextPosition& textPosition, | 46 const TextPosition& textPosition, |
45 const LoadFinishedCallback& load_finished_callback); | 47 const LoadFinishedCallback& load_finished_callback); |
46 void ExecuteLibraryInModule(AbstractModule* module, | 48 void ExecuteLibraryInModule(AbstractModule* module, |
47 Dart_Handle library, | 49 Dart_Handle library, |
48 HTMLScriptElement* script); | 50 HTMLScriptElement* script); |
49 | 51 |
50 void ClearForClose(); | 52 void ClearForClose(); |
51 void CreateIsolateFor(PassOwnPtr<DOMDartState> dom_dart_state); | 53 void CreateIsolateFor(PassOwnPtr<DOMDartState> dom_dart_state); |
52 void InstallView(View* view); | 54 void InstallView(View* view); |
53 | 55 |
54 DOMDartState* dart_state() const { return dom_dart_state_.get(); } | 56 DOMDartState* dart_state() const { return dom_dart_state_.get(); } |
55 | 57 |
56 private: | 58 private: |
57 bool ImportChildLibraries(AbstractModule* module, Dart_Handle library); | 59 bool ImportChildLibraries(AbstractModule* module, Dart_Handle library); |
58 Dart_Handle CreateLibrary(AbstractModule* module, | 60 Dart_Handle CreateLibrary(AbstractModule* module, |
59 const String& source, | 61 const String& source, |
60 const TextPosition& position); | 62 const TextPosition& position); |
61 | 63 |
62 void DidLoadMainLibrary(KURL url); | 64 void DidLoadMainLibrary(String url); |
63 void DidLoadSnapshot(); | 65 void DidLoadSnapshot(); |
64 | 66 |
65 OwnPtr<DOMDartState> dom_dart_state_; | 67 OwnPtr<DOMDartState> dom_dart_state_; |
66 OwnPtr<BuiltinSky> builtin_sky_; | 68 OwnPtr<BuiltinSky> builtin_sky_; |
67 OwnPtr<DartLibraryProviderNetwork> library_provider_; | 69 OwnPtr<DartLibraryProviderWebView> library_provider_; |
68 OwnPtr<DartSnapshotLoader> snapshot_loader_; | 70 OwnPtr<DartSnapshotLoader> snapshot_loader_; |
69 | 71 |
70 base::WeakPtrFactory<DartController> weak_factory_; | 72 base::WeakPtrFactory<DartController> weak_factory_; |
71 | 73 |
72 DISALLOW_COPY_AND_ASSIGN(DartController); | 74 DISALLOW_COPY_AND_ASSIGN(DartController); |
73 }; | 75 }; |
74 | 76 |
75 } | 77 } |
76 | 78 |
77 #endif // SKY_ENGINE_CORE_SCRIPT_DART_CONTROLLER_H_ | 79 #endif // SKY_ENGINE_CORE_SCRIPT_DART_CONTROLLER_H_ |
OLD | NEW |