Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_testing.cc

Issue 8840007: GetDocumentURL is added to PPB_Testing_Dev. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <vector>
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
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 std::vector<char> url_bytes(url_size);
yzshen1 2011/12/13 18:49:54 It seems better to use things like nacl::scoped_ar
ygorshenin 2011/12/14 17:41:10 Done.
114 NaClSrpcError srpc_result =
115 PpbTestingRpcClient::PPB_Testing_GetDocumentURL(
116 channel,
117 instance,
118 &components_size, reinterpret_cast<char*>(components),
119 &url_size, &url_bytes[0]);
120
121 struct PP_Var url = PP_MakeUndefined();
122 if (srpc_result == NACL_SRPC_RESULT_OK)
123 (void) DeserializeTo(
124 channel, &url_bytes[0], url_size, 1, &url);
125
126 DebugPrintf("PPB_Testing::GetDocumentURL: %s\n",
127 NaClSrpcErrorString(srpc_result));
128
129 return url;
130 }
131
100 } // namespace 132 } // namespace
101 133
102 const PPB_Testing_Dev* PluginTesting::GetInterface() { 134 const PPB_Testing_Dev* PluginTesting::GetInterface() {
103 static const PPB_Testing_Dev testing_interface = { 135 static const PPB_Testing_Dev testing_interface = {
104 ReadImageData, 136 ReadImageData,
105 RunMessageLoop, 137 RunMessageLoop,
106 QuitMessageLoop, 138 QuitMessageLoop,
107 GetLiveObjectsForInstance, 139 GetLiveObjectsForInstance,
108 IsOutOfProcess 140 IsOutOfProcess,
141 NULL,
bbudge 2011/12/13 18:55:29 OK, but only because I will follow up immediately
ygorshenin 2011/12/14 17:41:10 Done.
142 GetDocumentURL
109 }; 143 };
110 return &testing_interface; 144 return &testing_interface;
111 } 145 }
112 146
113 } // namespace ppapi_proxy 147 } // namespace ppapi_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698