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