| 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 "chrome/browser/sync_file_system/local/syncable_file_system_operation.h
" | 5 #include "chrome/browser/sync_file_system/local/syncable_file_system_operation.h
" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" | 8 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" |
| 9 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | 9 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
| 10 #include "chrome/browser/sync_file_system/local/syncable_file_operation_runner.h
" | 10 #include "chrome/browser/sync_file_system/local/syncable_file_operation_runner.h
" |
| 11 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" | 11 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" |
| 12 #include "net/url_request/url_request.h" | 12 #include "net/url_request/url_request.h" |
| 13 #include "webkit/browser/fileapi/file_system_context.h" | 13 #include "webkit/browser/fileapi/file_system_context.h" |
| 14 #include "webkit/browser/fileapi/file_system_operation.h" | 14 #include "webkit/browser/fileapi/file_system_operation.h" |
| 15 #include "webkit/browser/fileapi/file_system_operation_context.h" | 15 #include "webkit/browser/fileapi/file_system_operation_context.h" |
| 16 #include "webkit/browser/fileapi/file_system_url.h" | 16 #include "webkit/browser/fileapi/file_system_url.h" |
| 17 #include "webkit/browser/fileapi/file_writer_delegate.h" | 17 #include "webkit/browser/fileapi/file_writer_delegate.h" |
| 18 #include "webkit/common/blob/shareable_file_reference.h" | 18 #include "webkit/common/blob/shareable_file_reference.h" |
| 19 | 19 |
| 20 using fileapi::FileSystemURL; | 20 using storage::FileSystemURL; |
| 21 | 21 |
| 22 namespace sync_file_system { | 22 namespace sync_file_system { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 void WriteCallbackAdapter( | 26 void WriteCallbackAdapter( |
| 27 const SyncableFileSystemOperation::WriteCallback& callback, | 27 const SyncableFileSystemOperation::WriteCallback& callback, |
| 28 base::File::Error status) { | 28 base::File::Error status) { |
| 29 callback.Run(status, 0, true); | 29 callback.Run(status, 0, true); |
| 30 } | 30 } |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 weak_factory_.GetWeakPtr(), | 208 weak_factory_.GetWeakPtr(), |
| 209 base::Bind(&FileSystemOperation::Remove, | 209 base::Bind(&FileSystemOperation::Remove, |
| 210 base::Unretained(impl_.get()), | 210 base::Unretained(impl_.get()), |
| 211 url, recursive, | 211 url, recursive, |
| 212 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr())))); | 212 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr())))); |
| 213 operation_runner_->PostOperationTask(task.Pass()); | 213 operation_runner_->PostOperationTask(task.Pass()); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void SyncableFileSystemOperation::Write( | 216 void SyncableFileSystemOperation::Write( |
| 217 const FileSystemURL& url, | 217 const FileSystemURL& url, |
| 218 scoped_ptr<fileapi::FileWriterDelegate> writer_delegate, | 218 scoped_ptr<storage::FileWriterDelegate> writer_delegate, |
| 219 scoped_ptr<net::URLRequest> blob_request, | 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::File::FILE_ERROR_NOT_FOUND, 0, true); | 223 callback.Run(base::File::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); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 342 } |
| 343 | 343 |
| 344 base::File::Error SyncableFileSystemOperation::SyncGetPlatformPath( | 344 base::File::Error SyncableFileSystemOperation::SyncGetPlatformPath( |
| 345 const FileSystemURL& url, | 345 const FileSystemURL& url, |
| 346 base::FilePath* platform_path) { | 346 base::FilePath* platform_path) { |
| 347 return impl_->SyncGetPlatformPath(url, platform_path); | 347 return impl_->SyncGetPlatformPath(url, platform_path); |
| 348 } | 348 } |
| 349 | 349 |
| 350 SyncableFileSystemOperation::SyncableFileSystemOperation( | 350 SyncableFileSystemOperation::SyncableFileSystemOperation( |
| 351 const FileSystemURL& url, | 351 const FileSystemURL& url, |
| 352 fileapi::FileSystemContext* file_system_context, | 352 storage::FileSystemContext* file_system_context, |
| 353 scoped_ptr<fileapi::FileSystemOperationContext> operation_context) | 353 scoped_ptr<storage::FileSystemOperationContext> operation_context) |
| 354 : url_(url), | 354 : url_(url), weak_factory_(this) { |
| 355 weak_factory_(this) { | |
| 356 DCHECK(file_system_context); | 355 DCHECK(file_system_context); |
| 357 SyncFileSystemBackend* backend = | 356 SyncFileSystemBackend* backend = |
| 358 SyncFileSystemBackend::GetBackend(file_system_context); | 357 SyncFileSystemBackend::GetBackend(file_system_context); |
| 359 DCHECK(backend); | 358 DCHECK(backend); |
| 360 if (!backend->sync_context()) { | 359 if (!backend->sync_context()) { |
| 361 // Syncable FileSystem is opened in a file system context which doesn't | 360 // Syncable FileSystem is opened in a file system context which doesn't |
| 362 // support (or is not initialized for) the API. | 361 // support (or is not initialized for) the API. |
| 363 // Returning here to leave operation_runner_ as NULL. | 362 // Returning here to leave operation_runner_ as NULL. |
| 364 return; | 363 return; |
| 365 } | 364 } |
| 366 impl_.reset(fileapi::FileSystemOperation::Create( | 365 impl_.reset(storage::FileSystemOperation::Create( |
| 367 url_, file_system_context, operation_context.Pass())); | 366 url_, file_system_context, operation_context.Pass())); |
| 368 operation_runner_ = backend->sync_context()->operation_runner(); | 367 operation_runner_ = backend->sync_context()->operation_runner(); |
| 369 } | 368 } |
| 370 | 369 |
| 371 void SyncableFileSystemOperation::DidFinish(base::File::Error status) { | 370 void SyncableFileSystemOperation::DidFinish(base::File::Error status) { |
| 372 DCHECK(CalledOnValidThread()); | 371 DCHECK(CalledOnValidThread()); |
| 373 DCHECK(!completion_callback_.is_null()); | 372 DCHECK(!completion_callback_.is_null()); |
| 374 if (operation_runner_.get()) | 373 if (operation_runner_.get()) |
| 375 operation_runner_->OnOperationCompleted(target_paths_); | 374 operation_runner_->OnOperationCompleted(target_paths_); |
| 376 completion_callback_.Run(status); | 375 completion_callback_.Run(status); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 390 operation_runner_->OnOperationCompleted(target_paths_); | 389 operation_runner_->OnOperationCompleted(target_paths_); |
| 391 callback.Run(result, bytes, complete); | 390 callback.Run(result, bytes, complete); |
| 392 } | 391 } |
| 393 | 392 |
| 394 void SyncableFileSystemOperation::OnCancelled() { | 393 void SyncableFileSystemOperation::OnCancelled() { |
| 395 DCHECK(!completion_callback_.is_null()); | 394 DCHECK(!completion_callback_.is_null()); |
| 396 completion_callback_.Run(base::File::FILE_ERROR_ABORT); | 395 completion_callback_.Run(base::File::FILE_ERROR_ABORT); |
| 397 } | 396 } |
| 398 | 397 |
| 399 } // namespace sync_file_system | 398 } // namespace sync_file_system |
| OLD | NEW |