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: runtime/bin/loader.cc

Issue 2285223003: Fix native extension lookup (Closed)
Patch Set: Add back test for '/' Created 4 years, 3 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 (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 5
6 #include "bin/loader.h" 6 #include "bin/loader.h"
7 7
8 #include "bin/builtin.h" 8 #include "bin/builtin.h"
9 #include "bin/dartutils.h" 9 #include "bin/dartutils.h"
10 #include "bin/extensions.h" 10 #include "bin/extensions.h"
11 #include "bin/file.h"
11 #include "bin/lockers.h" 12 #include "bin/lockers.h"
12 #include "bin/utils.h" 13 #include "bin/utils.h"
13 14
14 namespace dart { 15 namespace dart {
15 namespace bin { 16 namespace bin {
16 17
17 // Development flag. 18 // Development flag.
18 static bool trace_loader = false; 19 static bool trace_loader = false;
19 // Keep in sync with loader.dart. 20 // Keep in sync with loader.dart.
20 static const intptr_t _Dart_kImportExtension = 9; 21 static const intptr_t _Dart_kImportExtension = 9;
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 Dart_Handle res = Dart_LibraryHandleError(library, error); 255 Dart_Handle res = Dart_LibraryHandleError(library, error);
255 if (Dart_IsNull(res)) { 256 if (Dart_IsNull(res)) {
256 // Error was handled by library. 257 // Error was handled by library.
257 return true; 258 return true;
258 } 259 }
259 } 260 }
260 return false; 261 return false;
261 } 262 }
262 263
263 264
264 static bool IsWindowsHost() {
265 #if defined(TARGET_OS_WINDOWS)
266 return true;
267 #else // defined(TARGET_OS_WINDOWS)
268 return false;
269 #endif // defined(TARGET_OS_WINDOWS)
270 }
271
272
273 bool Loader::ProcessResultLocked(Loader* loader, Loader::IOResult* result) { 265 bool Loader::ProcessResultLocked(Loader* loader, Loader::IOResult* result) {
274 // We have to copy everything we care about out of |result| because after 266 // We have to copy everything we care about out of |result| because after
275 // dropping the lock below |result| may no longer valid. 267 // dropping the lock below |result| may no longer valid.
276 Dart_Handle uri = 268 Dart_Handle uri =
277 Dart_NewStringFromCString(reinterpret_cast<char*>(result->uri)); 269 Dart_NewStringFromCString(reinterpret_cast<char*>(result->uri));
278 Dart_Handle resolved_uri = 270 Dart_Handle resolved_uri =
279 Dart_NewStringFromCString(reinterpret_cast<char*>(result->resolved_uri)); 271 Dart_NewStringFromCString(reinterpret_cast<char*>(result->resolved_uri));
280 Dart_Handle library_uri = Dart_Null(); 272 Dart_Handle library_uri = Dart_Null();
281 if (result->library_uri != NULL) { 273 if (result->library_uri != NULL) {
282 library_uri = 274 library_uri =
(...skipping 30 matching lines...) Expand all
313 return false; 305 return false;
314 } 306 }
315 const char* extension_uri = reinterpret_cast<const char*>(result->uri); 307 const char* extension_uri = reinterpret_cast<const char*>(result->uri);
316 const char* lib_path = NULL; 308 const char* lib_path = NULL;
317 if (strncmp(lib_uri, "file://", 7) == 0) { 309 if (strncmp(lib_uri, "file://", 7) == 0) {
318 lib_path = DartUtils::RemoveScheme(lib_uri); 310 lib_path = DartUtils::RemoveScheme(lib_uri);
319 } else { 311 } else {
320 lib_path = lib_uri; 312 lib_path = lib_uri;
321 } 313 }
322 const char* extension_path = DartUtils::RemoveScheme(extension_uri); 314 const char* extension_path = DartUtils::RemoveScheme(extension_uri);
323 if (strchr(extension_path, '/') != NULL || 315 if (!File::IsAbsolutePath(extension_path) &&
324 (IsWindowsHost() && strchr(extension_path, '\\') != NULL)) { 316 ((strchr(extension_path, '/') != NULL) ||
317 (strstr(extension_path, File::PathSeparator()) != NULL))) {
siva 2016/08/30 01:22:59 For non windows hosts looks like this check is rep
zra 2016/08/30 16:05:18 Avoided the duplicate test by checking the path se
325 loader->error_ = DartUtils::NewError( 318 loader->error_ = DartUtils::NewError(
326 "Relative paths for dart extensions are not supported: '%s'", 319 "Relative paths for dart extensions are not supported: '%s'",
327 extension_path); 320 extension_path);
328 return false; 321 return false;
329 } 322 }
330 Dart_Handle result = Extensions::LoadExtension(lib_path, 323 Dart_Handle result = Extensions::LoadExtension(lib_path,
331 extension_path, 324 extension_path,
332 library); 325 library);
333 if (Dart_IsError(result)) { 326 if (Dart_IsError(result)) {
334 loader->error_ = result; 327 loader->error_ = result;
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 MutexLocker ml(loader_infos_lock_); 750 MutexLocker ml(loader_infos_lock_);
758 Loader* loader = LoaderForLocked(dest_port_id); 751 Loader* loader = LoaderForLocked(dest_port_id);
759 if (loader == NULL) { 752 if (loader == NULL) {
760 return; 753 return;
761 } 754 }
762 loader->QueueMessage(message); 755 loader->QueueMessage(message);
763 } 756 }
764 757
765 } // namespace bin 758 } // namespace bin
766 } // namespace dart 759 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/extensions.cc ('k') | runtime/bin/utils.h » ('j') | runtime/bin/utils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698