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

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

Issue 8231004: Remaining cleanup (base::Bind): Replacing FileUtilProxy calls with new callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years, 2 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 "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/file_util.h" 9 #include "base/file_util.h"
10 #include "base/file_util_proxy.h" 10 #include "base/file_util_proxy.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 PPB_FileIO_Impl::CallbackEntry::CallbackEntry(const CallbackEntry& entry) 44 PPB_FileIO_Impl::CallbackEntry::CallbackEntry(const CallbackEntry& entry)
45 : callback(entry.callback), 45 : callback(entry.callback),
46 read_buffer(entry.read_buffer) { 46 read_buffer(entry.read_buffer) {
47 } 47 }
48 48
49 PPB_FileIO_Impl::CallbackEntry::~CallbackEntry() { 49 PPB_FileIO_Impl::CallbackEntry::~CallbackEntry() {
50 } 50 }
51 51
52 PPB_FileIO_Impl::PPB_FileIO_Impl(PP_Instance instance) 52 PPB_FileIO_Impl::PPB_FileIO_Impl(PP_Instance instance)
53 : Resource(instance), 53 : Resource(instance),
54 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
55 file_(base::kInvalidPlatformFileValue), 54 file_(base::kInvalidPlatformFileValue),
56 file_system_type_(PP_FILESYSTEMTYPE_INVALID), 55 file_system_type_(PP_FILESYSTEMTYPE_INVALID),
57 pending_op_(OPERATION_NONE), 56 pending_op_(OPERATION_NONE),
58 info_(NULL), 57 info_(NULL),
59 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 58 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
60 } 59 }
61 60
62 PPB_FileIO_Impl::~PPB_FileIO_Impl() { 61 PPB_FileIO_Impl::~PPB_FileIO_Impl() {
63 Close(); 62 Close();
64 } 63 }
65 64
66 PPB_FileIO_API* PPB_FileIO_Impl::AsPPB_FileIO_API() { 65 PPB_FileIO_API* PPB_FileIO_Impl::AsPPB_FileIO_API() {
67 return this; 66 return this;
68 } 67 }
69 68
(...skipping 21 matching lines...) Expand all
91 if (file_system_type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT && 90 if (file_system_type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
92 file_system_type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY && 91 file_system_type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY &&
93 file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) 92 file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL)
94 return PP_ERROR_FAILED; 93 return PP_ERROR_FAILED;
95 94
96 if (file_ref->HasValidFileSystem()) { 95 if (file_ref->HasValidFileSystem()) {
97 file_system_url_ = file_ref->GetFileSystemURL(); 96 file_system_url_ = file_ref->GetFileSystemURL();
98 if (!plugin_delegate->AsyncOpenFileSystemURL( 97 if (!plugin_delegate->AsyncOpenFileSystemURL(
99 file_system_url_, flags, 98 file_system_url_, flags,
100 base::Bind(&PPB_FileIO_Impl::AsyncOpenFileCallback, 99 base::Bind(&PPB_FileIO_Impl::AsyncOpenFileCallback,
101 weak_ptr_factory_.GetWeakPtr()))) 100 weak_factory_.GetWeakPtr())))
102 return PP_ERROR_FAILED; 101 return PP_ERROR_FAILED;
103 } else { 102 } else {
104 if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL) 103 if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL)
105 return PP_ERROR_FAILED; 104 return PP_ERROR_FAILED;
106 if (!plugin_delegate->AsyncOpenFile( 105 if (!plugin_delegate->AsyncOpenFile(
107 file_ref->GetSystemPath(), flags, 106 file_ref->GetSystemPath(), flags,
108 base::Bind(&PPB_FileIO_Impl::AsyncOpenFileCallback, 107 base::Bind(&PPB_FileIO_Impl::AsyncOpenFileCallback,
109 weak_ptr_factory_.GetWeakPtr()))) 108 weak_factory_.GetWeakPtr())))
110 return PP_ERROR_FAILED; 109 return PP_ERROR_FAILED;
111 } 110 }
112 111
113 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); 112 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL);
114 return PP_OK_COMPLETIONPENDING; 113 return PP_OK_COMPLETIONPENDING;
115 } 114 }
116 115
117 int32_t PPB_FileIO_Impl::Query(PP_FileInfo* info, 116 int32_t PPB_FileIO_Impl::Query(PP_FileInfo* info,
118 PP_CompletionCallback callback) { 117 PP_CompletionCallback callback) {
119 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); 118 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback);
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 if (error_code != base::PLATFORM_FILE_OK) { 480 if (error_code != base::PLATFORM_FILE_OK) {
482 RunAndRemoveFirstPendingCallback( 481 RunAndRemoveFirstPendingCallback(
483 PlatformFileErrorToPepperError(error_code)); 482 PlatformFileErrorToPepperError(error_code));
484 } else { 483 } else {
485 RunAndRemoveFirstPendingCallback(bytes_written); 484 RunAndRemoveFirstPendingCallback(bytes_written);
486 } 485 }
487 } 486 }
488 487
489 } // namespace ppapi 488 } // namespace ppapi
490 } // namespace webkit 489 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698