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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_FAKE_DRIVE_SERVICE_HELPER_H_ 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_FAKE_DRIVE_SERVICE_HELPER_H_ 7 8 #include <string> 9 10 #include "base/files/scoped_temp_dir.h" 11 #include "chrome/browser/drive/drive_uploader.h" 12 #include "chrome/browser/drive/fake_drive_service.h" 13 #include "google_apis/drive/gdata_wapi_parser.h" 14 15 namespace base { 16 class FilePath; 17 } 18 19 namespace sync_file_system { 20 namespace drive_backend { 21 22 class FakeDriveServiceHelper { 23 public: 24 FakeDriveServiceHelper(drive::FakeDriveService* fake_drive_service, 25 drive::DriveUploaderInterface* drive_uploader); 26 virtual ~FakeDriveServiceHelper(); 27 28 google_apis::GDataErrorCode AddOrphanedFolder( 29 const std::string& title, 30 std::string* folder_id); 31 google_apis::GDataErrorCode AddFolder( 32 const std::string& parent_folder_id, 33 const std::string& title, 34 std::string* folder_id); 35 google_apis::GDataErrorCode AddFile( 36 const std::string& parent_folder_id, 37 const std::string& title, 38 const std::string& content, 39 std::string* file_id); 40 google_apis::GDataErrorCode UpdateFile( 41 const std::string& file_id, 42 const std::string& content); 43 google_apis::GDataErrorCode DeleteResource( 44 const std::string& file_id); 45 google_apis::GDataErrorCode TrashResource( 46 const std::string& file_id); 47 google_apis::GDataErrorCode GetSyncRootFolderID( 48 std::string* sync_root_folder_id); 49 google_apis::GDataErrorCode ListFilesInFolder( 50 const std::string& folder_id, 51 ScopedVector<google_apis::ResourceEntry>* entries); 52 google_apis::GDataErrorCode SearchByTitle( 53 const std::string& folder_id, 54 const std::string& title, 55 ScopedVector<google_apis::ResourceEntry>* entries); 56 google_apis::GDataErrorCode GetResourceEntry( 57 const std::string& file_id, 58 scoped_ptr<google_apis::ResourceEntry>* entry); 59 google_apis::GDataErrorCode ReadFile( 60 const std::string& file_id, 61 std::string* file_content); 62 google_apis::GDataErrorCode GetAboutResource( 63 scoped_ptr<google_apis::AboutResource>* about_resource); 64 65 base::FilePath base_dir_path() { return base_dir_.path(); } 66 67 private: 68 google_apis::GDataErrorCode CompleteListing( 69 scoped_ptr<google_apis::ResourceList> list, 70 ScopedVector<google_apis::ResourceEntry> * entries); 71 72 void Initialize(); 73 74 base::FilePath WriteToTempFile(const std::string& content); 75 76 base::ScopedTempDir base_dir_; 77 base::FilePath temp_dir_; 78 79 // Not own. 80 drive::FakeDriveService* fake_drive_service_; 81 drive::DriveUploaderInterface* drive_uploader_; 82 }; 83 84 } // namespace drive_backend 85 } // namespace sync_file_system 86 87 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_FAKE_DRIVE_SERVICE_HELPER_H_ 88