OLD | NEW |
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" | 9 #include "ppapi/c/dev/ppb_file_system_dev.h" |
10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
180 | 180 |
181 CompletionCallback callback = callback_factory_.NewCallback( | 181 CompletionCallback callback = callback_factory_.NewOptionalCallback( |
182 &PPB_FileSystem_Proxy::OpenCompleteInHost, host_resource); | 182 &PPB_FileSystem_Proxy::OpenCompleteInHost, host_resource); |
183 int32_t result = enter.object()->Open(expected_size, | 183 int32_t result = enter.object()->Open(expected_size, |
184 callback.pp_completion_callback()); | 184 callback.pp_completion_callback()); |
185 if (result != PP_OK_COMPLETIONPENDING) | 185 if (result != PP_OK_COMPLETIONPENDING) |
186 callback.Run(result); | 186 callback.Run(result); |
187 } | 187 } |
188 | 188 |
189 // Called in the plugin to handle the open callback. | 189 // Called in the plugin to handle the open callback. |
190 void PPB_FileSystem_Proxy::OnMsgOpenComplete(const HostResource& host_resource, | 190 void PPB_FileSystem_Proxy::OnMsgOpenComplete(const HostResource& host_resource, |
191 int32_t result) { | 191 int32_t result) { |
192 EnterPluginFromHostResource<PPB_FileSystem_API> enter(host_resource); | 192 EnterPluginFromHostResource<PPB_FileSystem_API> enter(host_resource); |
193 if (enter.succeeded()) | 193 if (enter.succeeded()) |
194 static_cast<FileSystem*>(enter.object())->OpenComplete(result); | 194 static_cast<FileSystem*>(enter.object())->OpenComplete(result); |
195 } | 195 } |
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 |
OLD | NEW |