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

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

Issue 7248047: Migrating PPB_FileIO_Dev, PPB_FileRef_Dev, and PPB_FileSystem_Dev dependencies to PPB_FileIO, PPB... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 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 "ppapi/proxy/ppb_file_system_proxy.h" 5 #include "ppapi/proxy/ppb_file_system_proxy.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/task.h" 8 #include "base/task.h"
9 #include "ppapi/c/dev/ppb_file_system_dev.h"
10 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/ppb_file_system.h"
11 #include "ppapi/proxy/enter_proxy.h" 11 #include "ppapi/proxy/enter_proxy.h"
12 #include "ppapi/proxy/host_dispatcher.h" 12 #include "ppapi/proxy/host_dispatcher.h"
13 #include "ppapi/proxy/plugin_dispatcher.h" 13 #include "ppapi/proxy/plugin_dispatcher.h"
14 #include "ppapi/proxy/plugin_resource.h" 14 #include "ppapi/proxy/plugin_resource.h"
15 #include "ppapi/proxy/ppapi_messages.h" 15 #include "ppapi/proxy/ppapi_messages.h"
16 #include "ppapi/proxy/serialized_var.h" 16 #include "ppapi/proxy/serialized_var.h"
17 #include "ppapi/thunk/enter.h" 17 #include "ppapi/thunk/enter.h"
18 #include "ppapi/thunk/ppb_file_system_api.h" 18 #include "ppapi/thunk/ppb_file_system_api.h"
19 #include "ppapi/thunk/resource_creation_api.h" 19 #include "ppapi/thunk/resource_creation_api.h"
20 #include "ppapi/thunk/thunk.h" 20 #include "ppapi/thunk/thunk.h"
(...skipping 12 matching lines...) Expand all
33 return new PPB_FileSystem_Proxy(dispatcher, target_interface); 33 return new PPB_FileSystem_Proxy(dispatcher, target_interface);
34 } 34 }
35 35
36 } // namespace 36 } // namespace
37 37
38 // This object maintains most of the state of the ref in the plugin for fast 38 // This object maintains most of the state of the ref in the plugin for fast
39 // querying. It's all set in the constructor from the "create info" sent from 39 // querying. It's all set in the constructor from the "create info" sent from
40 // the host. 40 // the host.
41 class FileSystem : public PluginResource, public PPB_FileSystem_API { 41 class FileSystem : public PluginResource, public PPB_FileSystem_API {
42 public: 42 public:
43 FileSystem(const HostResource& host_resource, PP_FileSystemType_Dev type); 43 FileSystem(const HostResource& host_resource, PP_FileSystemType type);
44 virtual ~FileSystem(); 44 virtual ~FileSystem();
45 45
46 // ResourceObjectBase override. 46 // ResourceObjectBase override.
47 virtual PPB_FileSystem_API* AsPPB_FileSystem_API() OVERRIDE; 47 virtual PPB_FileSystem_API* AsPPB_FileSystem_API() OVERRIDE;
48 48
49 // PPB_FileSystem_APi implementation. 49 // PPB_FileSystem_APi implementation.
50 virtual int32_t Open(int64_t expected_size, 50 virtual int32_t Open(int64_t expected_size,
51 PP_CompletionCallback callback) OVERRIDE; 51 PP_CompletionCallback callback) OVERRIDE;
52 virtual PP_FileSystemType_Dev GetType() OVERRIDE; 52 virtual PP_FileSystemType GetType() OVERRIDE;
53 53
54 // Called when the host has responded to our open request. 54 // Called when the host has responded to our open request.
55 void OpenComplete(int32_t result); 55 void OpenComplete(int32_t result);
56 56
57 private: 57 private:
58 PP_FileSystemType_Dev type_; 58 PP_FileSystemType type_;
59 bool called_open_; 59 bool called_open_;
60 PP_CompletionCallback current_open_callback_; 60 PP_CompletionCallback current_open_callback_;
61 61
62 DISALLOW_COPY_AND_ASSIGN(FileSystem); 62 DISALLOW_COPY_AND_ASSIGN(FileSystem);
63 }; 63 };
64 64
65 FileSystem::FileSystem(const HostResource& host_resource, 65 FileSystem::FileSystem(const HostResource& host_resource,
66 PP_FileSystemType_Dev type) 66 PP_FileSystemType type)
67 : PluginResource(host_resource), 67 : PluginResource(host_resource),
68 type_(type), 68 type_(type),
69 called_open_(false), 69 called_open_(false),
70 current_open_callback_(PP_MakeCompletionCallback(NULL, NULL)) { 70 current_open_callback_(PP_MakeCompletionCallback(NULL, NULL)) {
71 } 71 }
72 72
73 // TODO(brettw) this logic is duplicated with some other resource objects 73 // TODO(brettw) this logic is duplicated with some other resource objects
74 // like FileChooser. It would be nice to look at all of the different resources 74 // like FileChooser. It would be nice to look at all of the different resources
75 // that need callback tracking and design something that they can all re-use. 75 // that need callback tracking and design something that they can all re-use.
76 FileSystem::~FileSystem() { 76 FileSystem::~FileSystem() {
(...skipping 18 matching lines...) Expand all
95 if (called_open_) 95 if (called_open_)
96 return PP_ERROR_FAILED; 96 return PP_ERROR_FAILED;
97 97
98 current_open_callback_ = callback; 98 current_open_callback_ = callback;
99 called_open_ = true; 99 called_open_ = true;
100 GetDispatcher()->Send(new PpapiHostMsg_PPBFileSystem_Open( 100 GetDispatcher()->Send(new PpapiHostMsg_PPBFileSystem_Open(
101 INTERFACE_ID_PPB_FILE_SYSTEM, host_resource(), expected_size)); 101 INTERFACE_ID_PPB_FILE_SYSTEM, host_resource(), expected_size));
102 return PP_OK_COMPLETIONPENDING; 102 return PP_OK_COMPLETIONPENDING;
103 } 103 }
104 104
105 PP_FileSystemType_Dev FileSystem::GetType() { 105 PP_FileSystemType FileSystem::GetType() {
106 return type_; 106 return type_;
107 } 107 }
108 108
109 void FileSystem::OpenComplete(int32_t result) { 109 void FileSystem::OpenComplete(int32_t result) {
110 PP_RunAndClearCompletionCallback(&current_open_callback_, result); 110 PP_RunAndClearCompletionCallback(&current_open_callback_, result);
111 } 111 }
112 112
113 PPB_FileSystem_Proxy::PPB_FileSystem_Proxy(Dispatcher* dispatcher, 113 PPB_FileSystem_Proxy::PPB_FileSystem_Proxy(Dispatcher* dispatcher,
114 const void* target_interface) 114 const void* target_interface)
115 : InterfaceProxy(dispatcher, target_interface), 115 : InterfaceProxy(dispatcher, target_interface),
116 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 116 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
117 } 117 }
118 118
119 PPB_FileSystem_Proxy::~PPB_FileSystem_Proxy() { 119 PPB_FileSystem_Proxy::~PPB_FileSystem_Proxy() {
120 } 120 }
121 121
122 const InterfaceProxy::Info* PPB_FileSystem_Proxy::GetInfo() { 122 const InterfaceProxy::Info* PPB_FileSystem_Proxy::GetInfo() {
123 static const Info info = { 123 static const Info info = {
124 ::ppapi::thunk::GetPPB_FileSystem_Thunk(), 124 ::ppapi::thunk::GetPPB_FileSystem_Thunk(),
125 PPB_FILESYSTEM_DEV_INTERFACE, 125 PPB_FILESYSTEM_INTERFACE,
126 INTERFACE_ID_PPB_FILE_SYSTEM, 126 INTERFACE_ID_PPB_FILE_SYSTEM,
127 false, 127 false,
128 &CreateFileSystemProxy, 128 &CreateFileSystemProxy,
129 }; 129 };
130 return &info; 130 return &info;
131 } 131 }
132 132
133 // static 133 // static
134 PP_Resource PPB_FileSystem_Proxy::CreateProxyResource( 134 PP_Resource PPB_FileSystem_Proxy::CreateProxyResource(
135 PP_Instance instance, 135 PP_Instance instance,
136 PP_FileSystemType_Dev type) { 136 PP_FileSystemType type) {
137 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); 137 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
138 if (!dispatcher) 138 if (!dispatcher)
139 return PP_ERROR_BADARGUMENT; 139 return PP_ERROR_BADARGUMENT;
140 140
141 HostResource result; 141 HostResource result;
142 dispatcher->Send(new PpapiHostMsg_PPBFileSystem_Create( 142 dispatcher->Send(new PpapiHostMsg_PPBFileSystem_Create(
143 INTERFACE_ID_PPB_FILE_SYSTEM, instance, type, &result)); 143 INTERFACE_ID_PPB_FILE_SYSTEM, instance, type, &result));
144 if (result.is_null()) 144 if (result.is_null())
145 return 0; 145 return 0;
146 146
(...skipping 12 matching lines...) Expand all
159 return handled; 159 return handled;
160 } 160 }
161 161
162 void PPB_FileSystem_Proxy::OnMsgCreate(PP_Instance instance, 162 void PPB_FileSystem_Proxy::OnMsgCreate(PP_Instance instance,
163 int type, 163 int type,
164 HostResource* result) { 164 HostResource* result) {
165 EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); 165 EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true);
166 if (enter.failed()) 166 if (enter.failed())
167 return; 167 return;
168 PP_Resource resource = enter.functions()->CreateFileSystem( 168 PP_Resource resource = enter.functions()->CreateFileSystem(
169 instance, static_cast<PP_FileSystemType_Dev>(type)); 169 instance, static_cast<PP_FileSystemType>(type));
170 if (!resource) 170 if (!resource)
171 return; // CreateInfo default constructor initializes to 0. 171 return; // CreateInfo default constructor initializes to 0.
172 result->SetHostResource(instance, resource); 172 result->SetHostResource(instance, resource);
173 } 173 }
174 174
175 void PPB_FileSystem_Proxy::OnMsgOpen(const HostResource& host_resource, 175 void PPB_FileSystem_Proxy::OnMsgOpen(const HostResource& host_resource,
176 int64_t expected_size) { 176 int64_t expected_size) {
177 EnterHostFromHostResource<PPB_FileSystem_API> enter(host_resource); 177 EnterHostFromHostResource<PPB_FileSystem_API> enter(host_resource);
178 if (enter.failed()) 178 if (enter.failed())
179 return; 179 return;
(...skipping 16 matching lines...) Expand all
196 196
197 void PPB_FileSystem_Proxy::OpenCompleteInHost( 197 void PPB_FileSystem_Proxy::OpenCompleteInHost(
198 int32_t result, 198 int32_t result,
199 const HostResource& host_resource) { 199 const HostResource& host_resource) {
200 dispatcher()->Send(new PpapiMsg_PPBFileSystem_OpenComplete( 200 dispatcher()->Send(new PpapiMsg_PPBFileSystem_OpenComplete(
201 INTERFACE_ID_PPB_FILE_SYSTEM, host_resource, result)); 201 INTERFACE_ID_PPB_FILE_SYSTEM, host_resource, result));
202 } 202 }
203 203
204 } // namespace proxy 204 } // namespace proxy
205 } // namespace pp 205 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698