| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/drive_backend/fake_drive_service_helpe
r.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/fake_drive_service_helpe
r.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 11 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
| 12 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" | 14 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" |
| 13 #include "chrome/browser/sync_file_system/sync_status_code.h" | 15 #include "chrome/browser/sync_file_system/sync_status_code.h" |
| 14 #include "google_apis/drive/drive_api_parser.h" | 16 #include "google_apis/drive/drive_api_parser.h" |
| 15 #include "storage/browser/fileapi/file_system_url.h" | 17 #include "storage/browser/fileapi/file_system_url.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 28 namespace { | 30 namespace { |
| 29 | 31 |
| 30 void UploadResultCallback(DriveApiErrorCode* error_out, | 32 void UploadResultCallback(DriveApiErrorCode* error_out, |
| 31 scoped_ptr<FileResource>* entry_out, | 33 scoped_ptr<FileResource>* entry_out, |
| 32 DriveApiErrorCode error, | 34 DriveApiErrorCode error, |
| 33 const GURL& upload_location, | 35 const GURL& upload_location, |
| 34 scoped_ptr<FileResource> entry) { | 36 scoped_ptr<FileResource> entry) { |
| 35 ASSERT_TRUE(error_out); | 37 ASSERT_TRUE(error_out); |
| 36 ASSERT_TRUE(entry_out); | 38 ASSERT_TRUE(entry_out); |
| 37 *error_out = error; | 39 *error_out = error; |
| 38 *entry_out = entry.Pass(); | 40 *entry_out = std::move(entry); |
| 39 } | 41 } |
| 40 | 42 |
| 41 void DownloadResultCallback(DriveApiErrorCode* error_out, | 43 void DownloadResultCallback(DriveApiErrorCode* error_out, |
| 42 DriveApiErrorCode error, | 44 DriveApiErrorCode error, |
| 43 const base::FilePath& local_file) { | 45 const base::FilePath& local_file) { |
| 44 ASSERT_TRUE(error_out); | 46 ASSERT_TRUE(error_out); |
| 45 *error_out = error; | 47 *error_out = error; |
| 46 } | 48 } |
| 47 | 49 |
| 48 } // namespace | 50 } // namespace |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 ScopedVector<FileResource>* entries) { | 234 ScopedVector<FileResource>* entries) { |
| 233 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; | 235 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; |
| 234 scoped_ptr<FileList> list; | 236 scoped_ptr<FileList> list; |
| 235 fake_drive_service_->GetFileListInDirectory( | 237 fake_drive_service_->GetFileListInDirectory( |
| 236 folder_id, | 238 folder_id, |
| 237 CreateResultReceiver(&error, &list)); | 239 CreateResultReceiver(&error, &list)); |
| 238 base::RunLoop().RunUntilIdle(); | 240 base::RunLoop().RunUntilIdle(); |
| 239 if (error != google_apis::HTTP_SUCCESS) | 241 if (error != google_apis::HTTP_SUCCESS) |
| 240 return error; | 242 return error; |
| 241 | 243 |
| 242 return CompleteListing(list.Pass(), entries); | 244 return CompleteListing(std::move(list), entries); |
| 243 } | 245 } |
| 244 | 246 |
| 245 DriveApiErrorCode FakeDriveServiceHelper::SearchByTitle( | 247 DriveApiErrorCode FakeDriveServiceHelper::SearchByTitle( |
| 246 const std::string& folder_id, | 248 const std::string& folder_id, |
| 247 const std::string& title, | 249 const std::string& title, |
| 248 ScopedVector<FileResource>* entries) { | 250 ScopedVector<FileResource>* entries) { |
| 249 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; | 251 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; |
| 250 scoped_ptr<FileList> list; | 252 scoped_ptr<FileList> list; |
| 251 fake_drive_service_->SearchByTitle( | 253 fake_drive_service_->SearchByTitle( |
| 252 title, folder_id, | 254 title, folder_id, |
| 253 CreateResultReceiver(&error, &list)); | 255 CreateResultReceiver(&error, &list)); |
| 254 base::RunLoop().RunUntilIdle(); | 256 base::RunLoop().RunUntilIdle(); |
| 255 if (error != google_apis::HTTP_SUCCESS) | 257 if (error != google_apis::HTTP_SUCCESS) |
| 256 return error; | 258 return error; |
| 257 | 259 |
| 258 return CompleteListing(list.Pass(), entries); | 260 return CompleteListing(std::move(list), entries); |
| 259 } | 261 } |
| 260 | 262 |
| 261 DriveApiErrorCode FakeDriveServiceHelper::GetFileResource( | 263 DriveApiErrorCode FakeDriveServiceHelper::GetFileResource( |
| 262 const std::string& file_id, | 264 const std::string& file_id, |
| 263 scoped_ptr<FileResource>* entry) { | 265 scoped_ptr<FileResource>* entry) { |
| 264 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; | 266 DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR; |
| 265 fake_drive_service_->GetFileResource( | 267 fake_drive_service_->GetFileResource( |
| 266 file_id, | 268 file_id, |
| 267 CreateResultReceiver(&error, entry)); | 269 CreateResultReceiver(&error, entry)); |
| 268 base::RunLoop().RunUntilIdle(); | 270 base::RunLoop().RunUntilIdle(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 const std::string& content) { | 351 const std::string& content) { |
| 350 base::FilePath temp_file; | 352 base::FilePath temp_file; |
| 351 EXPECT_TRUE(base::CreateTemporaryFileInDir(temp_dir_, &temp_file)); | 353 EXPECT_TRUE(base::CreateTemporaryFileInDir(temp_dir_, &temp_file)); |
| 352 EXPECT_EQ(static_cast<int>(content.size()), | 354 EXPECT_EQ(static_cast<int>(content.size()), |
| 353 base::WriteFile(temp_file, content.data(), content.size())); | 355 base::WriteFile(temp_file, content.data(), content.size())); |
| 354 return temp_file; | 356 return temp_file; |
| 355 } | 357 } |
| 356 | 358 |
| 357 } // namespace drive_backend | 359 } // namespace drive_backend |
| 358 } // namespace sync_file_system | 360 } // namespace sync_file_system |
| OLD | NEW |