| 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 DartLibraryProvider; | 21 class DartLibraryProvider; |
| 22 class DartLibraryProviderWebView; | 22 class DartLibraryProviderWebView; |
| 23 class DartSnapshotLoader; | 23 class DartSnapshotLoader; |
| 24 class DartValue; | 24 class DartValue; |
| 25 class HTMLScriptElement; | |
| 26 class KURL; | 25 class KURL; |
| 27 class View; | 26 class View; |
| 28 | 27 |
| 29 class DartController { | 28 class DartController { |
| 30 public: | 29 public: |
| 31 DartController(); | 30 DartController(); |
| 32 ~DartController(); | 31 ~DartController(); |
| 33 | 32 |
| 34 static void InitVM(); | 33 static void InitVM(); |
| 35 | 34 |
| 36 typedef base::Callback<void(RefPtr<AbstractModule>, RefPtr<DartValue>)> | 35 typedef base::Callback<void(RefPtr<AbstractModule>, RefPtr<DartValue>)> |
| 37 LoadFinishedCallback; | 36 LoadFinishedCallback; |
| 38 | 37 |
| 39 void RunFromLibrary(const String& name, | 38 void RunFromLibrary(const String& name, |
| 40 DartLibraryProvider* library_provider); | 39 DartLibraryProvider* library_provider); |
| 41 void RunFromSnapshot(mojo::ScopedDataPipeConsumerHandle snapshot); | 40 void RunFromSnapshot(mojo::ScopedDataPipeConsumerHandle snapshot); |
| 42 | 41 |
| 43 void LoadScriptInModule(AbstractModule* module, | |
| 44 const String& source, | |
| 45 const TextPosition& textPosition, | |
| 46 const LoadFinishedCallback& load_finished_callback); | |
| 47 void ExecuteLibraryInModule(AbstractModule* module, | |
| 48 Dart_Handle library, | |
| 49 HTMLScriptElement* script); | |
| 50 | |
| 51 void ClearForClose(); | 42 void ClearForClose(); |
| 52 void CreateIsolateFor(PassOwnPtr<DOMDartState> dom_dart_state); | 43 void CreateIsolateFor(PassOwnPtr<DOMDartState> dom_dart_state); |
| 53 void InstallView(View* view); | 44 void InstallView(View* view); |
| 54 | 45 |
| 55 DOMDartState* dart_state() const { return dom_dart_state_.get(); } | 46 DOMDartState* dart_state() const { return dom_dart_state_.get(); } |
| 56 | 47 |
| 57 private: | 48 private: |
| 58 bool ImportChildLibraries(AbstractModule* module, Dart_Handle library); | |
| 59 Dart_Handle CreateLibrary(AbstractModule* module, | |
| 60 const String& source, | |
| 61 const TextPosition& position); | |
| 62 | |
| 63 void DidLoadMainLibrary(String url); | 49 void DidLoadMainLibrary(String url); |
| 64 void DidLoadSnapshot(); | 50 void DidLoadSnapshot(); |
| 65 | 51 |
| 66 OwnPtr<DOMDartState> dom_dart_state_; | 52 OwnPtr<DOMDartState> dom_dart_state_; |
| 67 OwnPtr<BuiltinSky> builtin_sky_; | 53 OwnPtr<BuiltinSky> builtin_sky_; |
| 68 OwnPtr<DartLibraryProviderWebView> library_provider_; | 54 OwnPtr<DartLibraryProviderWebView> library_provider_; |
| 69 OwnPtr<DartSnapshotLoader> snapshot_loader_; | 55 OwnPtr<DartSnapshotLoader> snapshot_loader_; |
| 70 | 56 |
| 71 base::WeakPtrFactory<DartController> weak_factory_; | 57 base::WeakPtrFactory<DartController> weak_factory_; |
| 72 | 58 |
| 73 DISALLOW_COPY_AND_ASSIGN(DartController); | 59 DISALLOW_COPY_AND_ASSIGN(DartController); |
| 74 }; | 60 }; |
| 75 | 61 |
| 76 } | 62 } |
| 77 | 63 |
| 78 #endif // SKY_ENGINE_CORE_SCRIPT_DART_CONTROLLER_H_ | 64 #endif // SKY_ENGINE_CORE_SCRIPT_DART_CONTROLLER_H_ |
| OLD | NEW |