 Chromium Code Reviews
 Chromium Code Reviews Issue 16311010:
  Make FileSystemOperation::Write take closure-friendly parameters  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 16311010:
  Make FileSystemOperation::Write take closure-friendly parameters  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/fileapi/syncable/syncable_file_system_operation.h" | 5 #include "webkit/browser/fileapi/syncable/syncable_file_system_operation.h" | 
| 6 | 6 | 
| 7 #include "base/logging.h" | 7 #include "base/logging.h" | 
| 8 #include "net/url_request/url_request_context.h" | |
| 
kinuko
2013/06/12 14:25:08
This one needs to be "net/url_request/url_request.
 | |
| 8 #include "webkit/browser/fileapi/file_system_context.h" | 9 #include "webkit/browser/fileapi/file_system_context.h" | 
| 9 #include "webkit/browser/fileapi/file_system_operation_context.h" | 10 #include "webkit/browser/fileapi/file_system_operation_context.h" | 
| 10 #include "webkit/browser/fileapi/file_system_url.h" | 11 #include "webkit/browser/fileapi/file_system_url.h" | 
| 11 #include "webkit/browser/fileapi/local_file_system_operation.h" | 12 #include "webkit/browser/fileapi/local_file_system_operation.h" | 
| 12 #include "webkit/browser/fileapi/sandbox_mount_point_provider.h" | 13 #include "webkit/browser/fileapi/sandbox_mount_point_provider.h" | 
| 13 #include "webkit/browser/fileapi/syncable/local_file_sync_context.h" | 14 #include "webkit/browser/fileapi/syncable/local_file_sync_context.h" | 
| 14 #include "webkit/browser/fileapi/syncable/syncable_file_operation_runner.h" | 15 #include "webkit/browser/fileapi/syncable/syncable_file_operation_runner.h" | 
| 15 #include "webkit/browser/fileapi/syncable/syncable_file_system_util.h" | 16 #include "webkit/browser/fileapi/syncable/syncable_file_system_util.h" | 
| 16 #include "webkit/common/blob/shareable_file_reference.h" | 17 #include "webkit/common/blob/shareable_file_reference.h" | 
| 17 | 18 | 
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 scoped_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask( | 207 scoped_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask( | 
| 207 AsWeakPtr(), | 208 AsWeakPtr(), | 
| 208 base::Bind(&FileSystemOperation::Remove, | 209 base::Bind(&FileSystemOperation::Remove, | 
| 209 NewOperation()->AsWeakPtr(), | 210 NewOperation()->AsWeakPtr(), | 
| 210 url, recursive, | 211 url, recursive, | 
| 211 base::Bind(&self::DidFinish, AsWeakPtr())))); | 212 base::Bind(&self::DidFinish, AsWeakPtr())))); | 
| 212 operation_runner_->PostOperationTask(task.Pass()); | 213 operation_runner_->PostOperationTask(task.Pass()); | 
| 213 } | 214 } | 
| 214 | 215 | 
| 215 void SyncableFileSystemOperation::Write( | 216 void SyncableFileSystemOperation::Write( | 
| 216 const net::URLRequestContext* url_request_context, | |
| 217 const FileSystemURL& url, | 217 const FileSystemURL& url, | 
| 218 const GURL& blob_url, | 218 scoped_ptr<fileapi::FileWriterDelegate> writer_delegate, | 
| 219 int64 offset, | 219 scoped_ptr<net::URLRequest> blob_request, | 
| 220 const WriteCallback& callback) { | 220 const WriteCallback& callback) { | 
| 221 DCHECK(CalledOnValidThread()); | 221 DCHECK(CalledOnValidThread()); | 
| 222 if (!operation_runner_.get()) { | 222 if (!operation_runner_.get()) { | 
| 223 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, 0, true); | 223 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, 0, true); | 
| 224 return; | 224 return; | 
| 225 } | 225 } | 
| 226 DCHECK(operation_runner_.get()); | 226 DCHECK(operation_runner_.get()); | 
| 227 target_paths_.push_back(url); | 227 target_paths_.push_back(url); | 
| 228 completion_callback_ = base::Bind(&WriteCallbackAdapter, callback); | 228 completion_callback_ = base::Bind(&WriteCallbackAdapter, callback); | 
| 229 scoped_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask( | 229 scoped_ptr<SyncableFileOperationRunner::Task> task(new QueueableTask( | 
| 230 AsWeakPtr(), | 230 AsWeakPtr(), | 
| 231 NewOperation()->GetWriteClosure( | 231 base::Bind(&FileSystemOperation::Write, | 
| 232 url_request_context, url, blob_url, offset, | 232 NewOperation()->AsWeakPtr(), | 
| 233 base::Bind(&self::DidWrite, AsWeakPtr(), callback)))); | 233 url, | 
| 234 base::Passed(&writer_delegate), | |
| 235 base::Passed(&blob_request), | |
| 236 base::Bind(&self::DidWrite, AsWeakPtr(), callback)))); | |
| 234 operation_runner_->PostOperationTask(task.Pass()); | 237 operation_runner_->PostOperationTask(task.Pass()); | 
| 235 } | 238 } | 
| 236 | 239 | 
| 237 void SyncableFileSystemOperation::Truncate( | 240 void SyncableFileSystemOperation::Truncate( | 
| 238 const FileSystemURL& url, int64 length, | 241 const FileSystemURL& url, int64 length, | 
| 239 const StatusCallback& callback) { | 242 const StatusCallback& callback) { | 
| 240 DCHECK(CalledOnValidThread()); | 243 DCHECK(CalledOnValidThread()); | 
| 241 if (!operation_runner_.get()) { | 244 if (!operation_runner_.get()) { | 
| 242 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND); | 245 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND); | 
| 243 return; | 246 return; | 
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 operation_runner_->OnOperationCompleted(target_paths_); | 358 operation_runner_->OnOperationCompleted(target_paths_); | 
| 356 callback.Run(result, bytes, complete); | 359 callback.Run(result, bytes, complete); | 
| 357 } | 360 } | 
| 358 | 361 | 
| 359 void SyncableFileSystemOperation::OnCancelled() { | 362 void SyncableFileSystemOperation::OnCancelled() { | 
| 360 DCHECK(!completion_callback_.is_null()); | 363 DCHECK(!completion_callback_.is_null()); | 
| 361 completion_callback_.Run(base::PLATFORM_FILE_ERROR_ABORT); | 364 completion_callback_.Run(base::PLATFORM_FILE_ERROR_ABORT); | 
| 362 } | 365 } | 
| 363 | 366 | 
| 364 } // namespace sync_file_system | 367 } // namespace sync_file_system | 
| OLD | NEW |