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

Side by Side Diff: tonic/dart_library_loader.h

Issue 1244493002: Wholesale move sky/engine/tonic to tonic (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
« no previous file with comments | « tonic/dart_isolate_scope.cc ('k') | tonic/dart_library_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SKY_ENGINE_TONIC_DART_LIBRARY_LOADER_H_
6 #define SKY_ENGINE_TONIC_DART_LIBRARY_LOADER_H_
7
8 #include <memory>
9 #include <string>
10 #include <unordered_map>
11 #include <unordered_set>
12 #include <vector>
13
14 #include "base/callback_forward.h"
15 #include "base/macros.h"
16 #include "base/memory/weak_ptr.h"
17 #include "dart/runtime/include/dart_api.h"
18
19 namespace blink {
20 class DartDependency;
21 class DartDependencyCatcher;
22 class DartLibraryProvider;
23 class DartState;
24
25 // 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 // of inner classes that could potentially be factored out in some other way.
28 class DartLibraryLoader {
29 public:
30 explicit DartLibraryLoader(DartState* dart_state);
31 ~DartLibraryLoader();
32
33 // TODO(dart): This can be called both on the main thread from application
34 // solates or from the handle watcher isolate thread.
35 static Dart_Handle HandleLibraryTag(Dart_LibraryTag tag,
36 Dart_Handle library,
37 Dart_Handle url);
38
39 void LoadLibrary(const std::string& name);
40
41 void WaitForDependencies(
42 const std::unordered_set<DartDependency*>& dependencies,
43 const base::Closure& callback);
44
45 void set_dependency_catcher(DartDependencyCatcher* dependency_catcher) {
46 DCHECK(!dependency_catcher_ || !dependency_catcher);
47 dependency_catcher_ = dependency_catcher;
48 }
49
50 DartState* dart_state() const { return dart_state_; }
51
52 DartLibraryProvider* library_provider() const { return library_provider_; }
53
54 // The |DartLibraryProvider| must outlive the |DartLibraryLoader|.
55 void set_library_provider(DartLibraryProvider* library_provider) {
56 library_provider_ = library_provider;
57 }
58
59 private:
60 class Job;
61 class ImportJob;
62 class SourceJob;
63 class DependencyWatcher;
64 class WatcherSignaler;
65
66 Dart_Handle Import(Dart_Handle library, Dart_Handle url);
67 Dart_Handle Source(Dart_Handle library, Dart_Handle url);
68 Dart_Handle CanonicalizeURL(Dart_Handle library, Dart_Handle url);
69 void DidCompleteImportJob(ImportJob* job, const std::vector<uint8_t>& buffer);
70 void DidCompleteSourceJob(SourceJob* job, const std::vector<uint8_t>& buffer);
71 void DidFailJob(Job* job);
72
73 DartState* dart_state_;
74 DartLibraryProvider* library_provider_;
75 std::unordered_map<std::string, Job*> pending_libraries_;
76 std::unordered_set<std::unique_ptr<Job>> jobs_;
77 std::unordered_set<std::unique_ptr<DependencyWatcher>> dependency_watchers_;
78 DartDependencyCatcher* dependency_catcher_;
79
80 DISALLOW_COPY_AND_ASSIGN(DartLibraryLoader);
81 };
82
83 } // namespace blink
84
85 #endif // SKY_ENGINE_TONIC_DART_LIBRARY_LOADER_H_
OLDNEW
« no previous file with comments | « tonic/dart_isolate_scope.cc ('k') | tonic/dart_library_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698