OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_GOOGLE_APIS_DRIVE_NOTIFICATION_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_DRIVE_NOTIFICATION_MANAGER_H_ |
6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_NOTIFICATION_MANAGER_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_NOTIFICATION_MANAGER_H_ |
7 | 7 |
8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
9 #include "chrome/browser/google_apis/drive_notification_observer.h" | 9 #include "chrome/browser/google_apis/drive_notification_observer.h" |
10 #include "chrome/browser/profiles/profile_keyed_service.h" | 10 #include "chrome/browser/profiles/profile_keyed_service.h" |
11 #include "sync/notifier/invalidation_handler.h" | 11 #include "sync/notifier/invalidation_handler.h" |
12 | 12 |
13 class Profile; | 13 class Profile; |
14 class ProfileSyncService; | |
15 | 14 |
16 namespace google_apis { | 15 namespace google_apis { |
17 | 16 |
18 // Informs observers when they should check Google Drive for updates. | 17 // Informs observers when they should check Google Drive for updates. |
19 // Conditions under which updates should be searched: | 18 // Conditions under which updates should be searched: |
20 // 1. XMPP invalidation is received from Google Drive. | 19 // 1. XMPP invalidation is received from Google Drive. |
| 20 // TODO(calvinlo): Implement public syncer::InvalidationHandler interface. |
21 // 2. Polling timer counts down. | 21 // 2. Polling timer counts down. |
| 22 // TODO(calvinlo): Also add in backup timer. |
22 class DriveNotificationManager | 23 class DriveNotificationManager |
23 : public ProfileKeyedService, | 24 : public ProfileKeyedService, |
24 public syncer::InvalidationHandler { | 25 public syncer::InvalidationHandler { |
25 public: | 26 public: |
26 explicit DriveNotificationManager(Profile* profile); | 27 explicit DriveNotificationManager(Profile* profile); |
27 virtual ~DriveNotificationManager(); | 28 virtual ~DriveNotificationManager(); |
28 | 29 |
29 // ProfileKeyedService override. | 30 // ProfileKeyedService override. |
30 virtual void Shutdown() OVERRIDE; | 31 virtual void Shutdown() OVERRIDE; |
31 | 32 |
32 // syncer::InvalidationHandler implementation. | 33 // syncer::InvalidationHandler implementation. |
33 virtual void OnInvalidatorStateChange( | 34 virtual void OnInvalidatorStateChange( |
34 syncer::InvalidatorState state) OVERRIDE; | 35 syncer::InvalidatorState state) OVERRIDE; |
35 virtual void OnIncomingInvalidation( | 36 virtual void OnIncomingInvalidation( |
36 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | 37 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
37 | 38 |
38 void AddObserver(DriveNotificationObserver* observer); | 39 void AddObserver(DriveNotificationObserver* observer); |
39 void RemoveObserver(DriveNotificationObserver* observer); | 40 void RemoveObserver(DriveNotificationObserver* observer); |
40 | 41 |
41 // True when XMPP notifications registered and enabled. False otherwise. | |
42 bool IsPushNotificationEnabled(); | |
43 | |
44 private: | 42 private: |
45 void NotifyObserversToUpdate(); | 43 void NotifyObserversToUpdate(); |
| 44 |
| 45 // XMPP notification related methods. |
46 void RegisterDriveNotifications(); | 46 void RegisterDriveNotifications(); |
| 47 bool IsDriveNotificationSupported(); |
| 48 void SetPushNotificationEnabled(syncer::InvalidatorState state); |
47 | 49 |
48 Profile* profile_; | 50 Profile* profile_; |
49 ProfileSyncService* profile_sync_service_; | |
50 ObserverList<DriveNotificationObserver> observers_; | 51 ObserverList<DriveNotificationObserver> observers_; |
51 | 52 |
| 53 // XMPP notification related variables. |
52 // True when Drive File Sync Service is registered for Drive notifications. | 54 // True when Drive File Sync Service is registered for Drive notifications. |
53 bool push_notification_registered_; | 55 bool push_notification_registered_; |
54 // True once the first drive notification is received with OK state. | 56 // True once the first drive notification is received with OK state. |
55 bool push_notification_enabled_; | 57 bool push_notification_enabled_; |
56 | 58 |
| 59 // TODO(calvinlo): Polling variables to go here. |
| 60 |
57 DISALLOW_COPY_AND_ASSIGN(DriveNotificationManager); | 61 DISALLOW_COPY_AND_ASSIGN(DriveNotificationManager); |
58 }; | 62 }; |
59 | 63 |
60 } // namespace google_apis | 64 } // namespace google_apis |
61 | 65 |
62 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_NOTIFICATION_MANAGER_H_ | 66 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_NOTIFICATION_MANAGER_H_ |
OLD | NEW |