| 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 "storage/browser/fileapi/file_system_context.h" |
| 14 #include "webkit/browser/fileapi/file_system_operation.h" | 14 #include "storage/browser/fileapi/file_system_operation.h" |
| 15 #include "webkit/browser/fileapi/file_system_operation_context.h" | 15 #include "storage/browser/fileapi/file_system_operation_context.h" |
| 16 #include "webkit/browser/fileapi/file_system_url.h" | 16 #include "storage/browser/fileapi/file_system_url.h" |
| 17 #include "webkit/browser/fileapi/file_writer_delegate.h" | 17 #include "storage/browser/fileapi/file_writer_delegate.h" |
| 18 #include "webkit/common/blob/shareable_file_reference.h" | 18 #include "storage/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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 weak_factory_.GetWeakPtr(), | 212 weak_factory_.GetWeakPtr(), |
| 213 base::Bind(&FileSystemOperation::Remove, | 213 base::Bind(&FileSystemOperation::Remove, |
| 214 base::Unretained(impl_.get()), | 214 base::Unretained(impl_.get()), |
| 215 url, recursive, | 215 url, recursive, |
| 216 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr())))); | 216 base::Bind(&self::DidFinish, weak_factory_.GetWeakPtr())))); |
| 217 operation_runner_->PostOperationTask(task.Pass()); | 217 operation_runner_->PostOperationTask(task.Pass()); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void SyncableFileSystemOperation::Write( | 220 void SyncableFileSystemOperation::Write( |
| 221 const FileSystemURL& url, | 221 const FileSystemURL& url, |
| 222 scoped_ptr<fileapi::FileWriterDelegate> writer_delegate, | 222 scoped_ptr<storage::FileWriterDelegate> writer_delegate, |
| 223 scoped_ptr<net::URLRequest> blob_request, | 223 scoped_ptr<net::URLRequest> blob_request, |
| 224 const WriteCallback& callback) { | 224 const WriteCallback& callback) { |
| 225 DCHECK(CalledOnValidThread()); | 225 DCHECK(CalledOnValidThread()); |
| 226 if (!operation_runner_.get()) { | 226 if (!operation_runner_.get()) { |
| 227 callback.Run(base::File::FILE_ERROR_NOT_FOUND, 0, true); | 227 callback.Run(base::File::FILE_ERROR_NOT_FOUND, 0, true); |
| 228 return; | 228 return; |
| 229 } | 229 } |
| 230 DCHECK(operation_runner_.get()); | 230 DCHECK(operation_runner_.get()); |
| 231 target_paths_.push_back(url); | 231 target_paths_.push_back(url); |
| 232 completion_callback_ = base::Bind(&WriteCallbackAdapter, callback); | 232 completion_callback_ = base::Bind(&WriteCallbackAdapter, callback); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 } | 346 } |
| 347 | 347 |
| 348 base::File::Error SyncableFileSystemOperation::SyncGetPlatformPath( | 348 base::File::Error SyncableFileSystemOperation::SyncGetPlatformPath( |
| 349 const FileSystemURL& url, | 349 const FileSystemURL& url, |
| 350 base::FilePath* platform_path) { | 350 base::FilePath* platform_path) { |
| 351 return impl_->SyncGetPlatformPath(url, platform_path); | 351 return impl_->SyncGetPlatformPath(url, platform_path); |
| 352 } | 352 } |
| 353 | 353 |
| 354 SyncableFileSystemOperation::SyncableFileSystemOperation( | 354 SyncableFileSystemOperation::SyncableFileSystemOperation( |
| 355 const FileSystemURL& url, | 355 const FileSystemURL& url, |
| 356 fileapi::FileSystemContext* file_system_context, | 356 storage::FileSystemContext* file_system_context, |
| 357 scoped_ptr<fileapi::FileSystemOperationContext> operation_context) | 357 scoped_ptr<storage::FileSystemOperationContext> operation_context) |
| 358 : url_(url), | 358 : url_(url), weak_factory_(this) { |
| 359 weak_factory_(this) { | |
| 360 DCHECK(file_system_context); | 359 DCHECK(file_system_context); |
| 361 SyncFileSystemBackend* backend = | 360 SyncFileSystemBackend* backend = |
| 362 SyncFileSystemBackend::GetBackend(file_system_context); | 361 SyncFileSystemBackend::GetBackend(file_system_context); |
| 363 DCHECK(backend); | 362 DCHECK(backend); |
| 364 if (!backend->sync_context()) { | 363 if (!backend->sync_context()) { |
| 365 // Syncable FileSystem is opened in a file system context which doesn't | 364 // Syncable FileSystem is opened in a file system context which doesn't |
| 366 // support (or is not initialized for) the API. | 365 // support (or is not initialized for) the API. |
| 367 // Returning here to leave operation_runner_ as NULL. | 366 // Returning here to leave operation_runner_ as NULL. |
| 368 return; | 367 return; |
| 369 } | 368 } |
| 370 impl_.reset(fileapi::FileSystemOperation::Create( | 369 impl_.reset(storage::FileSystemOperation::Create( |
| 371 url_, file_system_context, operation_context.Pass())); | 370 url_, file_system_context, operation_context.Pass())); |
| 372 operation_runner_ = backend->sync_context()->operation_runner(); | 371 operation_runner_ = backend->sync_context()->operation_runner(); |
| 373 is_directory_operation_enabled_ = IsV2EnabledForOrigin(url.origin()); | 372 is_directory_operation_enabled_ = IsV2EnabledForOrigin(url.origin()); |
| 374 } | 373 } |
| 375 | 374 |
| 376 void SyncableFileSystemOperation::DidFinish(base::File::Error status) { | 375 void SyncableFileSystemOperation::DidFinish(base::File::Error status) { |
| 377 DCHECK(CalledOnValidThread()); | 376 DCHECK(CalledOnValidThread()); |
| 378 DCHECK(!completion_callback_.is_null()); | 377 DCHECK(!completion_callback_.is_null()); |
| 379 if (operation_runner_.get()) | 378 if (operation_runner_.get()) |
| 380 operation_runner_->OnOperationCompleted(target_paths_); | 379 operation_runner_->OnOperationCompleted(target_paths_); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 395 operation_runner_->OnOperationCompleted(target_paths_); | 394 operation_runner_->OnOperationCompleted(target_paths_); |
| 396 callback.Run(result, bytes, complete); | 395 callback.Run(result, bytes, complete); |
| 397 } | 396 } |
| 398 | 397 |
| 399 void SyncableFileSystemOperation::OnCancelled() { | 398 void SyncableFileSystemOperation::OnCancelled() { |
| 400 DCHECK(!completion_callback_.is_null()); | 399 DCHECK(!completion_callback_.is_null()); |
| 401 completion_callback_.Run(base::File::FILE_ERROR_ABORT); | 400 completion_callback_.Run(base::File::FILE_ERROR_ABORT); |
| 402 } | 401 } |
| 403 | 402 |
| 404 } // namespace sync_file_system | 403 } // namespace sync_file_system |
| OLD | NEW |