OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_APP_ABSTRACTMODULE_H_ | 5 #ifndef SKY_ENGINE_CORE_APP_ABSTRACTMODULE_H_ |
6 #define SKY_ENGINE_CORE_APP_ABSTRACTMODULE_H_ | 6 #define SKY_ENGINE_CORE_APP_ABSTRACTMODULE_H_ |
7 | 7 |
8 #include "sky/engine/bindings/core/v8/ScriptPromiseResolver.h" | |
9 #include "sky/engine/core/app/ModuleLoader.h" | |
10 #include "sky/engine/core/dom/ContextLifecycleObserver.h" | 8 #include "sky/engine/core/dom/ContextLifecycleObserver.h" |
11 #include "sky/engine/core/dom/Document.h" | 9 #include "sky/engine/core/dom/Document.h" |
12 #include "sky/engine/core/events/EventTarget.h" | 10 #include "sky/engine/core/events/EventTarget.h" |
13 #include "sky/engine/wtf/RefCounted.h" | 11 #include "sky/engine/wtf/RefCounted.h" |
14 | 12 |
15 namespace blink { | 13 namespace blink { |
16 class Application; | 14 class Application; |
17 | 15 |
18 class AbstractModule : public RefCounted<AbstractModule>, | 16 class AbstractModule : public RefCounted<AbstractModule>, |
19 public EventTargetWithInlineData, | 17 public EventTargetWithInlineData, |
20 public ContextLifecycleObserver, | 18 public ContextLifecycleObserver { |
21 public ModuleLoader::Client { | |
22 DEFINE_WRAPPERTYPEINFO(); | |
23 REFCOUNTED_EVENT_TARGET(AbstractModule); | 19 REFCOUNTED_EVENT_TARGET(AbstractModule); |
24 public: | 20 public: |
25 virtual ~AbstractModule(); | 21 virtual ~AbstractModule(); |
26 | 22 |
27 Document* document() const { return document_.get(); } | 23 Document* document() const { return document_.get(); } |
28 const String& url() const { return url_; } | 24 const String& url() const { return url_; } |
29 | 25 |
30 ScriptPromise import(ScriptState*, const String& url); | 26 virtual bool isApplication() const { return false; } |
| 27 |
| 28 void set_library(RefPtr<DartValue> library) { library_ = library; } |
| 29 |
| 30 DartValue* library() const { return library_.get(); } |
31 | 31 |
32 protected: | 32 protected: |
33 AbstractModule(ExecutionContext*, PassRefPtr<Document>, const String& url); | 33 AbstractModule(ExecutionContext*, PassRefPtr<Document>, const String& url); |
34 | 34 |
35 virtual Application* GetApplication() = 0; | 35 virtual Application* GetApplication() = 0; |
36 | 36 |
37 private: | 37 private: |
38 ExecutionContext* executionContext() const override; | 38 ExecutionContext* executionContext() const override; |
39 | 39 |
40 void OnModuleLoadComplete(ModuleLoader*, Module*) override; | |
41 | |
42 RefPtr<Document> document_; | 40 RefPtr<Document> document_; |
43 String url_; | 41 String url_; |
44 | 42 RefPtr<DartValue> library_; |
45 HashMap<OwnPtr<ModuleLoader>, RefPtr<ScriptPromiseResolver>> loaders_; | |
46 }; | 43 }; |
47 | 44 |
48 } // namespace blink | 45 } // namespace blink |
49 | 46 |
50 #endif // SKY_ENGINE_CORE_APP_ABSTRACTMODULE_H_ | 47 #endif // SKY_ENGINE_CORE_APP_ABSTRACTMODULE_H_ |
OLD | NEW |