| 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/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/c/ppb_file_system.h" | 10 #include "ppapi/c/ppb_file_system.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 return; | 167 return; |
| 168 PP_Resource resource = enter.functions()->CreateFileSystem( | 168 PP_Resource resource = enter.functions()->CreateFileSystem( |
| 169 instance, static_cast<PP_FileSystemType>(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 EnterHostFromHostResourceForceCallback<PPB_FileSystem_API> enter( |
| 178 if (enter.failed()) | 178 host_resource, callback_factory_, |
| 179 return; | |
| 180 | |
| 181 CompletionCallback callback = callback_factory_.NewOptionalCallback( | |
| 182 &PPB_FileSystem_Proxy::OpenCompleteInHost, host_resource); | 179 &PPB_FileSystem_Proxy::OpenCompleteInHost, host_resource); |
| 183 int32_t result = enter.object()->Open(expected_size, | 180 if (enter.succeeded()) |
| 184 callback.pp_completion_callback()); | 181 enter.SetResult(enter.object()->Open(expected_size, enter.callback())); |
| 185 if (result != PP_OK_COMPLETIONPENDING) | |
| 186 callback.Run(result); | |
| 187 } | 182 } |
| 188 | 183 |
| 189 // Called in the plugin to handle the open callback. | 184 // Called in the plugin to handle the open callback. |
| 190 void PPB_FileSystem_Proxy::OnMsgOpenComplete(const HostResource& host_resource, | 185 void PPB_FileSystem_Proxy::OnMsgOpenComplete(const HostResource& host_resource, |
| 191 int32_t result) { | 186 int32_t result) { |
| 192 EnterPluginFromHostResource<PPB_FileSystem_API> enter(host_resource); | 187 EnterPluginFromHostResource<PPB_FileSystem_API> enter(host_resource); |
| 193 if (enter.succeeded()) | 188 if (enter.succeeded()) |
| 194 static_cast<FileSystem*>(enter.object())->OpenComplete(result); | 189 static_cast<FileSystem*>(enter.object())->OpenComplete(result); |
| 195 } | 190 } |
| 196 | 191 |
| 197 void PPB_FileSystem_Proxy::OpenCompleteInHost( | 192 void PPB_FileSystem_Proxy::OpenCompleteInHost( |
| 198 int32_t result, | 193 int32_t result, |
| 199 const HostResource& host_resource) { | 194 const HostResource& host_resource) { |
| 200 dispatcher()->Send(new PpapiMsg_PPBFileSystem_OpenComplete( | 195 dispatcher()->Send(new PpapiMsg_PPBFileSystem_OpenComplete( |
| 201 INTERFACE_ID_PPB_FILE_SYSTEM, host_resource, result)); | 196 INTERFACE_ID_PPB_FILE_SYSTEM, host_resource, result)); |
| 202 } | 197 } |
| 203 | 198 |
| 204 } // namespace proxy | 199 } // namespace proxy |
| 205 } // namespace pp | 200 } // namespace pp |
| OLD | NEW |