Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: chrome/browser/chromeos/drive/drive_sync_client.h

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_CHROMEOS_DRIVE_DRIVE_SYNC_CLIENT_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYNC_CLIENT_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYNC_CLIENT_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYNC_CLIENT_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/prefs/public/pref_observer.h"
14 #include "base/time.h" 15 #include "base/time.h"
15 #include "chrome/browser/chromeos/drive/drive_cache.h" 16 #include "chrome/browser/chromeos/drive/drive_cache.h"
16 #include "chrome/browser/chromeos/drive/drive_cache_observer.h" 17 #include "chrome/browser/chromeos/drive/drive_cache_observer.h"
17 #include "chrome/browser/chromeos/drive/drive_file_system_observer.h" 18 #include "chrome/browser/chromeos/drive/drive_file_system_observer.h"
18 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" 19 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h"
19 #include "content/public/browser/notification_observer.h"
20 #include "net/base/network_change_notifier.h" 20 #include "net/base/network_change_notifier.h"
21 21
22 class Profile; 22 class Profile;
23 class PrefChangeRegistrar; 23 class PrefChangeRegistrar;
24 24
25 namespace drive { 25 namespace drive {
26 26
27 class DriveEntryProto; 27 class DriveEntryProto;
28 class DriveFileSystemInterface; 28 class DriveFileSystemInterface;
29 class DrivePrefetcher; 29 class DrivePrefetcher;
30 class DriveSyncClientObserver; 30 class DriveSyncClientObserver;
31 31
32 // The DriveSyncClient is used to synchronize pinned files on Drive and the 32 // The DriveSyncClient is used to synchronize pinned files on Drive and the
33 // cache on the local drive. The sync client works as follows. 33 // cache on the local drive. The sync client works as follows.
34 // 34 //
35 // When the user pins files on Drive, this client is notified about the files 35 // When the user pins files on Drive, this client is notified about the files
36 // that get pinned, and queues tasks and starts fetching these files in the 36 // that get pinned, and queues tasks and starts fetching these files in the
37 // background. 37 // background.
38 // 38 //
39 // When the user unpins files on Drive, this client is notified about the 39 // When the user unpins files on Drive, this client is notified about the
40 // files that get unpinned, cancels tasks if these are still in the queue. 40 // files that get unpinned, cancels tasks if these are still in the queue.
41 // 41 //
42 // If the user logs out before fetching of the pinned files is complete, this 42 // If the user logs out before fetching of the pinned files is complete, this
43 // client resumes fetching operations next time the user logs in, based on 43 // client resumes fetching operations next time the user logs in, based on
44 // the states left in the cache. 44 // the states left in the cache.
45 class DriveSyncClient 45 class DriveSyncClient
46 : public DriveFileSystemObserver, 46 : public DriveFileSystemObserver,
47 public DriveCacheObserver, 47 public DriveCacheObserver,
48 public content::NotificationObserver, 48 public PrefObserver,
49 public net::NetworkChangeNotifier::ConnectionTypeObserver { 49 public net::NetworkChangeNotifier::ConnectionTypeObserver {
50 public: 50 public:
51 // Types of sync tasks. 51 // Types of sync tasks.
52 enum SyncType { 52 enum SyncType {
53 FETCH, // Fetch a file from the Drive server. 53 FETCH, // Fetch a file from the Drive server.
54 UPLOAD, // Upload a file to the Drive server. 54 UPLOAD, // Upload a file to the Drive server.
55 }; 55 };
56 56
57 // The struct is used to queue tasks for fetching and uploading. 57 // The struct is used to queue tasks for fetching and uploading.
58 struct SyncTask { 58 struct SyncTask {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 DriveFileError error, 171 DriveFileError error,
172 const FilePath& local_path, 172 const FilePath& local_path,
173 const std::string& ununsed_mime_type, 173 const std::string& ununsed_mime_type,
174 DriveFileType file_type); 174 DriveFileType file_type);
175 175
176 // Called when the file for |resource_id| is uploaded. 176 // Called when the file for |resource_id| is uploaded.
177 // Calls DoSyncLoop() to go back to the sync loop. 177 // Calls DoSyncLoop() to go back to the sync loop.
178 void OnUploadFileComplete(const std::string& resource_id, 178 void OnUploadFileComplete(const std::string& resource_id,
179 DriveFileError error); 179 DriveFileError error);
180 180
181 // content::NotificationObserver override. 181 // PrefObserver override.
182 virtual void Observe(int type, 182 virtual void OnPreferenceChanged(PrefServiceBase* service,
183 const content::NotificationSource& source, 183 const std::string& pref_name) OVERRIDE;
184 const content::NotificationDetails& details) OVERRIDE;
185 184
186 // net::NetworkChangeNotifier::ConnectionTypeObserver override. 185 // net::NetworkChangeNotifier::ConnectionTypeObserver override.
187 virtual void OnConnectionTypeChanged( 186 virtual void OnConnectionTypeChanged(
188 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; 187 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
189 188
190 Profile* profile_; 189 Profile* profile_;
191 DriveFileSystemInterface* file_system_; // Owned by DriveSystemService. 190 DriveFileSystemInterface* file_system_; // Owned by DriveSystemService.
192 DriveCache* cache_; // Owned by DriveSystemService. 191 DriveCache* cache_; // Owned by DriveSystemService.
193 scoped_ptr<PrefChangeRegistrar> registrar_; 192 scoped_ptr<PrefChangeRegistrar> registrar_;
194 ObserverList<DriveSyncClientObserver> observers_; 193 ObserverList<DriveSyncClientObserver> observers_;
(...skipping 12 matching lines...) Expand all
207 // Note: This should remain the last member so it'll be destroyed and 206 // Note: This should remain the last member so it'll be destroyed and
208 // invalidate its weak pointers before any other members are destroyed. 207 // invalidate its weak pointers before any other members are destroyed.
209 base::WeakPtrFactory<DriveSyncClient> weak_ptr_factory_; 208 base::WeakPtrFactory<DriveSyncClient> weak_ptr_factory_;
210 209
211 DISALLOW_COPY_AND_ASSIGN(DriveSyncClient); 210 DISALLOW_COPY_AND_ASSIGN(DriveSyncClient);
212 }; 211 };
213 212
214 } // namespace drive 213 } // namespace drive
215 214
216 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYNC_CLIENT_H_ 215 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_SYNC_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698