Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / sync_file_system / drive_backend / fake_drive_service_helper.h
blobfa0a2e2bb07fa6b8c5700e5ab4bb219afea8586f
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
3 // found in the LICENSE file.
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_
8 #include <string>
10 #include "base/files/scoped_temp_dir.h"
11 #include "components/drive/drive_uploader.h"
12 #include "components/drive/service/fake_drive_service.h"
14 namespace base {
15 class FilePath;
18 namespace sync_file_system {
19 namespace drive_backend {
21 class FakeDriveServiceHelper {
22 public:
23 FakeDriveServiceHelper(drive::FakeDriveService* fake_drive_service,
24 drive::DriveUploaderInterface* drive_uploader,
25 const std::string& sync_root_folder_title);
26 virtual ~FakeDriveServiceHelper();
28 google_apis::DriveApiErrorCode AddOrphanedFolder(
29 const std::string& title,
30 std::string* folder_id);
31 google_apis::DriveApiErrorCode AddFolder(
32 const std::string& parent_folder_id,
33 const std::string& title,
34 std::string* folder_id);
35 google_apis::DriveApiErrorCode 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::DriveApiErrorCode UpdateFile(
41 const std::string& file_id,
42 const std::string& content);
43 google_apis::DriveApiErrorCode DeleteResource(
44 const std::string& file_id);
45 google_apis::DriveApiErrorCode TrashResource(
46 const std::string& file_id);
47 google_apis::DriveApiErrorCode UpdateModificationTime(
48 const std::string& file_id,
49 const base::Time& modification_time);
50 google_apis::DriveApiErrorCode RenameResource(
51 const std::string& file_id,
52 const std::string& new_title);
53 google_apis::DriveApiErrorCode AddResourceToDirectory(
54 const std::string& parent_folder_id,
55 const std::string& file_id);
56 google_apis::DriveApiErrorCode RemoveResourceFromDirectory(
57 const std::string& parent_folder_id,
58 const std::string& file_id);
59 google_apis::DriveApiErrorCode GetSyncRootFolderID(
60 std::string* sync_root_folder_id);
61 google_apis::DriveApiErrorCode ListFilesInFolder(
62 const std::string& folder_id,
63 ScopedVector<google_apis::FileResource>* entries);
64 google_apis::DriveApiErrorCode SearchByTitle(
65 const std::string& folder_id,
66 const std::string& title,
67 ScopedVector<google_apis::FileResource>* entries);
69 google_apis::DriveApiErrorCode GetFileResource(
70 const std::string& file_id,
71 scoped_ptr<google_apis::FileResource>* entry);
72 google_apis::DriveApiErrorCode GetFileVisibility(
73 const std::string& file_id,
74 google_apis::drive::FileVisibility* visiblity);
75 google_apis::DriveApiErrorCode ReadFile(
76 const std::string& file_id,
77 std::string* file_content);
78 google_apis::DriveApiErrorCode GetAboutResource(
79 scoped_ptr<google_apis::AboutResource>* about_resource);
81 base::FilePath base_dir_path() { return base_dir_.path(); }
83 private:
84 google_apis::DriveApiErrorCode CompleteListing(
85 scoped_ptr<google_apis::FileList> list,
86 ScopedVector<google_apis::FileResource>* entries);
88 void Initialize();
90 base::FilePath WriteToTempFile(const std::string& content);
92 base::ScopedTempDir base_dir_;
93 base::FilePath temp_dir_;
95 // Not own.
96 drive::FakeDriveService* fake_drive_service_;
97 drive::DriveUploaderInterface* drive_uploader_;
99 std::string sync_root_folder_title_;
102 } // namespace drive_backend
103 } // namespace sync_file_system
105 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_FAKE_DRIVE_SERVICE_HELPER_H_