Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: sky/engine/tonic/dart_library_loader.h

Issue 1241583003: Remove all remaining HashMap and HashSet usages except dart_string_cache (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory>
8 #include <string> 9 #include <string>
9 #include <unordered_map> 10 #include <unordered_map>
11 #include <unordered_set>
10 #include <vector> 12 #include <vector>
11 13
12 #include "base/callback_forward.h" 14 #include "base/callback_forward.h"
13 #include "base/macros.h" 15 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
15 #include "dart/runtime/include/dart_api.h" 17 #include "dart/runtime/include/dart_api.h"
16 #include "sky/engine/wtf/HashSet.h"
17 #include "sky/engine/wtf/OwnPtr.h" 18 #include "sky/engine/wtf/OwnPtr.h"
18 19
19 namespace blink { 20 namespace blink {
20 class DartDependency; 21 class DartDependency;
21 class DartDependencyCatcher; 22 class DartDependencyCatcher;
22 class DartLibraryProvider; 23 class DartLibraryProvider;
23 class DartState; 24 class DartState;
24 25
25 // TODO(abarth): This class seems more complicated than it needs to be. Is 26 // TODO(abarth): This class seems more complicated than it needs to be. Is
26 // there some way of simplifying this system? For example, we have a bunch 27 // there some way of simplifying this system? For example, we have a bunch
27 // of inner classes that could potentially be factored out in some other way. 28 // of inner classes that could potentially be factored out in some other way.
28 class DartLibraryLoader { 29 class DartLibraryLoader {
29 public: 30 public:
30 explicit DartLibraryLoader(DartState* dart_state); 31 explicit DartLibraryLoader(DartState* dart_state);
31 ~DartLibraryLoader(); 32 ~DartLibraryLoader();
32 33
33 // TODO(dart): This can be called both on the main thread from application 34 // TODO(dart): This can be called both on the main thread from application
34 // solates or from the handle watcher isolate thread. 35 // solates or from the handle watcher isolate thread.
35 static Dart_Handle HandleLibraryTag(Dart_LibraryTag tag, 36 static Dart_Handle HandleLibraryTag(Dart_LibraryTag tag,
36 Dart_Handle library, 37 Dart_Handle library,
37 Dart_Handle url); 38 Dart_Handle url);
38 39
39 void LoadLibrary(const std::string& name); 40 void LoadLibrary(const std::string& name);
40 41
41 void WaitForDependencies(const HashSet<DartDependency*>& dependencies, 42 void WaitForDependencies(
42 const base::Closure& callback); 43 const std::unordered_set<DartDependency*>& dependencies,
44 const base::Closure& callback);
43 45
44 void set_dependency_catcher(DartDependencyCatcher* dependency_catcher) { 46 void set_dependency_catcher(DartDependencyCatcher* dependency_catcher) {
45 DCHECK(!dependency_catcher_ || !dependency_catcher); 47 DCHECK(!dependency_catcher_ || !dependency_catcher);
46 dependency_catcher_ = dependency_catcher; 48 dependency_catcher_ = dependency_catcher;
47 } 49 }
48 50
49 DartState* dart_state() const { return dart_state_; } 51 DartState* dart_state() const { return dart_state_; }
50 52
51 DartLibraryProvider* library_provider() const { return library_provider_; } 53 DartLibraryProvider* library_provider() const { return library_provider_; }
52 54
(...skipping 12 matching lines...) Expand all
65 Dart_Handle Import(Dart_Handle library, Dart_Handle url); 67 Dart_Handle Import(Dart_Handle library, Dart_Handle url);
66 Dart_Handle Source(Dart_Handle library, Dart_Handle url); 68 Dart_Handle Source(Dart_Handle library, Dart_Handle url);
67 Dart_Handle CanonicalizeURL(Dart_Handle library, Dart_Handle url); 69 Dart_Handle CanonicalizeURL(Dart_Handle library, Dart_Handle url);
68 void DidCompleteImportJob(ImportJob* job, const std::vector<uint8_t>& buffer); 70 void DidCompleteImportJob(ImportJob* job, const std::vector<uint8_t>& buffer);
69 void DidCompleteSourceJob(SourceJob* job, const std::vector<uint8_t>& buffer); 71 void DidCompleteSourceJob(SourceJob* job, const std::vector<uint8_t>& buffer);
70 void DidFailJob(Job* job); 72 void DidFailJob(Job* job);
71 73
72 DartState* dart_state_; 74 DartState* dart_state_;
73 DartLibraryProvider* library_provider_; 75 DartLibraryProvider* library_provider_;
74 std::unordered_map<std::string, Job*> pending_libraries_; 76 std::unordered_map<std::string, Job*> pending_libraries_;
75 HashSet<OwnPtr<Job>> jobs_; 77 std::unordered_set<std::unique_ptr<Job>> jobs_;
76 HashSet<OwnPtr<DependencyWatcher>> dependency_watchers_; 78 std::unordered_set<std::unique_ptr<DependencyWatcher>> dependency_watchers_;
77 DartDependencyCatcher* dependency_catcher_; 79 DartDependencyCatcher* dependency_catcher_;
78 80
79 DISALLOW_COPY_AND_ASSIGN(DartLibraryLoader); 81 DISALLOW_COPY_AND_ASSIGN(DartLibraryLoader);
80 }; 82 };
81 83
82 } // namespace blink 84 } // namespace blink
83 85
84 #endif // SKY_ENGINE_TONIC_DART_LIBRARY_LOADER_H_ 86 #endif // SKY_ENGINE_TONIC_DART_LIBRARY_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698