Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 break; | 206 break; |
| 207 } | 207 } |
| 208 | 208 |
| 209 // Wait to be notified about new I/O results. | 209 // Wait to be notified about new I/O results. |
| 210 ml.Wait(); | 210 ml.Wait(); |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 | 214 |
| 215 bool Loader::ProcessResultLocked(Loader::IOResult* result) { | 215 bool Loader::ProcessResultLocked(Loader::IOResult* result) { |
| 216 // A negative result tag indicates a loading error occurred in the service | |
| 217 // isolate. The payload is a C string of the error message. | |
| 218 if (result->tag < 0) { | |
| 219 error_ = | |
| 220 Dart_NewUnhandledExceptionError( | |
| 221 Dart_NewStringFromUTF8(result->payload, | |
| 222 result->payload_length)); | |
| 223 | |
| 224 return false; | |
| 225 } | |
| 226 | |
| 227 // We have to copy everything we care about out of |result| because after | 216 // We have to copy everything we care about out of |result| because after |
| 228 // dropping the lock below |result| may no longer valid. | 217 // dropping the lock below |result| may no longer valid. |
| 229 Dart_Handle uri = | 218 Dart_Handle uri = |
| 230 Dart_NewStringFromCString(reinterpret_cast<char*>(result->uri)); | 219 Dart_NewStringFromCString(reinterpret_cast<char*>(result->uri)); |
| 231 Dart_Handle library_uri = Dart_Null(); | 220 Dart_Handle library_uri = Dart_Null(); |
| 232 if (result->library_uri != NULL) { | 221 if (result->library_uri != NULL) { |
| 233 library_uri = | 222 library_uri = |
| 234 Dart_NewStringFromCString(reinterpret_cast<char*>(result->library_uri)); | 223 Dart_NewStringFromCString(reinterpret_cast<char*>(result->library_uri)); |
| 235 } | 224 } |
| 225 | |
| 226 // A negative result tag indicates a loading error occurred in the service | |
| 227 // isolate. The payload is a C string of the error message. | |
| 228 if (result->tag < 0) { | |
| 229 Dart_Handle library = Dart_LookupLibrary(uri); | |
| 230 Dart_Handle error = Dart_NewStringFromUTF8(result->payload, | |
| 231 result->payload_length); | |
| 232 // If a library with the given uri exists, give it a chance to handle | |
| 233 // the error. If the load requests stems from a deferred library load, | |
| 234 // an IO error is not fatal. | |
| 235 if ((library != Dart_Null()) && !Dart_IsError(library)) { | |
|
hausner
2016/06/07 21:47:05
Is there a difference between x != Dart_Null() and
Cutch
2016/06/07 22:29:26
No difference, but I switched to Dart_IsNull().
| |
| 236 ASSERT(Dart_IsLibrary(library)); | |
| 237 Dart_Handle res = Dart_LibraryHandleError(library, error); | |
| 238 if (Dart_IsNull(res)) { | |
| 239 return true; | |
| 240 } | |
| 241 } | |
| 242 // Fall through | |
| 243 error_ = Dart_NewUnhandledExceptionError(error); | |
| 244 return false; | |
| 245 } | |
| 246 | |
| 247 | |
| 236 // Check for payload and load accordingly. | 248 // Check for payload and load accordingly. |
| 237 bool is_snapshot = false; | 249 bool is_snapshot = false; |
| 238 const uint8_t* payload = result->payload; | 250 const uint8_t* payload = result->payload; |
| 239 intptr_t payload_length = result->payload_length; | 251 intptr_t payload_length = result->payload_length; |
| 240 payload = | 252 payload = |
| 241 DartUtils::SniffForMagicNumber(payload, | 253 DartUtils::SniffForMagicNumber(payload, |
| 242 &payload_length, | 254 &payload_length, |
| 243 &is_snapshot); | 255 &is_snapshot); |
| 244 Dart_Handle source = Dart_Null(); | 256 Dart_Handle source = Dart_Null(); |
| 245 if (!is_snapshot) { | 257 if (!is_snapshot) { |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 576 MutexLocker ml(&loader_infos_lock_); | 588 MutexLocker ml(&loader_infos_lock_); |
| 577 Loader* loader = LoaderForLocked(dest_port_id); | 589 Loader* loader = LoaderForLocked(dest_port_id); |
| 578 if (loader == NULL) { | 590 if (loader == NULL) { |
| 579 return; | 591 return; |
| 580 } | 592 } |
| 581 loader->QueueMessage(message); | 593 loader->QueueMessage(message); |
| 582 } | 594 } |
| 583 | 595 |
| 584 } // namespace bin | 596 } // namespace bin |
| 585 } // namespace dart | 597 } // namespace dart |
| OLD | NEW |