| 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/sync_file_system_backend.h" | 5 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 152 } |
| 153 | 153 |
| 154 storage::FileSystemOperation* SyncFileSystemBackend::CreateFileSystemOperation( | 154 storage::FileSystemOperation* SyncFileSystemBackend::CreateFileSystemOperation( |
| 155 const storage::FileSystemURL& url, | 155 const storage::FileSystemURL& url, |
| 156 storage::FileSystemContext* context, | 156 storage::FileSystemContext* context, |
| 157 base::File::Error* error_code) const { | 157 base::File::Error* error_code) const { |
| 158 DCHECK(CanHandleType(url.type())); | 158 DCHECK(CanHandleType(url.type())); |
| 159 DCHECK(context); | 159 DCHECK(context); |
| 160 DCHECK(error_code); | 160 DCHECK(error_code); |
| 161 | 161 |
| 162 scoped_ptr<storage::FileSystemOperationContext> operation_context = | 162 std::unique_ptr<storage::FileSystemOperationContext> operation_context = |
| 163 GetDelegate()->CreateFileSystemOperationContext(url, context, error_code); | 163 GetDelegate()->CreateFileSystemOperationContext(url, context, error_code); |
| 164 if (!operation_context) | 164 if (!operation_context) |
| 165 return nullptr; | 165 return nullptr; |
| 166 | 166 |
| 167 if (url.type() == storage::kFileSystemTypeSyncableForInternalSync) { | 167 if (url.type() == storage::kFileSystemTypeSyncableForInternalSync) { |
| 168 return storage::FileSystemOperation::Create(url, context, | 168 return storage::FileSystemOperation::Create(url, context, |
| 169 std::move(operation_context)); | 169 std::move(operation_context)); |
| 170 } | 170 } |
| 171 | 171 |
| 172 return new SyncableFileSystemOperation(url, context, | 172 return new SyncableFileSystemOperation(url, context, |
| 173 std::move(operation_context)); | 173 std::move(operation_context)); |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool SyncFileSystemBackend::SupportsStreaming( | 176 bool SyncFileSystemBackend::SupportsStreaming( |
| 177 const storage::FileSystemURL& url) const { | 177 const storage::FileSystemURL& url) const { |
| 178 return false; | 178 return false; |
| 179 } | 179 } |
| 180 | 180 |
| 181 bool SyncFileSystemBackend::HasInplaceCopyImplementation( | 181 bool SyncFileSystemBackend::HasInplaceCopyImplementation( |
| 182 storage::FileSystemType type) const { | 182 storage::FileSystemType type) const { |
| 183 return false; | 183 return false; |
| 184 } | 184 } |
| 185 | 185 |
| 186 scoped_ptr<storage::FileStreamReader> | 186 std::unique_ptr<storage::FileStreamReader> |
| 187 SyncFileSystemBackend::CreateFileStreamReader( | 187 SyncFileSystemBackend::CreateFileStreamReader( |
| 188 const storage::FileSystemURL& url, | 188 const storage::FileSystemURL& url, |
| 189 int64_t offset, | 189 int64_t offset, |
| 190 int64_t max_bytes_to_read, | 190 int64_t max_bytes_to_read, |
| 191 const base::Time& expected_modification_time, | 191 const base::Time& expected_modification_time, |
| 192 storage::FileSystemContext* context) const { | 192 storage::FileSystemContext* context) const { |
| 193 DCHECK(CanHandleType(url.type())); | 193 DCHECK(CanHandleType(url.type())); |
| 194 return GetDelegate()->CreateFileStreamReader( | 194 return GetDelegate()->CreateFileStreamReader( |
| 195 url, offset, expected_modification_time, context); | 195 url, offset, expected_modification_time, context); |
| 196 } | 196 } |
| 197 | 197 |
| 198 scoped_ptr<storage::FileStreamWriter> | 198 std::unique_ptr<storage::FileStreamWriter> |
| 199 SyncFileSystemBackend::CreateFileStreamWriter( | 199 SyncFileSystemBackend::CreateFileStreamWriter( |
| 200 const storage::FileSystemURL& url, | 200 const storage::FileSystemURL& url, |
| 201 int64_t offset, | 201 int64_t offset, |
| 202 storage::FileSystemContext* context) const { | 202 storage::FileSystemContext* context) const { |
| 203 DCHECK(CanHandleType(url.type())); | 203 DCHECK(CanHandleType(url.type())); |
| 204 return GetDelegate()->CreateFileStreamWriter( | 204 return GetDelegate()->CreateFileStreamWriter( |
| 205 url, offset, context, storage::kFileSystemTypeSyncableForInternalSync); | 205 url, offset, context, storage::kFileSystemTypeSyncableForInternalSync); |
| 206 } | 206 } |
| 207 | 207 |
| 208 storage::FileSystemQuotaUtil* SyncFileSystemBackend::GetQuotaUtil() { | 208 storage::FileSystemQuotaUtil* SyncFileSystemBackend::GetQuotaUtil() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 227 // static | 227 // static |
| 228 SyncFileSystemBackend* SyncFileSystemBackend::GetBackend( | 228 SyncFileSystemBackend* SyncFileSystemBackend::GetBackend( |
| 229 const storage::FileSystemContext* file_system_context) { | 229 const storage::FileSystemContext* file_system_context) { |
| 230 DCHECK(file_system_context); | 230 DCHECK(file_system_context); |
| 231 return static_cast<SyncFileSystemBackend*>( | 231 return static_cast<SyncFileSystemBackend*>( |
| 232 file_system_context->GetFileSystemBackend( | 232 file_system_context->GetFileSystemBackend( |
| 233 storage::kFileSystemTypeSyncable)); | 233 storage::kFileSystemTypeSyncable)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void SyncFileSystemBackend::SetLocalFileChangeTracker( | 236 void SyncFileSystemBackend::SetLocalFileChangeTracker( |
| 237 scoped_ptr<LocalFileChangeTracker> tracker) { | 237 std::unique_ptr<LocalFileChangeTracker> tracker) { |
| 238 DCHECK(!change_tracker_); | 238 DCHECK(!change_tracker_); |
| 239 DCHECK(tracker); | 239 DCHECK(tracker); |
| 240 change_tracker_ = std::move(tracker); | 240 change_tracker_ = std::move(tracker); |
| 241 | 241 |
| 242 storage::SandboxFileSystemBackendDelegate* delegate = GetDelegate(); | 242 storage::SandboxFileSystemBackendDelegate* delegate = GetDelegate(); |
| 243 delegate->AddFileUpdateObserver(storage::kFileSystemTypeSyncable, | 243 delegate->AddFileUpdateObserver(storage::kFileSystemTypeSyncable, |
| 244 change_tracker_.get(), | 244 change_tracker_.get(), |
| 245 delegate->file_task_runner()); | 245 delegate->file_task_runner()); |
| 246 delegate->AddFileChangeObserver(storage::kFileSystemTypeSyncable, | 246 delegate->AddFileChangeObserver(storage::kFileSystemTypeSyncable, |
| 247 change_tracker_.get(), | 247 change_tracker_.get(), |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 SyncStatusCodeToFileError(status)); | 311 SyncStatusCodeToFileError(status)); |
| 312 return; | 312 return; |
| 313 } | 313 } |
| 314 | 314 |
| 315 callback.Run(GetSyncableFileSystemRootURI(origin_url), | 315 callback.Run(GetSyncableFileSystemRootURI(origin_url), |
| 316 GetFileSystemName(origin_url, type), | 316 GetFileSystemName(origin_url, type), |
| 317 base::File::FILE_OK); | 317 base::File::FILE_OK); |
| 318 } | 318 } |
| 319 | 319 |
| 320 } // namespace sync_file_system | 320 } // namespace sync_file_system |
| OLD | NEW |