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_ = | 37 port_ = Dart_NewNativePort("Loader", Loader::NativeMessageHandler, false); |
38 Dart_NewNativePort("Loader", Loader::NativeMessageHandler, false, this); | |
39 isolate_data_->set_loader(this); | 38 isolate_data_->set_loader(this); |
40 AddLoader(port_, isolate_data_); | 39 AddLoader(port_, isolate_data_); |
41 } | 40 } |
42 | 41 |
43 | 42 |
44 Loader::~Loader() { | 43 Loader::~Loader() { |
45 ASSERT(port_ != ILLEGAL_PORT); | 44 ASSERT(port_ != ILLEGAL_PORT); |
46 // Enter the monitor while we close the Dart port. After the Dart port is | 45 // Enter the monitor while we close the Dart port. After the Dart port is |
47 // closed, no more results can be queued. | 46 // closed, no more results can be queued. |
48 monitor_->Enter(); | 47 monitor_->Enter(); |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 } | 810 } |
812 | 811 |
813 | 812 |
814 Loader* Loader::LoaderFor(Dart_Port port) { | 813 Loader* Loader::LoaderFor(Dart_Port port) { |
815 MutexLocker ml(loader_infos_lock_); | 814 MutexLocker ml(loader_infos_lock_); |
816 return LoaderForLocked(port); | 815 return LoaderForLocked(port); |
817 } | 816 } |
818 | 817 |
819 | 818 |
820 void Loader::NativeMessageHandler(Dart_Port dest_port_id, | 819 void Loader::NativeMessageHandler(Dart_Port dest_port_id, |
821 Dart_CObject* message, | 820 Dart_CObject* message) { |
822 void* peer) { | |
823 MutexLocker ml(loader_infos_lock_); | 821 MutexLocker ml(loader_infos_lock_); |
824 static_cast<Loader*>(peer)->QueueMessage(message); | 822 Loader* loader = LoaderForLocked(dest_port_id); |
| 823 if (loader == NULL) { |
| 824 return; |
| 825 } |
| 826 loader->QueueMessage(message); |
825 } | 827 } |
826 | 828 |
827 } // namespace bin | 829 } // namespace bin |
828 } // namespace dart | 830 } // namespace dart |
OLD | NEW |