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

Side by Side Diff: ppapi/proxy/ppb_file_io_proxy.cc

Issue 11094060: Exclude host-side code from the NaCl IRT proxy build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ppapi/proxy/ppb_file_io_proxy.h" 5 #include "ppapi/proxy/ppb_file_io_proxy.h"
6 6
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/proxy/enter_proxy.h" 8 #include "ppapi/proxy/enter_proxy.h"
9 #include "ppapi/proxy/ppapi_messages.h" 9 #include "ppapi/proxy/ppapi_messages.h"
10 #include "ppapi/proxy/ppb_file_ref_proxy.h" 10 #include "ppapi/proxy/ppb_file_ref_proxy.h"
(...skipping 10 matching lines...) Expand all
21 21
22 namespace { 22 namespace {
23 23
24 // The maximum size we'll support reading in one chunk. The renderer process 24 // The maximum size we'll support reading in one chunk. The renderer process
25 // must allocate a buffer sized according to the request of the plugin. To 25 // must allocate a buffer sized according to the request of the plugin. To
26 // keep things from getting out of control, we cap the read size to this value. 26 // keep things from getting out of control, we cap the read size to this value.
27 // This should generally be OK since the API specifies that it may perform a 27 // This should generally be OK since the API specifies that it may perform a
28 // partial read. 28 // partial read.
29 static const int32_t kMaxReadSize = 33554432; // 32MB 29 static const int32_t kMaxReadSize = 33554432; // 32MB
30 30
31 #if !defined(OS_NACL)
31 typedef EnterHostFromHostResourceForceCallback<PPB_FileIO_API> EnterHostFileIO; 32 typedef EnterHostFromHostResourceForceCallback<PPB_FileIO_API> EnterHostFileIO;
33 #endif
32 typedef EnterPluginFromHostResource<PPB_FileIO_API> EnterPluginFileIO; 34 typedef EnterPluginFromHostResource<PPB_FileIO_API> EnterPluginFileIO;
33 35
34 class FileIO : public PPB_FileIO_Shared { 36 class FileIO : public PPB_FileIO_Shared {
35 public: 37 public:
36 explicit FileIO(const HostResource& host_resource); 38 explicit FileIO(const HostResource& host_resource);
37 virtual ~FileIO(); 39 virtual ~FileIO();
38 40
39 // PPB_FileIO_API implementation (not provided by FileIOImpl). 41 // PPB_FileIO_API implementation (not provided by FileIOImpl).
40 virtual void Close() OVERRIDE; 42 virtual void Close() OVERRIDE;
41 virtual int32_t GetOSFileDescriptor() OVERRIDE; 43 virtual int32_t GetOSFileDescriptor() OVERRIDE;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 dispatcher->Send(new PpapiHostMsg_PPBFileIO_Create(kApiID, instance, 213 dispatcher->Send(new PpapiHostMsg_PPBFileIO_Create(kApiID, instance,
212 &result)); 214 &result));
213 if (result.is_null()) 215 if (result.is_null())
214 return 0; 216 return 0;
215 return (new FileIO(result))->GetReference(); 217 return (new FileIO(result))->GetReference();
216 } 218 }
217 219
218 bool PPB_FileIO_Proxy::OnMessageReceived(const IPC::Message& msg) { 220 bool PPB_FileIO_Proxy::OnMessageReceived(const IPC::Message& msg) {
219 bool handled = true; 221 bool handled = true;
220 IPC_BEGIN_MESSAGE_MAP(PPB_FileIO_Proxy, msg) 222 IPC_BEGIN_MESSAGE_MAP(PPB_FileIO_Proxy, msg)
223 #if !defined(OS_NACL)
221 // Plugin -> host message. 224 // Plugin -> host message.
222 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Create, OnHostMsgCreate) 225 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Create, OnHostMsgCreate)
223 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Open, OnHostMsgOpen) 226 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Open, OnHostMsgOpen)
224 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Close, OnHostMsgClose) 227 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Close, OnHostMsgClose)
225 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Query, OnHostMsgQuery) 228 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Query, OnHostMsgQuery)
226 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Touch, OnHostMsgTouch) 229 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Touch, OnHostMsgTouch)
227 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Read, OnHostMsgRead) 230 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Read, OnHostMsgRead)
228 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Write, OnHostMsgWrite) 231 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Write, OnHostMsgWrite)
229 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_SetLength, OnHostMsgSetLength) 232 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_SetLength, OnHostMsgSetLength)
230 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Flush, OnHostMsgFlush) 233 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_Flush, OnHostMsgFlush)
231 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_WillWrite, OnHostMsgWillWrite) 234 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_WillWrite, OnHostMsgWillWrite)
232 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_WillSetLength, 235 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileIO_WillSetLength,
233 OnHostMsgWillSetLength) 236 OnHostMsgWillSetLength)
234 237 #endif // !defined(OS_NACL)
235 // Host -> plugin messages. 238 // Host -> plugin messages.
236 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_GeneralComplete, 239 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_GeneralComplete,
237 OnPluginMsgGeneralComplete) 240 OnPluginMsgGeneralComplete)
238 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_OpenFileComplete, 241 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_OpenFileComplete,
239 OnPluginMsgOpenFileComplete) 242 OnPluginMsgOpenFileComplete)
240 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_QueryComplete, 243 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_QueryComplete,
241 OnPluginMsgQueryComplete) 244 OnPluginMsgQueryComplete)
242 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_ReadComplete, 245 IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileIO_ReadComplete,
243 OnPluginMsgReadComplete) 246 OnPluginMsgReadComplete)
244 IPC_MESSAGE_UNHANDLED(handled = false) 247 IPC_MESSAGE_UNHANDLED(handled = false)
245 IPC_END_MESSAGE_MAP() 248 IPC_END_MESSAGE_MAP()
246 return handled; 249 return handled;
247 } 250 }
248 251
252 #if !defined(OS_NACL)
249 void PPB_FileIO_Proxy::OnHostMsgCreate(PP_Instance instance, 253 void PPB_FileIO_Proxy::OnHostMsgCreate(PP_Instance instance,
250 HostResource* result) { 254 HostResource* result) {
251 thunk::EnterResourceCreation enter(instance); 255 thunk::EnterResourceCreation enter(instance);
252 if (enter.succeeded()) { 256 if (enter.succeeded()) {
253 result->SetHostResource(instance, 257 result->SetHostResource(instance,
254 enter.functions()->CreateFileIO(instance)); 258 enter.functions()->CreateFileIO(instance));
255 } 259 }
256 } 260 }
257 261
258 void PPB_FileIO_Proxy::OnHostMsgOpen(const HostResource& host_resource, 262 void PPB_FileIO_Proxy::OnHostMsgOpen(const HostResource& host_resource,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 368
365 void PPB_FileIO_Proxy::OnHostMsgWillSetLength(const HostResource& host_resource, 369 void PPB_FileIO_Proxy::OnHostMsgWillSetLength(const HostResource& host_resource,
366 int64_t length) { 370 int64_t length) {
367 EnterHostFileIO enter(host_resource, callback_factory_, 371 EnterHostFileIO enter(host_resource, callback_factory_,
368 &PPB_FileIO_Proxy::GeneralCallbackCompleteInHost, 372 &PPB_FileIO_Proxy::GeneralCallbackCompleteInHost,
369 host_resource); 373 host_resource);
370 if (enter.succeeded()) 374 if (enter.succeeded())
371 enter.SetResult(enter.object()->WillSetLength(length, enter.callback())); 375 enter.SetResult(enter.object()->WillSetLength(length, enter.callback()));
372 } 376 }
373 377
378 void PPB_FileIO_Proxy::GeneralCallbackCompleteInHost(
brettw 2012/10/11 18:05:50 I like to keep the header and .cc ordering the sam
bbudge 2012/10/11 18:46:02 Done for all files where methods were moved.
379 int32_t pp_error,
380 const HostResource& host_resource) {
381 Send(new PpapiMsg_PPBFileIO_GeneralComplete(kApiID, host_resource, pp_error));
382 }
383
384 void PPB_FileIO_Proxy::OpenFileCallbackCompleteInHost(
385 int32_t pp_error,
386 const HostResource& host_resource) {
387 Send(new PpapiMsg_PPBFileIO_OpenFileComplete(kApiID, host_resource,
388 pp_error));
389 }
390
391 void PPB_FileIO_Proxy::QueryCallbackCompleteInHost(
392 int32_t pp_error,
393 const HostResource& host_resource,
394 PP_FileInfo* info) {
395 Send(new PpapiMsg_PPBFileIO_QueryComplete(kApiID, host_resource, pp_error,
396 *info));
397 delete info;
398 }
399
400 void PPB_FileIO_Proxy::ReadCallbackCompleteInHost(
401 int32_t pp_error,
402 const HostResource& host_resource,
403 std::string* data) {
404 // Only send the amount of data in the string that was actually read.
405 if (pp_error >= 0) {
406 DCHECK(pp_error <= static_cast<int32_t>(data->size()));
407 data->resize(pp_error);
408 }
409 Send(new PpapiMsg_PPBFileIO_ReadComplete(kApiID, host_resource, pp_error,
410 *data));
411 delete data;
412 }
413 #endif // !defined(OS_NACL)
414
374 void PPB_FileIO_Proxy::OnPluginMsgGeneralComplete( 415 void PPB_FileIO_Proxy::OnPluginMsgGeneralComplete(
375 const HostResource& host_resource, 416 const HostResource& host_resource,
376 int32_t result) { 417 int32_t result) {
377 EnterPluginFileIO enter(host_resource); 418 EnterPluginFileIO enter(host_resource);
378 if (enter.succeeded()) 419 if (enter.succeeded())
379 static_cast<FileIO*>(enter.object())->ExecuteGeneralCallback(result); 420 static_cast<FileIO*>(enter.object())->ExecuteGeneralCallback(result);
380 } 421 }
381 422
382 void PPB_FileIO_Proxy::OnPluginMsgOpenFileComplete( 423 void PPB_FileIO_Proxy::OnPluginMsgOpenFileComplete(
383 const HostResource& host_resource, 424 const HostResource& host_resource,
(...skipping 19 matching lines...) Expand all
403 EnterPluginFileIO enter(host_resource); 444 EnterPluginFileIO enter(host_resource);
404 if (enter.succeeded()) { 445 if (enter.succeeded()) {
405 // The result code should contain the data size if it's positive. 446 // The result code should contain the data size if it's positive.
406 DCHECK((result < 0 && data.size() == 0) || 447 DCHECK((result < 0 && data.size() == 0) ||
407 result == static_cast<int32_t>(data.size())); 448 result == static_cast<int32_t>(data.size()));
408 static_cast<FileIO*>(enter.object())->ExecuteReadCallback(result, 449 static_cast<FileIO*>(enter.object())->ExecuteReadCallback(result,
409 data.data()); 450 data.data());
410 } 451 }
411 } 452 }
412 453
413 void PPB_FileIO_Proxy::GeneralCallbackCompleteInHost(
414 int32_t pp_error,
415 const HostResource& host_resource) {
416 Send(new PpapiMsg_PPBFileIO_GeneralComplete(kApiID, host_resource, pp_error));
417 }
418
419 void PPB_FileIO_Proxy::OpenFileCallbackCompleteInHost(
420 int32_t pp_error,
421 const HostResource& host_resource) {
422 Send(new PpapiMsg_PPBFileIO_OpenFileComplete(kApiID, host_resource,
423 pp_error));
424 }
425
426 void PPB_FileIO_Proxy::QueryCallbackCompleteInHost(
427 int32_t pp_error,
428 const HostResource& host_resource,
429 PP_FileInfo* info) {
430 Send(new PpapiMsg_PPBFileIO_QueryComplete(kApiID, host_resource, pp_error,
431 *info));
432 delete info;
433 }
434
435 void PPB_FileIO_Proxy::ReadCallbackCompleteInHost(
436 int32_t pp_error,
437 const HostResource& host_resource,
438 std::string* data) {
439 // Only send the amount of data in the string that was actually read.
440 if (pp_error >= 0) {
441 DCHECK(pp_error <= static_cast<int32_t>(data->size()));
442 data->resize(pp_error);
443 }
444 Send(new PpapiMsg_PPBFileIO_ReadComplete(kApiID, host_resource, pp_error,
445 *data));
446 delete data;
447 }
448
449 } // namespace proxy 454 } // namespace proxy
450 } // namespace ppapi 455 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698