OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_FAKE_SYNC_WORKER_H_ | |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_FAKE_SYNC_WORKER_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 #include "base/callback.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/memory/weak_ptr.h" | |
14 #include "base/observer_list.h" | |
15 #include "base/sequence_checker.h" | |
16 #include "chrome/browser/sync_file_system/drive_backend/sync_worker_interface.h" | |
17 #include "chrome/browser/sync_file_system/remote_file_sync_service.h" | |
18 #include "chrome/browser/sync_file_system/sync_callbacks.h" | |
19 #include "net/base/network_change_notifier.h" | |
20 | |
21 class GURL; | |
22 | |
23 namespace base { | |
24 class FilePath; | |
25 class ListValue; | |
26 } | |
27 | |
28 namespace drive { | |
29 class DriveServiceInterface; | |
30 class DriveUploaderInterface; | |
31 } | |
32 | |
33 namespace fileapi { | |
34 class FileSystemURL; | |
35 } | |
36 | |
37 namespace leveldb { | |
38 class Env; | |
tzik
2014/06/13 02:26:15
Can we remove this?
peria
2014/06/13 02:34:46
Done.
| |
39 } | |
40 | |
41 namespace sync_file_system { | |
42 | |
43 class FileChange; | |
44 class SyncFileMetadata; | |
45 | |
46 namespace drive_backend { | |
47 | |
48 class MetadataDatabase; | |
49 class RemoteChangeProcessorOnWorker; | |
50 class SyncTaskManager; | |
51 | |
52 class FakeSyncWorker : public SyncWorkerInterface { | |
53 public: | |
54 FakeSyncWorker(); | |
55 virtual ~FakeSyncWorker(); | |
56 | |
57 // SyncWorkerInterface overrides. | |
58 virtual void Initialize() OVERRIDE; | |
59 virtual void RegisterOrigin(const GURL& origin, | |
60 const SyncStatusCallback& callback) OVERRIDE; | |
61 virtual void EnableOrigin(const GURL& origin, | |
62 const SyncStatusCallback& callback) OVERRIDE; | |
63 virtual void DisableOrigin(const GURL& origin, | |
64 const SyncStatusCallback& callback) OVERRIDE; | |
65 virtual void UninstallOrigin( | |
66 const GURL& origin, | |
67 RemoteFileSyncService::UninstallFlag flag, | |
68 const SyncStatusCallback& callback) OVERRIDE; | |
69 virtual void ProcessRemoteChange(const SyncFileCallback& callback) OVERRIDE; | |
70 virtual void SetRemoteChangeProcessor( | |
71 RemoteChangeProcessorOnWorker* remote_change_processor_on_worker) | |
72 OVERRIDE; | |
73 virtual RemoteServiceState GetCurrentState() const OVERRIDE; | |
74 virtual void GetOriginStatusMap( | |
75 const RemoteFileSyncService::StatusMapCallback& callback) OVERRIDE; | |
76 virtual scoped_ptr<base::ListValue> DumpFiles(const GURL& origin) OVERRIDE; | |
77 virtual scoped_ptr<base::ListValue> DumpDatabase() OVERRIDE; | |
78 virtual void SetSyncEnabled(bool enabled) OVERRIDE; | |
79 virtual void PromoteDemotedChanges() OVERRIDE; | |
80 virtual void ApplyLocalChange( | |
81 const FileChange& local_change, | |
82 const base::FilePath& local_path, | |
83 const SyncFileMetadata& local_metadata, | |
84 const fileapi::FileSystemURL& url, | |
85 const SyncStatusCallback& callback) OVERRIDE; | |
86 virtual void OnNotificationReceived() OVERRIDE; | |
87 virtual void OnReadyToSendRequests(const std::string& account_id) OVERRIDE; | |
88 virtual void OnRefreshTokenInvalid() OVERRIDE; | |
89 virtual void OnNetworkChanged( | |
90 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; | |
91 virtual drive::DriveServiceInterface* GetDriveService() OVERRIDE; | |
92 virtual drive::DriveUploaderInterface* GetDriveUploader() OVERRIDE; | |
93 virtual MetadataDatabase* GetMetadataDatabase() OVERRIDE; | |
94 virtual SyncTaskManager* GetSyncTaskManager() OVERRIDE; | |
95 virtual void DetachFromSequence() OVERRIDE; | |
96 virtual void AddObserver(Observer* observer) OVERRIDE; | |
97 | |
98 void UpdateServiceStateForTesting(RemoteServiceState state, | |
99 const std::string& description, | |
100 const base::Closure& closure); | |
101 | |
102 private: | |
103 enum AppStatus { | |
104 REGISTERED, | |
105 ENABLED, | |
106 DISABLED, | |
107 UNINSTALLED, | |
108 }; | |
109 typedef std::map<GURL, AppStatus> StatusMap; | |
110 | |
111 // TODO(peria): Remove this interface after making FakeSyncWorker class. | |
112 virtual void SetHasRefreshToken(bool has_refresh_token) OVERRIDE; | |
113 | |
114 void UpdateServiceState(RemoteServiceState state, | |
115 const std::string& description); | |
116 | |
117 bool sync_enabled_; | |
118 StatusMap status_map_; | |
119 bool has_refresh_token_; | |
120 bool network_available_; | |
121 | |
122 ObserverList<Observer> observers_; | |
123 base::SequenceChecker sequence_checker_; | |
124 | |
125 base::WeakPtrFactory<FakeSyncWorker> weak_ptr_factory_; | |
tzik
2014/06/13 02:26:15
not used?/is not going to used?
peria
2014/06/13 02:34:46
Seems not to be needed.
Removed.
| |
126 DISALLOW_COPY_AND_ASSIGN(FakeSyncWorker); | |
127 }; | |
128 | |
129 } // namespace drive_backend | |
130 } // namespace sync_file_system | |
131 | |
132 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_FAKE_SYNC_WORKER_H_ | |
OLD | NEW |