| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdio.h> | 5 #include <stdio.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 int64_t data; | 722 int64_t data; |
| 723 }; | 723 }; |
| 724 | 724 |
| 725 void MojoHandleWatcher_SendControlData(Dart_NativeArguments arguments) { | 725 void MojoHandleWatcher_SendControlData(Dart_NativeArguments arguments) { |
| 726 int64_t control_handle = 0; | 726 int64_t control_handle = 0; |
| 727 int64_t client_handle = 0; | 727 int64_t client_handle = 0; |
| 728 CHECK_INTEGER_ARGUMENT(arguments, 0, &control_handle, InvalidArgument); | 728 CHECK_INTEGER_ARGUMENT(arguments, 0, &control_handle, InvalidArgument); |
| 729 CHECK_INTEGER_ARGUMENT(arguments, 1, &client_handle, InvalidArgument); | 729 CHECK_INTEGER_ARGUMENT(arguments, 1, &client_handle, InvalidArgument); |
| 730 | 730 |
| 731 Dart_Handle send_port_handle = Dart_GetNativeArgument(arguments, 2); | 731 Dart_Handle send_port_handle = Dart_GetNativeArgument(arguments, 2); |
| 732 Dart_Port send_port_id = 0; | 732 Dart_Port send_port_id = ILLEGAL_PORT; |
| 733 if (!Dart_IsNull(send_port_handle)) { | 733 if (!Dart_IsNull(send_port_handle)) { |
| 734 Dart_Handle result = Dart_SendPortGetId(send_port_handle, &send_port_id); | 734 Dart_Handle result = Dart_SendPortGetId(send_port_handle, &send_port_id); |
| 735 if (Dart_IsError(result)) { | 735 if (Dart_IsError(result)) { |
| 736 SetInvalidArgumentReturn(arguments); | 736 SetInvalidArgumentReturn(arguments); |
| 737 return; | 737 return; |
| 738 } | 738 } |
| 739 } | 739 } |
| 740 | 740 |
| 741 int64_t data = 0; | 741 int64_t data = 0; |
| 742 CHECK_INTEGER_ARGUMENT(arguments, 3, &data, InvalidArgument); | 742 CHECK_INTEGER_ARGUMENT(arguments, 3, &data, InvalidArgument); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 761 uint32_t num_handles = 0; | 761 uint32_t num_handles = 0; |
| 762 MojoResult res = MojoReadMessage( | 762 MojoResult res = MojoReadMessage( |
| 763 control_handle, bytes, &num_bytes, nullptr, &num_handles, 0); | 763 control_handle, bytes, &num_bytes, nullptr, &num_handles, 0); |
| 764 if (res != MOJO_RESULT_OK) { | 764 if (res != MOJO_RESULT_OK) { |
| 765 SetNullReturn(arguments); | 765 SetNullReturn(arguments); |
| 766 return; | 766 return; |
| 767 } | 767 } |
| 768 | 768 |
| 769 Dart_Handle list = Dart_NewList(3); | 769 Dart_Handle list = Dart_NewList(3); |
| 770 Dart_ListSetAt(list, 0, Dart_NewInteger(cd.handle)); | 770 Dart_ListSetAt(list, 0, Dart_NewInteger(cd.handle)); |
| 771 Dart_ListSetAt(list, 1, Dart_NewSendPort(cd.port)); | 771 if (cd.port != ILLEGAL_PORT) { |
| 772 Dart_ListSetAt(list, 1, Dart_NewSendPort(cd.port)); |
| 773 } |
| 772 Dart_ListSetAt(list, 2, Dart_NewInteger(cd.data)); | 774 Dart_ListSetAt(list, 2, Dart_NewInteger(cd.data)); |
| 773 Dart_SetReturnValue(arguments, list); | 775 Dart_SetReturnValue(arguments, list); |
| 774 } | 776 } |
| 775 | 777 |
| 776 static int64_t mojo_control_handle = MOJO_HANDLE_INVALID; | 778 static int64_t mojo_control_handle = MOJO_HANDLE_INVALID; |
| 777 void MojoHandleWatcher_SetControlHandle(Dart_NativeArguments arguments) { | 779 void MojoHandleWatcher_SetControlHandle(Dart_NativeArguments arguments) { |
| 778 int64_t control_handle; | 780 int64_t control_handle; |
| 779 CHECK_INTEGER_ARGUMENT(arguments, 0, &control_handle, InvalidArgument); | 781 CHECK_INTEGER_ARGUMENT(arguments, 0, &control_handle, InvalidArgument); |
| 780 mojo_control_handle = control_handle; | 782 mojo_control_handle = control_handle; |
| 781 Dart_SetIntegerReturnValue(arguments, static_cast<int64_t>(MOJO_RESULT_OK)); | 783 Dart_SetIntegerReturnValue(arguments, static_cast<int64_t>(MOJO_RESULT_OK)); |
| 782 } | 784 } |
| 783 | 785 |
| 784 void MojoHandleWatcher_GetControlHandle(Dart_NativeArguments arguments) { | 786 void MojoHandleWatcher_GetControlHandle(Dart_NativeArguments arguments) { |
| 785 Dart_SetIntegerReturnValue(arguments, mojo_control_handle); | 787 Dart_SetIntegerReturnValue(arguments, mojo_control_handle); |
| 786 } | 788 } |
| 787 | 789 |
| 788 } // namespace dart | 790 } // namespace dart |
| 789 } // namespace mojo | 791 } // namespace mojo |
| OLD | NEW |