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 16 matching lines...) Expand all Loading... | |
| 27 error_(Dart_Null()), | 27 error_(Dart_Null()), |
| 28 monitor_(NULL), | 28 monitor_(NULL), |
| 29 pending_operations_(0), | 29 pending_operations_(0), |
| 30 results_(NULL), | 30 results_(NULL), |
| 31 results_length_(0), | 31 results_length_(0), |
| 32 results_capacity_(0), | 32 results_capacity_(0), |
| 33 payload_(NULL), | 33 payload_(NULL), |
| 34 payload_length_(0) { | 34 payload_length_(0) { |
| 35 monitor_ = new Monitor(); | 35 monitor_ = new Monitor(); |
| 36 ASSERT(isolate_data_ != NULL); | 36 ASSERT(isolate_data_ != NULL); |
| 37 port_ = Dart_NewNativePort("Loader", Loader::NativeMessageHandler, false); | 37 port_ = |
| 38 Dart_NewNativePort("Loader", Loader::NativeMessageHandler, false, this); | |
| 38 isolate_data_->set_loader(this); | 39 isolate_data_->set_loader(this); |
| 39 AddLoader(port_, isolate_data_); | 40 AddLoader(port_, isolate_data_); |
| 40 } | 41 } |
| 41 | 42 |
| 42 | 43 |
| 43 Loader::~Loader() { | 44 Loader::~Loader() { |
| 44 ASSERT(port_ != ILLEGAL_PORT); | 45 ASSERT(port_ != ILLEGAL_PORT); |
| 45 // Enter the monitor while we close the Dart port. After the Dart port is | 46 // Enter the monitor while we close the Dart port. After the Dart port is |
| 46 // closed, no more results can be queued. | 47 // closed, no more results can be queued. |
| 47 monitor_->Enter(); | 48 monitor_->Enter(); |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 637 // Use the existing loader. | 638 // Use the existing loader. |
| 638 loader = isolate_data->loader(); | 639 loader = isolate_data->loader(); |
| 639 } | 640 } |
| 640 ASSERT(loader != NULL); | 641 ASSERT(loader != NULL); |
| 641 ASSERT(isolate_data->HasLoader()); | 642 ASSERT(isolate_data->HasLoader()); |
| 642 | 643 |
| 643 if (DartUtils::IsDartExtensionSchemeURL(url_string)) { | 644 if (DartUtils::IsDartExtensionSchemeURL(url_string)) { |
| 644 loader->SendImportExtensionRequest(url, Dart_LibraryUrl(library)); | 645 loader->SendImportExtensionRequest(url, Dart_LibraryUrl(library)); |
| 645 } else { | 646 } else { |
| 646 if (Dart_KernelIsolateIsRunning()) { | 647 if (Dart_KernelIsolateIsRunning()) { |
| 647 loader->SendKernelRequest(tag, url); | 648 loader->SendKernelRequest(tag, url); |
|
hausner
2017/01/24 00:50:55
Is this code path still used? It seems to me that
Vyacheslav Egorov (Google)
2017/01/30 19:34:12
This code path will be used again when we start do
| |
| 648 } else { | 649 } else { |
| 649 loader->SendRequest(tag, url, (library != Dart_Null()) | 650 loader->SendRequest(tag, url, (library != Dart_Null()) |
| 650 ? Dart_LibraryUrl(library) | 651 ? Dart_LibraryUrl(library) |
| 651 : Dart_Null()); | 652 : Dart_Null()); |
| 652 } | 653 } |
| 653 } | 654 } |
| 654 | 655 |
| 655 if (blocking_call) { | 656 if (blocking_call) { |
| 656 // The outer invocation of the tag handler will block here until all nested | 657 // The outer invocation of the tag handler will block here until all nested |
| 657 // invocations complete. | 658 // invocations complete. |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 810 } | 811 } |
| 811 | 812 |
| 812 | 813 |
| 813 Loader* Loader::LoaderFor(Dart_Port port) { | 814 Loader* Loader::LoaderFor(Dart_Port port) { |
| 814 MutexLocker ml(loader_infos_lock_); | 815 MutexLocker ml(loader_infos_lock_); |
| 815 return LoaderForLocked(port); | 816 return LoaderForLocked(port); |
| 816 } | 817 } |
| 817 | 818 |
| 818 | 819 |
| 819 void Loader::NativeMessageHandler(Dart_Port dest_port_id, | 820 void Loader::NativeMessageHandler(Dart_Port dest_port_id, |
| 820 Dart_CObject* message) { | 821 Dart_CObject* message, |
| 822 void* peer) { | |
| 821 MutexLocker ml(loader_infos_lock_); | 823 MutexLocker ml(loader_infos_lock_); |
| 822 Loader* loader = LoaderForLocked(dest_port_id); | 824 static_cast<Loader*>(peer)->QueueMessage(message); |
| 823 if (loader == NULL) { | |
| 824 return; | |
| 825 } | |
| 826 loader->QueueMessage(message); | |
| 827 } | 825 } |
| 828 | 826 |
| 829 } // namespace bin | 827 } // namespace bin |
| 830 } // namespace dart | 828 } // namespace dart |
| OLD | NEW |