Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / sync_file_system / drive_backend_v1 / fake_api_util.h
blob1335573821c2a4676c79d4c457a03d84ecbf3047
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.
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_FAKE_API_UTIL_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_FAKE_API_UTIL_H_
8 #include <map>
9 #include <string>
11 #include "chrome/browser/sync_file_system/drive_backend_v1/api_util_interface.h"
12 #include "chrome/browser/sync_file_system/sync_file_type.h"
13 #include "google_apis/drive/drive_api_parser.h"
14 #include "google_apis/drive/gdata_wapi_parser.h"
15 #include "google_apis/drive/gdata_wapi_url_generator.h"
17 class GURL;
18 class Profile;
20 namespace google_apis {
21 class ResourceEntry;
24 namespace sync_file_system {
25 namespace drive_backend {
27 class FakeAPIUtil : public APIUtilInterface {
28 public:
29 struct RemoteResource {
30 std::string parent_resource_id;
31 std::string parent_title;
32 std::string title;
33 std::string resource_id;
34 std::string md5_checksum;
35 SyncFileType type;
36 bool deleted;
37 int64 changestamp;
39 RemoteResource();
40 RemoteResource(const std::string& parent_resource_id,
41 const std::string& parent_title,
42 const std::string& title,
43 const std::string& resource_id,
44 const std::string& md5_checksum,
45 SyncFileType type,
46 bool deleted,
47 int64 changestamp);
48 ~RemoteResource();
51 struct RemoteResourceComparator {
52 // Returns lexicographical order referring all members.
53 bool operator()(const RemoteResource& left, const RemoteResource& right);
56 typedef std::map<std::string, RemoteResource> RemoteResourceByResourceId;
58 FakeAPIUtil();
59 virtual ~FakeAPIUtil();
61 // APIUtilInterface overrides.
62 virtual void AddObserver(APIUtilObserver* observer) OVERRIDE;
63 virtual void RemoveObserver(APIUtilObserver* observer) OVERRIDE;
64 virtual void GetDriveDirectoryForSyncRoot(
65 const ResourceIdCallback& callback) OVERRIDE;
66 virtual void GetDriveDirectoryForOrigin(
67 const std::string& sync_root_resource_id,
68 const GURL& origin,
69 const ResourceIdCallback& callback) OVERRIDE;
70 virtual void GetLargestChangeStamp(
71 const ChangeStampCallback& callback) OVERRIDE;
72 virtual void GetResourceEntry(const std::string& resource_id,
73 const ResourceEntryCallback& callback) OVERRIDE;
74 virtual void ListFiles(const std::string& directory_resource_id,
75 const ResourceListCallback& callback) OVERRIDE;
76 virtual void ListChanges(int64 start_changestamp,
77 const ResourceListCallback& callback) OVERRIDE;
78 virtual void ContinueListing(const GURL& next_link,
79 const ResourceListCallback& callback) OVERRIDE;
80 virtual void DownloadFile(const std::string& resource_id,
81 const std::string& local_file_md5,
82 const DownloadFileCallback& callback) OVERRIDE;
83 virtual void UploadNewFile(const std::string& directory_resource_id,
84 const base::FilePath& local_file_path,
85 const std::string& title,
86 const UploadFileCallback& callback) OVERRIDE;
87 virtual void UploadExistingFile(const std::string& resource_id,
88 const std::string& remote_file_md5,
89 const base::FilePath& local_file_path,
90 const UploadFileCallback& callback) OVERRIDE;
91 virtual void CreateDirectory(const std::string& parent_resource_id,
92 const std::string& title,
93 const ResourceIdCallback& callback) OVERRIDE;
94 virtual bool IsAuthenticated() const OVERRIDE;
95 virtual void DeleteFile(const std::string& resource_id,
96 const std::string& remote_file_md5,
97 const GDataErrorCallback& callback) OVERRIDE;
98 virtual void EnsureSyncRootIsNotInMyDrive(
99 const std::string& sync_root_resource_id) OVERRIDE;
101 void PushRemoteChange(const std::string& parent_resource_id,
102 const std::string& parent_title,
103 const std::string& title,
104 const std::string& resource_id,
105 const std::string& md5,
106 SyncFileType type,
107 bool deleted);
109 const RemoteResourceByResourceId& remote_resources() const {
110 return remote_resources_;
113 private:
114 struct ChangeStampComparator;
115 RemoteResourceByResourceId remote_resources_;
117 scoped_ptr<google_apis::ResourceEntry> CreateResourceEntry(
118 const RemoteResource& resource_id) const;
119 GURL ResourceIdToResourceLink(const std::string& resource_id) const;
121 int64 largest_changestamp_;
122 google_apis::GDataWapiUrlGenerator url_generator_;
124 DISALLOW_COPY_AND_ASSIGN(FakeAPIUtil);
127 } // namespace drive_backend
128 } // namespace sync_file_system
130 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_FAKE_API_UTIL_H_