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