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_TONIC_DART_LIBRARY_LOADER_H_ | 5 #ifndef SKY_ENGINE_TONIC_DART_LIBRARY_LOADER_H_ |
6 #define SKY_ENGINE_TONIC_DART_LIBRARY_LOADER_H_ | 6 #define SKY_ENGINE_TONIC_DART_LIBRARY_LOADER_H_ |
7 | 7 |
| 8 #include <string> |
| 9 #include <unordered_map> |
8 #include <vector> | 10 #include <vector> |
| 11 |
9 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
10 #include "base/macros.h" | 13 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
12 #include "dart/runtime/include/dart_api.h" | 15 #include "dart/runtime/include/dart_api.h" |
13 #include "sky/engine/wtf/HashMap.h" | |
14 #include "sky/engine/wtf/HashSet.h" | 16 #include "sky/engine/wtf/HashSet.h" |
15 #include "sky/engine/wtf/OwnPtr.h" | 17 #include "sky/engine/wtf/OwnPtr.h" |
16 #include "sky/engine/wtf/text/WTFString.h" | |
17 | 18 |
18 namespace blink { | 19 namespace blink { |
19 class DartDependency; | 20 class DartDependency; |
20 class DartDependencyCatcher; | 21 class DartDependencyCatcher; |
21 class DartLibraryProvider; | 22 class DartLibraryProvider; |
22 class DartState; | 23 class DartState; |
23 | 24 |
24 // TODO(abarth): This class seems more complicated than it needs to be. Is | 25 // TODO(abarth): This class seems more complicated than it needs to be. Is |
25 // there some way of simplifying this system? For example, we have a bunch | 26 // there some way of simplifying this system? For example, we have a bunch |
26 // of inner classes that could potentially be factored out in some other way. | 27 // of inner classes that could potentially be factored out in some other way. |
27 class DartLibraryLoader { | 28 class DartLibraryLoader { |
28 public: | 29 public: |
29 explicit DartLibraryLoader(DartState* dart_state); | 30 explicit DartLibraryLoader(DartState* dart_state); |
30 ~DartLibraryLoader(); | 31 ~DartLibraryLoader(); |
31 | 32 |
32 // TODO(dart): This can be called both on the main thread from application | 33 // TODO(dart): This can be called both on the main thread from application |
33 // solates or from the handle watcher isolate thread. | 34 // solates or from the handle watcher isolate thread. |
34 static Dart_Handle HandleLibraryTag(Dart_LibraryTag tag, | 35 static Dart_Handle HandleLibraryTag(Dart_LibraryTag tag, |
35 Dart_Handle library, | 36 Dart_Handle library, |
36 Dart_Handle url); | 37 Dart_Handle url); |
37 | 38 |
38 void LoadLibrary(const String& name); | 39 void LoadLibrary(const std::string& name); |
39 | 40 |
40 void WaitForDependencies(const HashSet<DartDependency*>& dependencies, | 41 void WaitForDependencies(const HashSet<DartDependency*>& dependencies, |
41 const base::Closure& callback); | 42 const base::Closure& callback); |
42 | 43 |
43 void set_dependency_catcher(DartDependencyCatcher* dependency_catcher) { | 44 void set_dependency_catcher(DartDependencyCatcher* dependency_catcher) { |
44 DCHECK(!dependency_catcher_ || !dependency_catcher); | 45 DCHECK(!dependency_catcher_ || !dependency_catcher); |
45 dependency_catcher_ = dependency_catcher; | 46 dependency_catcher_ = dependency_catcher; |
46 } | 47 } |
47 | 48 |
48 DartState* dart_state() const { return dart_state_; } | 49 DartState* dart_state() const { return dart_state_; } |
(...skipping 14 matching lines...) Expand all Loading... |
63 | 64 |
64 Dart_Handle Import(Dart_Handle library, Dart_Handle url); | 65 Dart_Handle Import(Dart_Handle library, Dart_Handle url); |
65 Dart_Handle Source(Dart_Handle library, Dart_Handle url); | 66 Dart_Handle Source(Dart_Handle library, Dart_Handle url); |
66 Dart_Handle CanonicalizeURL(Dart_Handle library, Dart_Handle url); | 67 Dart_Handle CanonicalizeURL(Dart_Handle library, Dart_Handle url); |
67 void DidCompleteImportJob(ImportJob* job, const std::vector<uint8_t>& buffer); | 68 void DidCompleteImportJob(ImportJob* job, const std::vector<uint8_t>& buffer); |
68 void DidCompleteSourceJob(SourceJob* job, const std::vector<uint8_t>& buffer); | 69 void DidCompleteSourceJob(SourceJob* job, const std::vector<uint8_t>& buffer); |
69 void DidFailJob(Job* job); | 70 void DidFailJob(Job* job); |
70 | 71 |
71 DartState* dart_state_; | 72 DartState* dart_state_; |
72 DartLibraryProvider* library_provider_; | 73 DartLibraryProvider* library_provider_; |
73 HashMap<String, Job*> pending_libraries_; | 74 std::unordered_map<std::string, Job*> pending_libraries_; |
74 HashSet<OwnPtr<Job>> jobs_; | 75 HashSet<OwnPtr<Job>> jobs_; |
75 HashSet<OwnPtr<DependencyWatcher>> dependency_watchers_; | 76 HashSet<OwnPtr<DependencyWatcher>> dependency_watchers_; |
76 DartDependencyCatcher* dependency_catcher_; | 77 DartDependencyCatcher* dependency_catcher_; |
77 | 78 |
78 DISALLOW_COPY_AND_ASSIGN(DartLibraryLoader); | 79 DISALLOW_COPY_AND_ASSIGN(DartLibraryLoader); |
79 }; | 80 }; |
80 | 81 |
81 } // namespace blink | 82 } // namespace blink |
82 | 83 |
83 #endif // SKY_ENGINE_TONIC_DART_LIBRARY_LOADER_H_ | 84 #endif // SKY_ENGINE_TONIC_DART_LIBRARY_LOADER_H_ |
OLD | NEW |