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

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

Issue 7844018: Revert 100748 - This patch tries to remove most of the manual registration for Pepper interfaces,... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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
« no previous file with comments | « ppapi/proxy/ppb_file_ref_proxy.h ('k') | ppapi/proxy/ppb_file_system_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_ref_proxy.h" 5 #include "ppapi/proxy/ppb_file_ref_proxy.h"
6 6
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/ppb_file_ref.h" 8 #include "ppapi/c/ppb_file_ref.h"
9 #include "ppapi/c/private/ppb_proxy_private.h" 9 #include "ppapi/c/private/ppb_proxy_private.h"
10 #include "ppapi/proxy/enter_proxy.h" 10 #include "ppapi/proxy/enter_proxy.h"
11 #include "ppapi/proxy/host_dispatcher.h" 11 #include "ppapi/proxy/host_dispatcher.h"
12 #include "ppapi/proxy/plugin_dispatcher.h" 12 #include "ppapi/proxy/plugin_dispatcher.h"
13 #include "ppapi/proxy/ppapi_messages.h" 13 #include "ppapi/proxy/ppapi_messages.h"
14 #include "ppapi/proxy/serialized_var.h" 14 #include "ppapi/proxy/serialized_var.h"
15 #include "ppapi/shared_impl/file_ref_impl.h" 15 #include "ppapi/shared_impl/file_ref_impl.h"
16 #include "ppapi/thunk/resource_creation_api.h" 16 #include "ppapi/thunk/resource_creation_api.h"
17 #include "ppapi/thunk/thunk.h" 17 #include "ppapi/thunk/thunk.h"
18 18
19 using ppapi::thunk::EnterFunctionNoLock; 19 using ppapi::thunk::EnterFunctionNoLock;
20 using ppapi::thunk::EnterResourceNoLock; 20 using ppapi::thunk::EnterResourceNoLock;
21 using ppapi::thunk::PPB_FileRef_API; 21 using ppapi::thunk::PPB_FileRef_API;
22 using ppapi::thunk::ResourceCreationAPI; 22 using ppapi::thunk::ResourceCreationAPI;
23 23
24 namespace ppapi { 24 namespace ppapi {
25 namespace proxy { 25 namespace proxy {
26 26
27 namespace {
28
29 InterfaceProxy* CreateFileRefProxy(Dispatcher* dispatcher,
30 const void* target_interface) {
31 return new PPB_FileRef_Proxy(dispatcher, target_interface);
32 }
33
34 } // namespace
35
27 class FileRef : public FileRefImpl { 36 class FileRef : public FileRefImpl {
28 public: 37 public:
29 explicit FileRef(const PPB_FileRef_CreateInfo& info); 38 explicit FileRef(const PPB_FileRef_CreateInfo& info);
30 virtual ~FileRef(); 39 virtual ~FileRef();
31 40
32 // PPB_FileRef_API implementation (not provided by FileRefImpl). 41 // PPB_FileRef_API implementation (not provided by FileRefImpl).
33 virtual PP_Resource GetParent() OVERRIDE; 42 virtual PP_Resource GetParent() OVERRIDE;
34 virtual int32_t MakeDirectory(PP_Bool make_ancestors, 43 virtual int32_t MakeDirectory(PP_Bool make_ancestors,
35 PP_CompletionCallback callback) OVERRIDE; 44 PP_CompletionCallback callback) OVERRIDE;
36 virtual int32_t Touch(PP_Time last_access_time, 45 virtual int32_t Touch(PP_Time last_access_time,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 new_file_ref_object->host_resource().instance() != pp_instance()) 104 new_file_ref_object->host_resource().instance() != pp_instance())
96 return PP_ERROR_BADRESOURCE; 105 return PP_ERROR_BADRESOURCE;
97 106
98 GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_Rename( 107 GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_Rename(
99 INTERFACE_ID_PPB_FILE_REF, host_resource(), 108 INTERFACE_ID_PPB_FILE_REF, host_resource(),
100 new_file_ref_object->host_resource(), 109 new_file_ref_object->host_resource(),
101 GetDispatcher()->callback_tracker().SendCallback(callback))); 110 GetDispatcher()->callback_tracker().SendCallback(callback)));
102 return PP_OK_COMPLETIONPENDING; 111 return PP_OK_COMPLETIONPENDING;
103 } 112 }
104 113
105 PPB_FileRef_Proxy::PPB_FileRef_Proxy(Dispatcher* dispatcher) 114 PPB_FileRef_Proxy::PPB_FileRef_Proxy(Dispatcher* dispatcher,
106 : InterfaceProxy(dispatcher) { 115 const void* target_interface)
116 : InterfaceProxy(dispatcher, target_interface) {
107 } 117 }
108 118
109 PPB_FileRef_Proxy::~PPB_FileRef_Proxy() { 119 PPB_FileRef_Proxy::~PPB_FileRef_Proxy() {
110 } 120 }
111 121
122 const InterfaceProxy::Info* PPB_FileRef_Proxy::GetInfo() {
123 static const Info info = {
124 thunk::GetPPB_FileRef_Thunk(),
125 PPB_FILEREF_INTERFACE,
126 INTERFACE_ID_PPB_FILE_REF,
127 false,
128 &CreateFileRefProxy,
129 };
130 return &info;
131 }
132
112 // static 133 // static
113 PP_Resource PPB_FileRef_Proxy::CreateProxyResource(PP_Resource file_system, 134 PP_Resource PPB_FileRef_Proxy::CreateProxyResource(PP_Resource file_system,
114 const char* path) { 135 const char* path) {
115 Resource* file_system_object = 136 Resource* file_system_object =
116 PluginResourceTracker::GetInstance()->GetResource(file_system); 137 PluginResourceTracker::GetInstance()->GetResource(file_system);
117 if (!file_system_object) 138 if (!file_system_object)
118 return 0; 139 return 0;
119 140
120 PPB_FileRef_CreateInfo create_info; 141 PPB_FileRef_CreateInfo create_info;
121 PluginDispatcher::GetForResource(file_system_object)->Send( 142 PluginDispatcher::GetForResource(file_system_object)->Send(
(...skipping 29 matching lines...) Expand all
151 PP_Resource PPB_FileRef_Proxy::DeserializeFileRef( 172 PP_Resource PPB_FileRef_Proxy::DeserializeFileRef(
152 const PPB_FileRef_CreateInfo& serialized) { 173 const PPB_FileRef_CreateInfo& serialized) {
153 if (serialized.resource.is_null()) 174 if (serialized.resource.is_null())
154 return 0; // Resource invalid. 175 return 0; // Resource invalid.
155 return (new FileRef(serialized))->GetReference(); 176 return (new FileRef(serialized))->GetReference();
156 } 177 }
157 178
158 void PPB_FileRef_Proxy::OnMsgCreate(const HostResource& file_system, 179 void PPB_FileRef_Proxy::OnMsgCreate(const HostResource& file_system,
159 const std::string& path, 180 const std::string& path,
160 PPB_FileRef_CreateInfo* result) { 181 PPB_FileRef_CreateInfo* result) {
161 thunk::EnterResourceCreation enter(file_system.instance()); 182 EnterFunctionNoLock<ResourceCreationAPI> enter(file_system.instance(), true);
162 if (enter.failed()) 183 if (enter.failed())
163 return; 184 return;
164 PP_Resource resource = enter.functions()->CreateFileRef( 185 PP_Resource resource = enter.functions()->CreateFileRef(
165 file_system.host_resource(), path.c_str()); 186 file_system.host_resource(), path.c_str());
166 if (!resource) 187 if (!resource)
167 return; // CreateInfo default constructor initializes to 0. 188 return; // CreateInfo default constructor initializes to 0.
168 SerializeFileRef(resource, result); 189 SerializeFileRef(resource, result);
169 } 190 }
170 191
171 void PPB_FileRef_Proxy::OnMsgGetParent(const HostResource& host_resource, 192 void PPB_FileRef_Proxy::OnMsgGetParent(const HostResource& host_resource,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 return; 240 return;
220 PP_CompletionCallback callback = ReceiveCallback(serialized_callback); 241 PP_CompletionCallback callback = ReceiveCallback(serialized_callback);
221 int32_t result = enter.object()->Rename(new_file_ref.host_resource(), 242 int32_t result = enter.object()->Rename(new_file_ref.host_resource(),
222 callback); 243 callback);
223 if (result != PP_OK_COMPLETIONPENDING) 244 if (result != PP_OK_COMPLETIONPENDING)
224 PP_RunCompletionCallback(&callback, result); 245 PP_RunCompletionCallback(&callback, result);
225 } 246 }
226 247
227 } // namespace proxy 248 } // namespace proxy
228 } // namespace ppapi 249 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_file_ref_proxy.h ('k') | ppapi/proxy/ppb_file_system_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698