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

Side by Side Diff: runtime/bin/loader.h

Issue 2073173002: Use the new loader mechanism to resolve URIs and load script files in gen_snapshot. This should all… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address issues that were found while testing with the flutter engine. Created 4 years, 6 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 | « runtime/bin/gen_snapshot.cc ('k') | runtime/bin/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
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef BIN_LOADER_H_ 5 #ifndef BIN_LOADER_H_
6 #define BIN_LOADER_H_ 6 #define BIN_LOADER_H_
7 7
8 #include "bin/isolate_data.h" 8 #include "bin/isolate_data.h"
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "include/dart_native_api.h" 10 #include "include/dart_native_api.h"
11 #include "platform/assert.h" 11 #include "platform/assert.h"
12 #include "platform/globals.h" 12 #include "platform/globals.h"
13 #include "bin/thread.h" 13 #include "bin/thread.h"
14 14
15 namespace dart { 15 namespace dart {
16 namespace bin { 16 namespace bin {
17 17
18 class Loader { 18 class Loader {
19 public: 19 public:
20 explicit Loader(IsolateData* isolate_data); 20 explicit Loader(IsolateData* isolate_data);
21 ~Loader(); 21 ~Loader();
22 22
23 static void InitForSnapshot(const char* snapshot_uri); 23 static void InitForSnapshot(const char* snapshot_uri);
24 24
25 // Loads contents of the specified url.
26 static Dart_Handle LoadUrlContents(Dart_Handle url,
27 uint8_t** payload,
28 intptr_t* payload_length);
29
30
25 // A static tag handler that hides all usage of a loader for an isolate. 31 // A static tag handler that hides all usage of a loader for an isolate.
26 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, 32 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag,
27 Dart_Handle library, 33 Dart_Handle library,
28 Dart_Handle url); 34 Dart_Handle url);
29 35
30 Dart_Handle error() const { 36 Dart_Handle error() const {
31 return error_; 37 return error_;
32 } 38 }
33 39
34 private: 40 private:
(...skipping 20 matching lines...) Expand all
55 char* uri; 61 char* uri;
56 int8_t tag; 62 int8_t tag;
57 63
58 void Setup(Dart_CObject* message); 64 void Setup(Dart_CObject* message);
59 void Cleanup(); 65 void Cleanup();
60 }; 66 };
61 // An array of I/O results queued from the service isolate. 67 // An array of I/O results queued from the service isolate.
62 IOResult* results_; 68 IOResult* results_;
63 intptr_t results_length_; 69 intptr_t results_length_;
64 intptr_t results_capacity_; 70 intptr_t results_capacity_;
71 uint8_t* payload_;
72 intptr_t payload_length_;
73 typedef bool (*ProcessResult)(Loader* loader, IOResult* result);
65 74
66 intptr_t results_length() { 75 intptr_t results_length() {
67 return *static_cast<volatile intptr_t*>(&results_length_); 76 return *static_cast<volatile intptr_t*>(&results_length_);
68 } 77 }
69 78
70 // Send the loader init request to the service isolate. 79 // Send the loader init request to the service isolate.
71 void Init(const char* package_root, 80 void Init(const char* package_root,
72 const char* packages_file, 81 const char* packages_file,
73 const char* working_directory, 82 const char* working_directory,
74 const char* root_script_uri); 83 const char* root_script_uri);
75 84
76 // Send a request from the tag handler to the service isolate. 85 // Send a request from the tag handler to the service isolate.
77 void SendRequest(Dart_LibraryTag tag, 86 void SendRequest(Dart_LibraryTag tag,
78 Dart_Handle url, 87 Dart_Handle url,
79 Dart_Handle library_url); 88 Dart_Handle library_url);
80 89
81 /// Queue |message| and notify the loader that a message is available. 90 /// Queue |message| and notify the loader that a message is available.
82 void QueueMessage(Dart_CObject* message); 91 void QueueMessage(Dart_CObject* message);
83 92
84 /// Blocks the caller until the loader is finished. 93 /// Blocks the caller until the loader is finished.
85 void BlockUntilComplete(); 94 void BlockUntilComplete(ProcessResult process_result);
86 95
87 /// Returns false if |result| is an error and the loader should quit. 96 /// Returns false if |result| is an error and the loader should quit.
88 bool ProcessResultLocked(IOResult* result); 97 static bool ProcessResultLocked(Loader* loader, IOResult* result);
98
99 /// Returns false if |result| is an error and the loader should quit.
100 static bool ProcessUrlLoadResultLocked(Loader* loader, IOResult* result);
89 101
90 /// Returns false if an error occurred and the loader should quit. 102 /// Returns false if an error occurred and the loader should quit.
91 bool ProcessQueueLocked(); 103 bool ProcessQueueLocked(ProcessResult process_result);
92 104
93 // Special inner tag handler for dart: uris. 105 // Special inner tag handler for dart: uris.
94 static Dart_Handle DartColonLibraryTagHandler(Dart_LibraryTag tag, 106 static Dart_Handle DartColonLibraryTagHandler(Dart_LibraryTag tag,
95 Dart_Handle library, 107 Dart_Handle library,
96 Dart_Handle url, 108 Dart_Handle url,
97 const char* library_url_string, 109 const char* library_url_string,
98 const char* url_string); 110 const char* url_string);
99 111
100 // We use one native message handler callback for N loaders. The native 112 // We use one native message handler callback for N loaders. The native
101 // message handler callback provides us with the Dart_Port which we use as a 113 // message handler callback provides us with the Dart_Port which we use as a
(...skipping 19 matching lines...) Expand all
121 133
122 // This is the global callback for the native message handlers. 134 // This is the global callback for the native message handlers.
123 static void NativeMessageHandler(Dart_Port dest_port_id, 135 static void NativeMessageHandler(Dart_Port dest_port_id,
124 Dart_CObject* message); 136 Dart_CObject* message);
125 }; 137 };
126 138
127 } // namespace bin 139 } // namespace bin
128 } // namespace dart 140 } // namespace dart
129 141
130 #endif // BIN_LOADER_H_ 142 #endif // BIN_LOADER_H_
OLDNEW
« no previous file with comments | « runtime/bin/gen_snapshot.cc ('k') | runtime/bin/loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698