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

Side by Side Diff: webkit/plugins/ppapi/ppb_file_io_impl.cc

Issue 10541113: Notify CloseFile from Pepper to FileSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 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
« no previous file with comments | « webkit/plugins/ppapi/ppb_file_io_impl.h ('k') | no next file » | 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) 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 "webkit/plugins/ppapi/ppb_file_io_impl.h" 5 #include "webkit/plugins/ppapi/ppb_file_io_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/callback_helpers.h"
9 #include "base/file_util.h" 10 #include "base/file_util.h"
10 #include "base/file_util_proxy.h" 11 #include "base/file_util_proxy.h"
11 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
12 #include "base/platform_file.h" 13 #include "base/platform_file.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/time.h" 15 #include "base/time.h"
15 #include "ppapi/c/ppb_file_io.h" 16 #include "ppapi/c/ppb_file_io.h"
16 #include "ppapi/c/trusted/ppb_file_io_trusted.h" 17 #include "ppapi/c/trusted/ppb_file_io_trusted.h"
17 #include "ppapi/c/pp_completion_callback.h" 18 #include "ppapi/c/pp_completion_callback.h"
18 #include "ppapi/c/pp_errors.h" 19 #include "ppapi/c/pp_errors.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return PP_ERROR_BADARGUMENT; 58 return PP_ERROR_BADARGUMENT;
58 59
59 PluginDelegate* plugin_delegate = GetPluginDelegate(); 60 PluginDelegate* plugin_delegate = GetPluginDelegate();
60 if (!plugin_delegate) 61 if (!plugin_delegate)
61 return PP_ERROR_BADARGUMENT; 62 return PP_ERROR_BADARGUMENT;
62 63
63 if (file_ref->HasValidFileSystem()) { 64 if (file_ref->HasValidFileSystem()) {
64 file_system_url_ = file_ref->GetFileSystemURL(); 65 file_system_url_ = file_ref->GetFileSystemURL();
65 if (!plugin_delegate->AsyncOpenFileSystemURL( 66 if (!plugin_delegate->AsyncOpenFileSystemURL(
66 file_system_url_, flags, 67 file_system_url_, flags,
67 base::Bind(&PPB_FileIO_Impl::ExecutePlatformOpenFileCallback, 68 base::Bind(
68 weak_factory_.GetWeakPtr()))) 69 &PPB_FileIO_Impl::ExecutePlatformOpenFileSystemURLCallback,
70 weak_factory_.GetWeakPtr())))
69 return PP_ERROR_FAILED; 71 return PP_ERROR_FAILED;
70 } else { 72 } else {
71 if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) 73 if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL)
72 return PP_ERROR_FAILED; 74 return PP_ERROR_FAILED;
73 if (!plugin_delegate->AsyncOpenFile( 75 if (!plugin_delegate->AsyncOpenFile(
74 file_ref->GetSystemPath(), flags, 76 file_ref->GetSystemPath(), flags,
75 base::Bind(&PPB_FileIO_Impl::ExecutePlatformOpenFileCallback, 77 base::Bind(&PPB_FileIO_Impl::ExecutePlatformOpenFileCallback,
76 weak_factory_.GetWeakPtr()))) 78 weak_factory_.GetWeakPtr())))
77 return PP_ERROR_FAILED; 79 return PP_ERROR_FAILED;
78 } 80 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 return PP_ERROR_FAILED; 206 return PP_ERROR_FAILED;
205 207
206 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, NULL); 208 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL, NULL);
207 return PP_OK_COMPLETIONPENDING; 209 return PP_OK_COMPLETIONPENDING;
208 } 210 }
209 211
210 void PPB_FileIO_Impl::Close() { 212 void PPB_FileIO_Impl::Close() {
211 PluginDelegate* plugin_delegate = GetPluginDelegate(); 213 PluginDelegate* plugin_delegate = GetPluginDelegate();
212 if (file_ != base::kInvalidPlatformFileValue && plugin_delegate) { 214 if (file_ != base::kInvalidPlatformFileValue && plugin_delegate) {
213 base::FileUtilProxy::Close( 215 base::FileUtilProxy::Close(
214 plugin_delegate->GetFileThreadMessageLoopProxy(), file_, 216 plugin_delegate->GetFileThreadMessageLoopProxy(),
215 base::FileUtilProxy::StatusCallback()); 217 file_,
218 base::ResetAndReturn(&notify_close_file_callback_));
216 file_ = base::kInvalidPlatformFileValue; 219 file_ = base::kInvalidPlatformFileValue;
217 quota_file_io_.reset(); 220 quota_file_io_.reset();
218 } 221 }
219 } 222 }
220 223
221 int32_t PPB_FileIO_Impl::GetOSFileDescriptor() { 224 int32_t PPB_FileIO_Impl::GetOSFileDescriptor() {
222 #if defined(OS_POSIX) 225 #if defined(OS_POSIX)
223 return file_; 226 return file_;
224 #elif defined(OS_WIN) 227 #elif defined(OS_WIN)
225 return reinterpret_cast<uintptr_t>(file_); 228 return reinterpret_cast<uintptr_t>(file_);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 if (file_ != base::kInvalidPlatformFileValue && 290 if (file_ != base::kInvalidPlatformFileValue &&
288 (file_system_type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY || 291 (file_system_type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY ||
289 file_system_type_ == PP_FILESYSTEMTYPE_LOCALPERSISTENT)) { 292 file_system_type_ == PP_FILESYSTEMTYPE_LOCALPERSISTENT)) {
290 quota_file_io_.reset(new QuotaFileIO( 293 quota_file_io_.reset(new QuotaFileIO(
291 pp_instance(), file_, file_system_url_, file_system_type_)); 294 pp_instance(), file_, file_system_url_, file_system_type_));
292 } 295 }
293 296
294 ExecuteOpenFileCallback(::ppapi::PlatformFileErrorToPepperError(error_code)); 297 ExecuteOpenFileCallback(::ppapi::PlatformFileErrorToPepperError(error_code));
295 } 298 }
296 299
300 void PPB_FileIO_Impl::ExecutePlatformOpenFileSystemURLCallback(
301 base::PlatformFileError error_code,
302 base::PassPlatformFile file,
303 const PluginDelegate::NotifyCloseFileCallback& callback) {
304 if (error_code == base::PLATFORM_FILE_OK)
305 notify_close_file_callback_ = callback;
306 ExecutePlatformOpenFileCallback(error_code, file);
307 }
308
297 void PPB_FileIO_Impl::ExecutePlatformQueryCallback( 309 void PPB_FileIO_Impl::ExecutePlatformQueryCallback(
298 base::PlatformFileError error_code, 310 base::PlatformFileError error_code,
299 const base::PlatformFileInfo& file_info) { 311 const base::PlatformFileInfo& file_info) {
300 PP_FileInfo pp_info; 312 PP_FileInfo pp_info;
301 pp_info.size = file_info.size; 313 pp_info.size = file_info.size;
302 pp_info.creation_time = TimeToPPTime(file_info.creation_time); 314 pp_info.creation_time = TimeToPPTime(file_info.creation_time);
303 pp_info.last_access_time = TimeToPPTime(file_info.last_accessed); 315 pp_info.last_access_time = TimeToPPTime(file_info.last_accessed);
304 pp_info.last_modified_time = TimeToPPTime(file_info.last_modified); 316 pp_info.last_modified_time = TimeToPPTime(file_info.last_modified);
305 pp_info.system_type = file_system_type_; 317 pp_info.system_type = file_system_type_;
306 if (file_info.is_directory) 318 if (file_info.is_directory)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 if (error_code != base::PLATFORM_FILE_OK) { 351 if (error_code != base::PLATFORM_FILE_OK) {
340 RunAndRemoveFirstPendingCallback( 352 RunAndRemoveFirstPendingCallback(
341 ::ppapi::PlatformFileErrorToPepperError(error_code)); 353 ::ppapi::PlatformFileErrorToPepperError(error_code));
342 } else { 354 } else {
343 RunAndRemoveFirstPendingCallback(bytes_written); 355 RunAndRemoveFirstPendingCallback(bytes_written);
344 } 356 }
345 } 357 }
346 358
347 } // namespace ppapi 359 } // namespace ppapi
348 } // namespace webkit 360 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_file_io_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698