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 "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
6 #include "sky/engine/bindings/mojo_natives.h" | 6 #include "sky/engine/bindings/mojo_natives.h" |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <vector> | 10 #include <vector> |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 int64_t data; | 709 int64_t data; |
710 }; | 710 }; |
711 | 711 |
712 void MojoHandleWatcher_SendControlData(Dart_NativeArguments arguments) { | 712 void MojoHandleWatcher_SendControlData(Dart_NativeArguments arguments) { |
713 int64_t control_handle = 0; | 713 int64_t control_handle = 0; |
714 int64_t client_handle = 0; | 714 int64_t client_handle = 0; |
715 CHECK_INTEGER_ARGUMENT(arguments, 0, &control_handle, InvalidArgument); | 715 CHECK_INTEGER_ARGUMENT(arguments, 0, &control_handle, InvalidArgument); |
716 CHECK_INTEGER_ARGUMENT(arguments, 1, &client_handle, InvalidArgument); | 716 CHECK_INTEGER_ARGUMENT(arguments, 1, &client_handle, InvalidArgument); |
717 | 717 |
718 Dart_Handle send_port_handle = Dart_GetNativeArgument(arguments, 2); | 718 Dart_Handle send_port_handle = Dart_GetNativeArgument(arguments, 2); |
719 Dart_Port send_port_id = 0; | 719 Dart_Port send_port_id = ILLEGAL_PORT; |
720 if (!Dart_IsNull(send_port_handle)) { | 720 if (!Dart_IsNull(send_port_handle)) { |
721 Dart_Handle result = Dart_SendPortGetId(send_port_handle, &send_port_id); | 721 Dart_Handle result = Dart_SendPortGetId(send_port_handle, &send_port_id); |
722 if (Dart_IsError(result)) { | 722 if (Dart_IsError(result)) { |
723 SetInvalidArgumentReturn(arguments); | 723 SetInvalidArgumentReturn(arguments); |
724 return; | 724 return; |
725 } | 725 } |
726 } | 726 } |
727 | 727 |
728 int64_t data = 0; | 728 int64_t data = 0; |
729 CHECK_INTEGER_ARGUMENT(arguments, 3, &data, InvalidArgument); | 729 CHECK_INTEGER_ARGUMENT(arguments, 3, &data, InvalidArgument); |
(...skipping 18 matching lines...) Expand all Loading... |
748 uint32_t num_handles = 0; | 748 uint32_t num_handles = 0; |
749 MojoResult res = MojoReadMessage( | 749 MojoResult res = MojoReadMessage( |
750 control_handle, bytes, &num_bytes, nullptr, &num_handles, 0); | 750 control_handle, bytes, &num_bytes, nullptr, &num_handles, 0); |
751 if (res != MOJO_RESULT_OK) { | 751 if (res != MOJO_RESULT_OK) { |
752 SetNullReturn(arguments); | 752 SetNullReturn(arguments); |
753 return; | 753 return; |
754 } | 754 } |
755 | 755 |
756 Dart_Handle list = Dart_NewList(3); | 756 Dart_Handle list = Dart_NewList(3); |
757 Dart_ListSetAt(list, 0, Dart_NewInteger(cd.handle)); | 757 Dart_ListSetAt(list, 0, Dart_NewInteger(cd.handle)); |
758 Dart_ListSetAt(list, 1, Dart_NewSendPort(cd.port)); | 758 if (cd.port != ILLEGAL_PORT) { |
| 759 Dart_ListSetAt(list, 1, Dart_NewSendPort(cd.port)); |
| 760 } |
759 Dart_ListSetAt(list, 2, Dart_NewInteger(cd.data)); | 761 Dart_ListSetAt(list, 2, Dart_NewInteger(cd.data)); |
760 Dart_SetReturnValue(arguments, list); | 762 Dart_SetReturnValue(arguments, list); |
761 } | 763 } |
762 | 764 |
763 static int64_t mojo_control_handle = MOJO_HANDLE_INVALID; | 765 static int64_t mojo_control_handle = MOJO_HANDLE_INVALID; |
764 void MojoHandleWatcher_SetControlHandle(Dart_NativeArguments arguments) { | 766 void MojoHandleWatcher_SetControlHandle(Dart_NativeArguments arguments) { |
765 int64_t control_handle; | 767 int64_t control_handle; |
766 CHECK_INTEGER_ARGUMENT(arguments, 0, &control_handle, InvalidArgument); | 768 CHECK_INTEGER_ARGUMENT(arguments, 0, &control_handle, InvalidArgument); |
767 mojo_control_handle = control_handle; | 769 mojo_control_handle = control_handle; |
768 Dart_SetIntegerReturnValue(arguments, static_cast<int64_t>(MOJO_RESULT_OK)); | 770 Dart_SetIntegerReturnValue(arguments, static_cast<int64_t>(MOJO_RESULT_OK)); |
769 } | 771 } |
770 | 772 |
771 void MojoHandleWatcher_GetControlHandle(Dart_NativeArguments arguments) { | 773 void MojoHandleWatcher_GetControlHandle(Dart_NativeArguments arguments) { |
772 Dart_SetIntegerReturnValue(arguments, mojo_control_handle); | 774 Dart_SetIntegerReturnValue(arguments, mojo_control_handle); |
773 } | 775 } |
774 | 776 |
775 } // namespace blink | 777 } // namespace blink |
OLD | NEW |