| 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.h" | 8 #include "net/url_request/url_request.h" |
| 9 #include "webkit/browser/fileapi/file_system_context.h" | 9 #include "webkit/browser/fileapi/file_system_context.h" |
| 10 #include "webkit/browser/fileapi/file_system_operation_context.h" | 10 #include "webkit/browser/fileapi/file_system_operation_context.h" |
| 11 #include "webkit/browser/fileapi/file_system_url.h" | 11 #include "webkit/browser/fileapi/file_system_url.h" |
| 12 #include "webkit/browser/fileapi/local_file_system_operation.h" | 12 #include "webkit/browser/fileapi/local_file_system_operation.h" |
| 13 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" | 13 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" |
| 14 #include "webkit/browser/fileapi/syncable/local_file_sync_context.h" | 14 #include "webkit/browser/fileapi/syncable/local_file_sync_context.h" |
| 15 #include "webkit/browser/fileapi/syncable/sync_file_system_backend.h" |
| 15 #include "webkit/browser/fileapi/syncable/syncable_file_operation_runner.h" | 16 #include "webkit/browser/fileapi/syncable/syncable_file_operation_runner.h" |
| 16 #include "webkit/browser/fileapi/syncable/syncable_file_system_util.h" | 17 #include "webkit/browser/fileapi/syncable/syncable_file_system_util.h" |
| 17 #include "webkit/common/blob/shareable_file_reference.h" | 18 #include "webkit/common/blob/shareable_file_reference.h" |
| 18 | 19 |
| 19 using fileapi::FileSystemURL; | 20 using fileapi::FileSystemURL; |
| 20 using fileapi::FileSystemOperationContext; | 21 using fileapi::FileSystemOperationContext; |
| 21 using fileapi::LocalFileSystemOperation; | 22 using fileapi::LocalFileSystemOperation; |
| 22 | 23 |
| 23 namespace sync_file_system { | 24 namespace sync_file_system { |
| 24 | 25 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 312 } |
| 312 | 313 |
| 313 SyncableFileSystemOperation::SyncableFileSystemOperation( | 314 SyncableFileSystemOperation::SyncableFileSystemOperation( |
| 314 const FileSystemURL& url, | 315 const FileSystemURL& url, |
| 315 fileapi::FileSystemContext* file_system_context, | 316 fileapi::FileSystemContext* file_system_context, |
| 316 scoped_ptr<FileSystemOperationContext> operation_context) | 317 scoped_ptr<FileSystemOperationContext> operation_context) |
| 317 : LocalFileSystemOperation(url, file_system_context, | 318 : LocalFileSystemOperation(url, file_system_context, |
| 318 operation_context.Pass()), | 319 operation_context.Pass()), |
| 319 url_(url) { | 320 url_(url) { |
| 320 DCHECK(file_system_context); | 321 DCHECK(file_system_context); |
| 321 if (!file_system_context->sync_context()) { | 322 SyncFileSystemBackend* backend = |
| 323 SyncFileSystemBackend::GetBackend(file_system_context); |
| 324 DCHECK(backend); |
| 325 if (!backend->sync_context()) { |
| 322 // Syncable FileSystem is opened in a file system context which doesn't | 326 // Syncable FileSystem is opened in a file system context which doesn't |
| 323 // support (or is not initialized for) the API. | 327 // support (or is not initialized for) the API. |
| 324 // Returning here to leave operation_runner_ as NULL. | 328 // Returning here to leave operation_runner_ as NULL. |
| 325 return; | 329 return; |
| 326 } | 330 } |
| 327 operation_runner_ = file_system_context->sync_context()->operation_runner(); | 331 operation_runner_ = backend->sync_context()->operation_runner(); |
| 328 is_directory_operation_enabled_ = IsSyncFSDirectoryOperationEnabled(); | 332 is_directory_operation_enabled_ = IsSyncFSDirectoryOperationEnabled(); |
| 329 } | 333 } |
| 330 | 334 |
| 331 LocalFileSystemOperation* SyncableFileSystemOperation::NewOperation() { | 335 LocalFileSystemOperation* SyncableFileSystemOperation::NewOperation() { |
| 332 DCHECK(operation_context_); | 336 DCHECK(operation_context_); |
| 333 inflight_operation_.reset(new LocalFileSystemOperation( | 337 inflight_operation_.reset(new LocalFileSystemOperation( |
| 334 url_, file_system_context(), operation_context_.Pass())); | 338 url_, file_system_context(), operation_context_.Pass())); |
| 335 DCHECK(inflight_operation_); | 339 DCHECK(inflight_operation_); |
| 336 return inflight_operation_.get(); | 340 return inflight_operation_.get(); |
| 337 } | 341 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 358 operation_runner_->OnOperationCompleted(target_paths_); | 362 operation_runner_->OnOperationCompleted(target_paths_); |
| 359 callback.Run(result, bytes, complete); | 363 callback.Run(result, bytes, complete); |
| 360 } | 364 } |
| 361 | 365 |
| 362 void SyncableFileSystemOperation::OnCancelled() { | 366 void SyncableFileSystemOperation::OnCancelled() { |
| 363 DCHECK(!completion_callback_.is_null()); | 367 DCHECK(!completion_callback_.is_null()); |
| 364 completion_callback_.Run(base::PLATFORM_FILE_ERROR_ABORT); | 368 completion_callback_.Run(base::PLATFORM_FILE_ERROR_ABORT); |
| 365 } | 369 } |
| 366 | 370 |
| 367 } // namespace sync_file_system | 371 } // namespace sync_file_system |
| OLD | NEW |