OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "native_client/src/shared/ppapi_proxy/plugin_ppb_testing.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_testing.h" |
6 | 6 |
| 7 #include <cstddef> |
| 8 #include <new> |
| 9 |
7 #include "native_client/src/include/nacl_scoped_ptr.h" | 10 #include "native_client/src/include/nacl_scoped_ptr.h" |
8 #include "native_client/src/include/portability.h" | 11 #include "native_client/src/include/portability.h" |
9 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" | 12 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" |
10 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" | 13 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" |
11 #include "native_client/src/shared/ppapi_proxy/plugin_callback.h" | 14 #include "native_client/src/shared/ppapi_proxy/plugin_callback.h" |
12 #include "native_client/src/shared/ppapi_proxy/utility.h" | 15 #include "native_client/src/shared/ppapi_proxy/utility.h" |
13 #include "ppapi/c/dev/ppb_testing_dev.h" | 16 #include "ppapi/c/dev/ppb_testing_dev.h" |
14 #include "ppapi/c/pp_completion_callback.h" | 17 #include "ppapi/c/pp_completion_callback.h" |
15 #include "ppapi/c/pp_errors.h" | 18 #include "ppapi/c/pp_errors.h" |
16 #include "ppapi/c/pp_point.h" | 19 #include "ppapi/c/pp_point.h" |
17 #include "ppapi/c/pp_rect.h" | 20 #include "ppapi/c/pp_rect.h" |
18 #include "srpcgen/ppb_rpc.h" | 21 #include "srpcgen/ppb_rpc.h" |
19 | 22 |
20 namespace ppapi_proxy { | 23 namespace ppapi_proxy { |
21 | 24 |
22 namespace { | 25 namespace { |
23 | 26 |
24 const nacl_abi_size_t kPPPointBytes = | 27 const nacl_abi_size_t kPPPointBytes = |
25 static_cast<nacl_abi_size_t>(sizeof(struct PP_Point)); | 28 static_cast<nacl_abi_size_t>(sizeof(struct PP_Point)); |
| 29 const nacl_abi_size_t kPPURLComponentsDevBytes = |
| 30 static_cast<nacl_abi_size_t>(sizeof(struct PP_URLComponents_Dev)); |
26 | 31 |
27 PP_Bool ReadImageData(PP_Resource device_context_2d, | 32 PP_Bool ReadImageData(PP_Resource device_context_2d, |
28 PP_Resource image, | 33 PP_Resource image, |
29 const struct PP_Point* top_left) { | 34 const struct PP_Point* top_left) { |
30 DebugPrintf("PPB_Testing::ReadImageData: device_context_2d=%"NACL_PRIu32"\n", | 35 DebugPrintf("PPB_Testing::ReadImageData: device_context_2d=%"NACL_PRIu32"\n", |
31 device_context_2d); | 36 device_context_2d); |
32 | 37 |
33 int32_t success = 0; | 38 int32_t success = 0; |
34 NaClSrpcError srpc_result = | 39 NaClSrpcError srpc_result = |
35 PpbTestingRpcClient::PPB_Testing_ReadImageData( | 40 PpbTestingRpcClient::PPB_Testing_ReadImageData( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 95 } |
91 | 96 |
92 PP_Bool IsOutOfProcess() { | 97 PP_Bool IsOutOfProcess() { |
93 // The NaCl plugin is run in-process, and all calls are synchronous, so even | 98 // The NaCl plugin is run in-process, and all calls are synchronous, so even |
94 // though a NaCl module runs in a separate process, it behaves as if it were | 99 // though a NaCl module runs in a separate process, it behaves as if it were |
95 // in-process. Furthermore, calls off of the main thread are not supported | 100 // in-process. Furthermore, calls off of the main thread are not supported |
96 // (same as trusted in-process). | 101 // (same as trusted in-process). |
97 return PP_FALSE; | 102 return PP_FALSE; |
98 } | 103 } |
99 | 104 |
| 105 struct PP_Var GetDocumentURL(PP_Instance instance, |
| 106 struct PP_URLComponents_Dev* components) { |
| 107 DebugPrintf("PPB_Testing::GetDocumentURL: " |
| 108 "instance=%"NACL_PRIu32"\n", instance); |
| 109 |
| 110 NaClSrpcChannel* channel = GetMainSrpcChannel(); |
| 111 nacl_abi_size_t components_size = kPPURLComponentsDevBytes; |
| 112 nacl_abi_size_t url_size = kMaxVarSize; |
| 113 nacl::scoped_array<char> url_bytes(new (std::nothrow) char[url_size]); |
| 114 if (url_bytes.get() == NULL) |
| 115 return PP_MakeUndefined(); |
| 116 |
| 117 NaClSrpcError srpc_result = |
| 118 PpbTestingRpcClient::PPB_Testing_GetDocumentURL( |
| 119 channel, |
| 120 instance, |
| 121 &components_size, reinterpret_cast<char*>(components), |
| 122 &url_size, url_bytes.get()); |
| 123 |
| 124 struct PP_Var url = PP_MakeUndefined(); |
| 125 if (srpc_result == NACL_SRPC_RESULT_OK) |
| 126 (void) DeserializeTo(url_bytes.get(), url_size, 1, &url); |
| 127 |
| 128 DebugPrintf("PPB_Testing::GetDocumentURL: %s\n", |
| 129 NaClSrpcErrorString(srpc_result)); |
| 130 |
| 131 return url; |
| 132 } |
| 133 |
100 } // namespace | 134 } // namespace |
101 | 135 |
102 const PPB_Testing_Dev* PluginTesting::GetInterface() { | 136 const PPB_Testing_Dev* PluginTesting::GetInterface() { |
103 static const PPB_Testing_Dev testing_interface = { | 137 static const PPB_Testing_Dev testing_interface = { |
104 ReadImageData, | 138 ReadImageData, |
105 RunMessageLoop, | 139 RunMessageLoop, |
106 QuitMessageLoop, | 140 QuitMessageLoop, |
107 GetLiveObjectsForInstance, | 141 GetLiveObjectsForInstance, |
108 IsOutOfProcess | 142 IsOutOfProcess, |
| 143 NULL, |
| 144 GetDocumentURL |
109 }; | 145 }; |
110 return &testing_interface; | 146 return &testing_interface; |
111 } | 147 } |
112 | 148 |
113 } // namespace ppapi_proxy | 149 } // namespace ppapi_proxy |
OLD | NEW |