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 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_FAKE_DRIVE_SERVICE_HELPER_
H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_FAKE_DRIVE_SERVICE_HELPER_
H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_FAKE_DRIVE_SERVICE_HELPER_
H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_FAKE_DRIVE_SERVICE_HELPER_
H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "chrome/browser/drive/drive_uploader.h" | 11 #include "chrome/browser/drive/drive_uploader.h" |
12 #include "chrome/browser/drive/fake_drive_service.h" | 12 #include "chrome/browser/drive/fake_drive_service.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class FilePath; | 15 class FilePath; |
16 } | 16 } |
17 | 17 |
18 namespace sync_file_system { | 18 namespace sync_file_system { |
19 namespace drive_backend { | 19 namespace drive_backend { |
20 | 20 |
21 class FakeDriveServiceHelper { | 21 class FakeDriveServiceHelper { |
22 public: | 22 public: |
23 FakeDriveServiceHelper(drive::FakeDriveService* fake_drive_service, | 23 FakeDriveServiceHelper(drive::FakeDriveService* fake_drive_service, |
24 drive::DriveUploaderInterface* drive_uploader, | 24 drive::DriveUploaderInterface* drive_uploader, |
25 const std::string& sync_root_folder_title); | 25 const std::string& sync_root_folder_title); |
26 virtual ~FakeDriveServiceHelper(); | 26 virtual ~FakeDriveServiceHelper(); |
27 | 27 |
28 google_apis::GDataErrorCode AddOrphanedFolder( | 28 google_apis::DriveApiErrorCode AddOrphanedFolder( |
29 const std::string& title, | 29 const std::string& title, |
30 std::string* folder_id); | 30 std::string* folder_id); |
31 google_apis::GDataErrorCode AddFolder( | 31 google_apis::DriveApiErrorCode AddFolder( |
32 const std::string& parent_folder_id, | 32 const std::string& parent_folder_id, |
33 const std::string& title, | 33 const std::string& title, |
34 std::string* folder_id); | 34 std::string* folder_id); |
35 google_apis::GDataErrorCode AddFile( | 35 google_apis::DriveApiErrorCode AddFile( |
36 const std::string& parent_folder_id, | 36 const std::string& parent_folder_id, |
37 const std::string& title, | 37 const std::string& title, |
38 const std::string& content, | 38 const std::string& content, |
39 std::string* file_id); | 39 std::string* file_id); |
40 google_apis::GDataErrorCode UpdateFile( | 40 google_apis::DriveApiErrorCode UpdateFile( |
41 const std::string& file_id, | 41 const std::string& file_id, |
42 const std::string& content); | 42 const std::string& content); |
43 google_apis::GDataErrorCode DeleteResource( | 43 google_apis::DriveApiErrorCode DeleteResource( |
44 const std::string& file_id); | 44 const std::string& file_id); |
45 google_apis::GDataErrorCode TrashResource( | 45 google_apis::DriveApiErrorCode TrashResource( |
46 const std::string& file_id); | 46 const std::string& file_id); |
47 google_apis::GDataErrorCode UpdateModificationTime( | 47 google_apis::DriveApiErrorCode UpdateModificationTime( |
48 const std::string& file_id, | 48 const std::string& file_id, |
49 const base::Time& modification_time); | 49 const base::Time& modification_time); |
50 google_apis::GDataErrorCode RenameResource( | 50 google_apis::DriveApiErrorCode RenameResource( |
51 const std::string& file_id, | 51 const std::string& file_id, |
52 const std::string& new_title); | 52 const std::string& new_title); |
53 google_apis::GDataErrorCode AddResourceToDirectory( | 53 google_apis::DriveApiErrorCode AddResourceToDirectory( |
54 const std::string& parent_folder_id, | 54 const std::string& parent_folder_id, |
55 const std::string& file_id); | 55 const std::string& file_id); |
56 google_apis::GDataErrorCode RemoveResourceFromDirectory( | 56 google_apis::DriveApiErrorCode RemoveResourceFromDirectory( |
57 const std::string& parent_folder_id, | 57 const std::string& parent_folder_id, |
58 const std::string& file_id); | 58 const std::string& file_id); |
59 google_apis::GDataErrorCode GetSyncRootFolderID( | 59 google_apis::DriveApiErrorCode GetSyncRootFolderID( |
60 std::string* sync_root_folder_id); | 60 std::string* sync_root_folder_id); |
61 google_apis::GDataErrorCode ListFilesInFolder( | 61 google_apis::DriveApiErrorCode ListFilesInFolder( |
62 const std::string& folder_id, | 62 const std::string& folder_id, |
63 ScopedVector<google_apis::FileResource>* entries); | 63 ScopedVector<google_apis::FileResource>* entries); |
64 google_apis::GDataErrorCode SearchByTitle( | 64 google_apis::DriveApiErrorCode SearchByTitle( |
65 const std::string& folder_id, | 65 const std::string& folder_id, |
66 const std::string& title, | 66 const std::string& title, |
67 ScopedVector<google_apis::FileResource>* entries); | 67 ScopedVector<google_apis::FileResource>* entries); |
68 | 68 |
69 google_apis::GDataErrorCode GetFileResource( | 69 google_apis::DriveApiErrorCode GetFileResource( |
70 const std::string& file_id, | 70 const std::string& file_id, |
71 scoped_ptr<google_apis::FileResource>* entry); | 71 scoped_ptr<google_apis::FileResource>* entry); |
72 google_apis::GDataErrorCode ReadFile( | 72 google_apis::DriveApiErrorCode ReadFile( |
73 const std::string& file_id, | 73 const std::string& file_id, |
74 std::string* file_content); | 74 std::string* file_content); |
75 google_apis::GDataErrorCode GetAboutResource( | 75 google_apis::DriveApiErrorCode GetAboutResource( |
76 scoped_ptr<google_apis::AboutResource>* about_resource); | 76 scoped_ptr<google_apis::AboutResource>* about_resource); |
77 | 77 |
78 base::FilePath base_dir_path() { return base_dir_.path(); } | 78 base::FilePath base_dir_path() { return base_dir_.path(); } |
79 | 79 |
80 private: | 80 private: |
81 google_apis::GDataErrorCode CompleteListing( | 81 google_apis::DriveApiErrorCode CompleteListing( |
82 scoped_ptr<google_apis::FileList> list, | 82 scoped_ptr<google_apis::FileList> list, |
83 ScopedVector<google_apis::FileResource>* entries); | 83 ScopedVector<google_apis::FileResource>* entries); |
84 | 84 |
85 void Initialize(); | 85 void Initialize(); |
86 | 86 |
87 base::FilePath WriteToTempFile(const std::string& content); | 87 base::FilePath WriteToTempFile(const std::string& content); |
88 | 88 |
89 base::ScopedTempDir base_dir_; | 89 base::ScopedTempDir base_dir_; |
90 base::FilePath temp_dir_; | 90 base::FilePath temp_dir_; |
91 | 91 |
92 // Not own. | 92 // Not own. |
93 drive::FakeDriveService* fake_drive_service_; | 93 drive::FakeDriveService* fake_drive_service_; |
94 drive::DriveUploaderInterface* drive_uploader_; | 94 drive::DriveUploaderInterface* drive_uploader_; |
95 | 95 |
96 std::string sync_root_folder_title_; | 96 std::string sync_root_folder_title_; |
97 }; | 97 }; |
98 | 98 |
99 } // namespace drive_backend | 99 } // namespace drive_backend |
100 } // namespace sync_file_system | 100 } // namespace sync_file_system |
101 | 101 |
102 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_FAKE_DRIVE_SERVICE_HELP
ER_H_ | 102 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_FAKE_DRIVE_SERVICE_HELP
ER_H_ |
OLD | NEW |