| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/chromeos/drive/fake_file_system.h" | 5 #include "chrome/browser/chromeos/drive/fake_file_system.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 weak_ptr_factory_.GetWeakPtr(), | 264 weak_ptr_factory_.GetWeakPtr(), |
| 265 initialized_callback, | 265 initialized_callback, |
| 266 get_content_callback, | 266 get_content_callback, |
| 267 completion_callback)); | 267 completion_callback)); |
| 268 } | 268 } |
| 269 | 269 |
| 270 void FakeFileSystem::GetFileContentAfterGetFileResource( | 270 void FakeFileSystem::GetFileContentAfterGetFileResource( |
| 271 const GetFileContentInitializedCallback& initialized_callback, | 271 const GetFileContentInitializedCallback& initialized_callback, |
| 272 const google_apis::GetContentCallback& get_content_callback, | 272 const google_apis::GetContentCallback& get_content_callback, |
| 273 const FileOperationCallback& completion_callback, | 273 const FileOperationCallback& completion_callback, |
| 274 google_apis::GDataErrorCode gdata_error, | 274 google_apis::DriveApiErrorCode gdata_error, |
| 275 scoped_ptr<google_apis::FileResource> gdata_entry) { | 275 scoped_ptr<google_apis::FileResource> gdata_entry) { |
| 276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 277 | 277 |
| 278 FileError error = GDataToFileError(gdata_error); | 278 FileError error = GDataToFileError(gdata_error); |
| 279 if (error != FILE_ERROR_OK) { | 279 if (error != FILE_ERROR_OK) { |
| 280 completion_callback.Run(error); | 280 completion_callback.Run(error); |
| 281 return; | 281 return; |
| 282 } | 282 } |
| 283 DCHECK(gdata_entry); | 283 DCHECK(gdata_entry); |
| 284 | 284 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 309 gdata_entry->file_id(), | 309 gdata_entry->file_id(), |
| 310 base::Bind(&FakeFileSystem::GetFileContentAfterDownloadFile, | 310 base::Bind(&FakeFileSystem::GetFileContentAfterDownloadFile, |
| 311 weak_ptr_factory_.GetWeakPtr(), | 311 weak_ptr_factory_.GetWeakPtr(), |
| 312 completion_callback), | 312 completion_callback), |
| 313 get_content_callback, | 313 get_content_callback, |
| 314 google_apis::ProgressCallback()); | 314 google_apis::ProgressCallback()); |
| 315 } | 315 } |
| 316 | 316 |
| 317 void FakeFileSystem::GetFileContentAfterDownloadFile( | 317 void FakeFileSystem::GetFileContentAfterDownloadFile( |
| 318 const FileOperationCallback& completion_callback, | 318 const FileOperationCallback& completion_callback, |
| 319 google_apis::GDataErrorCode gdata_error, | 319 google_apis::DriveApiErrorCode gdata_error, |
| 320 const base::FilePath& temp_file) { | 320 const base::FilePath& temp_file) { |
| 321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 322 completion_callback.Run(GDataToFileError(gdata_error)); | 322 completion_callback.Run(GDataToFileError(gdata_error)); |
| 323 } | 323 } |
| 324 | 324 |
| 325 // Implementation of GetResourceEntry. | 325 // Implementation of GetResourceEntry. |
| 326 void FakeFileSystem::GetResourceEntryAfterGetAboutResource( | 326 void FakeFileSystem::GetResourceEntryAfterGetAboutResource( |
| 327 const GetResourceEntryCallback& callback, | 327 const GetResourceEntryCallback& callback, |
| 328 google_apis::GDataErrorCode gdata_error, | 328 google_apis::DriveApiErrorCode gdata_error, |
| 329 scoped_ptr<google_apis::AboutResource> about_resource) { | 329 scoped_ptr<google_apis::AboutResource> about_resource) { |
| 330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 330 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 331 | 331 |
| 332 FileError error = GDataToFileError(gdata_error); | 332 FileError error = GDataToFileError(gdata_error); |
| 333 if (error != FILE_ERROR_OK) { | 333 if (error != FILE_ERROR_OK) { |
| 334 callback.Run(error, scoped_ptr<ResourceEntry>()); | 334 callback.Run(error, scoped_ptr<ResourceEntry>()); |
| 335 return; | 335 return; |
| 336 } | 336 } |
| 337 | 337 |
| 338 DCHECK(about_resource); | 338 DCHECK(about_resource); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 359 drive_service_->GetFileListInDirectory( | 359 drive_service_->GetFileListInDirectory( |
| 360 parent_entry->resource_id(), | 360 parent_entry->resource_id(), |
| 361 base::Bind( | 361 base::Bind( |
| 362 &FakeFileSystem::GetResourceEntryAfterGetFileList, | 362 &FakeFileSystem::GetResourceEntryAfterGetFileList, |
| 363 weak_ptr_factory_.GetWeakPtr(), base_name, callback)); | 363 weak_ptr_factory_.GetWeakPtr(), base_name, callback)); |
| 364 } | 364 } |
| 365 | 365 |
| 366 void FakeFileSystem::GetResourceEntryAfterGetFileList( | 366 void FakeFileSystem::GetResourceEntryAfterGetFileList( |
| 367 const base::FilePath& base_name, | 367 const base::FilePath& base_name, |
| 368 const GetResourceEntryCallback& callback, | 368 const GetResourceEntryCallback& callback, |
| 369 google_apis::GDataErrorCode gdata_error, | 369 google_apis::DriveApiErrorCode gdata_error, |
| 370 scoped_ptr<google_apis::FileList> file_list) { | 370 scoped_ptr<google_apis::FileList> file_list) { |
| 371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 372 | 372 |
| 373 FileError error = GDataToFileError(gdata_error); | 373 FileError error = GDataToFileError(gdata_error); |
| 374 if (error != FILE_ERROR_OK) { | 374 if (error != FILE_ERROR_OK) { |
| 375 callback.Run(error, scoped_ptr<ResourceEntry>()); | 375 callback.Run(error, scoped_ptr<ResourceEntry>()); |
| 376 return; | 376 return; |
| 377 } | 377 } |
| 378 | 378 |
| 379 DCHECK(file_list); | 379 DCHECK(file_list); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 391 callback.Run(FILE_ERROR_OK, entry.Pass()); | 391 callback.Run(FILE_ERROR_OK, entry.Pass()); |
| 392 return; | 392 return; |
| 393 } | 393 } |
| 394 } | 394 } |
| 395 | 395 |
| 396 callback.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<ResourceEntry>()); | 396 callback.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<ResourceEntry>()); |
| 397 } | 397 } |
| 398 | 398 |
| 399 } // namespace test_util | 399 } // namespace test_util |
| 400 } // namespace drive | 400 } // namespace drive |
| OLD | NEW |