Chromium Code Reviews| Index: webkit/browser/fileapi/file_system_context.cc |
| diff --git a/webkit/browser/fileapi/file_system_context.cc b/webkit/browser/fileapi/file_system_context.cc |
| index 24c505bb8a927d07b4b892768b411f3680c59005..dd8984cbb27f172a44056547e24e80f220ee770e 100644 |
| --- a/webkit/browser/fileapi/file_system_context.cc |
| +++ b/webkit/browser/fileapi/file_system_context.cc |
| @@ -135,6 +135,7 @@ FileSystemContext::FileSystemContext( |
| for (ScopedVector<FileSystemBackend>::const_iterator iter = |
| additional_backends_.begin(); |
| iter != additional_backends_.end(); ++iter) { |
| + (*iter)->Initialize(this); |
| RegisterBackend(*iter); |
|
kinuko
2013/07/23 06:41:51
I'd have another loop for Initialize after this lo
nhiroki
2013/07/24 05:58:47
Done in a separate CL.
|
| } |
| @@ -220,25 +221,34 @@ bool FileSystemContext::IsSandboxFileSystem(FileSystemType type) const { |
| const UpdateObserverList* FileSystemContext::GetUpdateObservers( |
| FileSystemType type) const { |
| - // Currently update observer is only available in SandboxFileSystemBackend |
| - // and TestFileSystemBackend. |
| - // TODO(kinuko): Probably GetUpdateObservers() virtual method should be |
| - // added to FileSystemBackend interface and be called like |
| - // other GetFoo() methods do. |
| + // Currently update observer is only available in SandboxFileSystemBackend, |
| + // SyncFileSystemBackend and TestFileSystemBackend. |
| if (sandbox_backend_->CanHandleType(type)) |
| return sandbox_backend_->GetUpdateObservers(type); |
| - if (type != kFileSystemTypeTest) |
| - return NULL; |
| FileSystemBackend* backend = GetFileSystemBackend(type); |
| - return static_cast<TestFileSystemBackend*>( |
| - backend)->GetUpdateObservers(type); |
| + if (type == kFileSystemTypeSyncable || |
| + type == kFileSystemTypeSyncableForInternalSync) { |
| + return static_cast<SandboxFileSystemBackend*>( |
| + backend)->GetUpdateObservers(type); |
| + } |
| + if (type == kFileSystemTypeTest) { |
| + return static_cast<TestFileSystemBackend*>( |
| + backend)->GetUpdateObservers(type); |
| + } |
|
kinuko
2013/07/23 06:41:51
Can't this be simply written like:
if (backend->G
nhiroki
2013/07/24 05:58:47
Done.
|
| + return NULL; |
| } |
| const AccessObserverList* FileSystemContext::GetAccessObservers( |
| FileSystemType type) const { |
| - // Currently access observer is only available in SandboxFileSystemBackend. |
| + // Currently access observer is only available in SandboxFileSystemBackend and |
| + // SyncFileSystemBackend. |
| if (sandbox_backend_->CanHandleType(type)) |
| return sandbox_backend_->GetAccessObservers(type); |
| + if (type == kFileSystemTypeSyncable || |
| + type == kFileSystemTypeSyncableForInternalSync) { |
| + return static_cast<SandboxFileSystemBackend*>( |
| + GetFileSystemBackend(type))->GetAccessObservers(type); |
| + } |
|
kinuko
2013/07/23 06:41:51
ditto
nhiroki
2013/07/24 05:58:47
Done.
|
| return NULL; |
| } |
| @@ -326,21 +336,28 @@ scoped_ptr<FileStreamWriter> FileSystemContext::CreateFileStreamWriter( |
| return backend->CreateFileStreamWriter(url, offset, this); |
| } |
| +// TODO(nhiroki): Move into SyncFileSystemBackend (http://crbug.com/242422). |
| void FileSystemContext::SetLocalFileChangeTracker( |
| scoped_ptr<sync_file_system::LocalFileChangeTracker> tracker) { |
| DCHECK(!change_tracker_.get()); |
| DCHECK(tracker.get()); |
| change_tracker_ = tracker.Pass(); |
| - sandbox_backend_->AddFileUpdateObserver( |
| + |
| + SandboxFileSystemBackend* backend = |
| + static_cast<SandboxFileSystemBackend*>( |
| + GetFileSystemBackend(kFileSystemTypeSyncable)); |
| + |
| + backend->AddFileUpdateObserver( |
| kFileSystemTypeSyncable, |
| change_tracker_.get(), |
| task_runners_->file_task_runner()); |
| - sandbox_backend_->AddFileChangeObserver( |
| + backend->AddFileChangeObserver( |
| kFileSystemTypeSyncable, |
| change_tracker_.get(), |
| task_runners_->file_task_runner()); |
| } |
| +// TODO(nhiroki): Move into SyncFileSystemBackend (http://crbug.com/242422). |
| void FileSystemContext::set_sync_context( |
| sync_file_system::LocalFileSyncContext* sync_context) { |
| sync_context_ = sync_context; |