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 762 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 |