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

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

Issue 8321014: base::Bind: Convert FileUtilProxy::WriteCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment fixes. 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
« no previous file with comments | « content/common/net/url_fetcher.cc ('k') | webkit/plugins/ppapi/quota_file_io.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 "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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 if (rv != PP_OK) 194 if (rv != PP_OK)
195 return rv; 195 return rv;
196 196
197 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); 197 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
198 if (!plugin_delegate) 198 if (!plugin_delegate)
199 return PP_ERROR_FAILED; 199 return PP_ERROR_FAILED;
200 200
201 if (quota_file_io_.get()) { 201 if (quota_file_io_.get()) {
202 if (!quota_file_io_->Write( 202 if (!quota_file_io_->Write(
203 offset, buffer, bytes_to_write, 203 offset, buffer, bytes_to_write,
204 callback_factory_.NewCallback(&PPB_FileIO_Impl::WriteCallback))) 204 base::Bind(&PPB_FileIO_Impl::WriteCallback,
205 weak_factory_.GetWeakPtr())))
205 return PP_ERROR_FAILED; 206 return PP_ERROR_FAILED;
206 } else { 207 } else {
207 if (!base::FileUtilProxy::Write( 208 if (!base::FileUtilProxy::Write(
208 plugin_delegate->GetFileThreadMessageLoopProxy(), 209 plugin_delegate->GetFileThreadMessageLoopProxy(), file_, offset,
209 file_, offset, buffer, bytes_to_write, 210 buffer, bytes_to_write,
210 callback_factory_.NewCallback(&PPB_FileIO_Impl::WriteCallback))) 211 base::Bind(&PPB_FileIO_Impl::WriteCallback,
212 weak_factory_.GetWeakPtr())))
211 return PP_ERROR_FAILED; 213 return PP_ERROR_FAILED;
212 } 214 }
213 215
214 RegisterCallback(OPERATION_WRITE, callback, NULL); 216 RegisterCallback(OPERATION_WRITE, callback, NULL);
215 return PP_OK_COMPLETIONPENDING; 217 return PP_OK_COMPLETIONPENDING;
216 } 218 }
217 219
218 int32_t PPB_FileIO_Impl::SetLength(int64_t length, 220 int32_t PPB_FileIO_Impl::SetLength(int64_t length,
219 PP_CompletionCallback callback) { 221 PP_CompletionCallback callback) {
220 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); 222 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 PP_CompletionCallback callback) { 287 PP_CompletionCallback callback) {
286 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); 288 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback);
287 if (rv != PP_OK) 289 if (rv != PP_OK)
288 return rv; 290 return rv;
289 291
290 if (!quota_file_io_.get()) 292 if (!quota_file_io_.get())
291 return PP_OK; 293 return PP_OK;
292 294
293 if (!quota_file_io_->WillWrite( 295 if (!quota_file_io_->WillWrite(
294 offset, bytes_to_write, 296 offset, bytes_to_write,
295 callback_factory_.NewCallback(&PPB_FileIO_Impl::WillWriteCallback))) 297 base::Bind(&PPB_FileIO_Impl::WillWriteCallback,
298 weak_factory_.GetWeakPtr())))
296 return PP_ERROR_FAILED; 299 return PP_ERROR_FAILED;
297 300
298 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL); 301 RegisterCallback(OPERATION_EXCLUSIVE, callback, NULL);
299 return PP_OK_COMPLETIONPENDING; 302 return PP_OK_COMPLETIONPENDING;
300 } 303 }
301 304
302 int32_t PPB_FileIO_Impl::WillSetLength(int64_t length, 305 int32_t PPB_FileIO_Impl::WillSetLength(int64_t length,
303 PP_CompletionCallback callback) { 306 PP_CompletionCallback callback) {
304 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback); 307 int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback);
305 if (rv != PP_OK) 308 if (rv != PP_OK)
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if (error_code != base::PLATFORM_FILE_OK) { 477 if (error_code != base::PLATFORM_FILE_OK) {
475 RunAndRemoveFirstPendingCallback( 478 RunAndRemoveFirstPendingCallback(
476 PlatformFileErrorToPepperError(error_code)); 479 PlatformFileErrorToPepperError(error_code));
477 } else { 480 } else {
478 RunAndRemoveFirstPendingCallback(bytes_written); 481 RunAndRemoveFirstPendingCallback(bytes_written);
479 } 482 }
480 } 483 }
481 484
482 } // namespace ppapi 485 } // namespace ppapi
483 } // namespace webkit 486 } // namespace webkit
OLDNEW
« no previous file with comments | « content/common/net/url_fetcher.cc ('k') | webkit/plugins/ppapi/quota_file_io.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698