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

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

Issue 21966004: Pepper: Move FileRef to the "new" resource proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove code duplication Created 7 years, 4 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/file_io_resource.h" 5 #include "ppapi/proxy/file_io_resource.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "ipc/ipc_message.h" 8 #include "ipc/ipc_message.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/proxy/ppapi_messages.h" 10 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/shared_impl/array_writer.h" 11 #include "ppapi/shared_impl/array_writer.h"
12 #include "ppapi/shared_impl/ppapi_globals.h" 12 #include "ppapi/shared_impl/ppapi_globals.h"
13 #include "ppapi/shared_impl/resource_tracker.h" 13 #include "ppapi/shared_impl/resource_tracker.h"
14 #include "ppapi/thunk/enter.h" 14 #include "ppapi/thunk/enter.h"
15 #include "ppapi/thunk/ppb_file_ref_api.h" 15 #include "ppapi/thunk/ppb_file_ref_api.h"
16 16
17 using ppapi::thunk::EnterResourceNoLock; 17 using ppapi::thunk::EnterResourceNoLock;
18 using ppapi::thunk::PPB_FileIO_API; 18 using ppapi::thunk::PPB_FileIO_API;
19 using ppapi::thunk::PPB_FileRef_API;
dmichael (off chromium) 2013/08/07 22:19:13 Why did you need to do this? Seems like it would b
teravest 2013/08/08 00:50:06 Done.
20 19
21 namespace { 20 namespace {
22 21
23 // An adapter to let Read() share the same implementation with ReadToArray(). 22 // An adapter to let Read() share the same implementation with ReadToArray().
24 void* DummyGetDataBuffer(void* user_data, uint32_t count, uint32_t size) { 23 void* DummyGetDataBuffer(void* user_data, uint32_t count, uint32_t size) {
25 return user_data; 24 return user_data;
26 } 25 }
27 26
28 } // namespace 27 } // namespace
29 28
30 namespace ppapi { 29 namespace ppapi {
31 namespace proxy { 30 namespace proxy {
32 31
33 FileIOResource::FileIOResource(Connection connection, PP_Instance instance) 32 FileIOResource::FileIOResource(Connection connection, PP_Instance instance)
34 : PluginResource(connection, instance) { 33 : PluginResource(connection, instance) {
35 SendCreate(RENDERER, PpapiHostMsg_FileIO_Create()); 34 SendCreate(RENDERER, PpapiHostMsg_FileIO_Create());
36 } 35 }
37 36
38 FileIOResource::~FileIOResource() { 37 FileIOResource::~FileIOResource() {
39 } 38 }
40 39
41 PPB_FileIO_API* FileIOResource::AsPPB_FileIO_API() { 40 PPB_FileIO_API* FileIOResource::AsPPB_FileIO_API() {
42 return this; 41 return this;
43 } 42 }
44 43
45 int32_t FileIOResource::Open(PP_Resource file_ref, 44 int32_t FileIOResource::Open(PP_Resource file_ref,
46 int32_t open_flags, 45 int32_t open_flags,
47 scoped_refptr<TrackedCallback> callback) { 46 scoped_refptr<TrackedCallback> callback) {
48 EnterResourceNoLock<PPB_FileRef_API> enter(file_ref, true); 47 EnterResourceNoLock<thunk::PPB_FileRef_API> enter(file_ref, true);
49 if (enter.failed()) 48 if (enter.failed())
50 return PP_ERROR_BADRESOURCE; 49 return PP_ERROR_BADRESOURCE;
51 50
52 int32_t rv = state_manager_.CheckOperationState( 51 int32_t rv = state_manager_.CheckOperationState(
53 FileIOStateManager::OPERATION_EXCLUSIVE, false); 52 FileIOStateManager::OPERATION_EXCLUSIVE, false);
54 if (rv != PP_OK) 53 if (rv != PP_OK)
55 return rv; 54 return rv;
56 55
57 Call<PpapiPluginMsg_FileIO_OpenReply>(RENDERER, 56 Call<PpapiPluginMsg_FileIO_OpenReply>(RENDERER,
58 PpapiHostMsg_FileIO_Open( 57 PpapiHostMsg_FileIO_Open(
59 enter.resource()->host_resource().host_resource(), 58 file_ref,
60 open_flags), 59 open_flags),
61 base::Bind(&FileIOResource::OnPluginMsgOpenFileComplete, this, 60 base::Bind(&FileIOResource::OnPluginMsgOpenFileComplete, this,
62 callback)); 61 callback));
63 62
64 state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE); 63 state_manager_.SetPendingOperation(FileIOStateManager::OPERATION_EXCLUSIVE);
65 return PP_OK_COMPLETIONPENDING; 64 return PP_OK_COMPLETIONPENDING;
66 } 65 }
67 66
68 int32_t FileIOResource::Query(PP_FileInfo* info, 67 int32_t FileIOResource::Query(PP_FileInfo* info,
69 scoped_refptr<TrackedCallback> callback) { 68 scoped_refptr<TrackedCallback> callback) {
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 result = PP_ERROR_FAILED; 320 result = PP_ERROR_FAILED;
322 *output_handle = IPC::PlatformFileForTransitToPlatformFile(transit_file); 321 *output_handle = IPC::PlatformFileForTransitToPlatformFile(transit_file);
323 322
324 // End the operation now. The callback may perform another file operation. 323 // End the operation now. The callback may perform another file operation.
325 state_manager_.SetOperationFinished(); 324 state_manager_.SetOperationFinished();
326 callback->Run(result); 325 callback->Run(result);
327 } 326 }
328 327
329 } // namespace proxy 328 } // namespace proxy
330 } // namespace ppapi 329 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698