| 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/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 10 #include "base/timer.h" | 10 #include "base/timer.h" |
| 11 #include "chrome/browser/google_apis/drive_notification_observer.h" | 11 #include "chrome/browser/google_apis/drive_notification_observer.h" |
| 12 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 12 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 13 #include "sync/notifier/invalidation_handler.h" | 13 #include "sync/notifier/invalidation_handler.h" |
| 14 | 14 |
| 15 class Profile; | 15 class Profile; |
| 16 class ProfileSyncService; | 16 class ProfileSyncService; |
| 17 | 17 |
| 18 namespace google_apis { | 18 namespace google_apis { |
| 19 | 19 |
| 20 // Informs observers when they should check Google Drive for updates. | 20 // Informs observers when they should check Google Drive for updates. |
| 21 // Conditions under which updates should be searched: | 21 // Conditions under which updates should be searched: |
| 22 // 1. XMPP invalidation is received from Google Drive. | 22 // 1. XMPP invalidation is received from Google Drive. |
| 23 // 2. Polling timer counts down. | 23 // 2. Polling timer counts down. |
| 24 class DriveNotificationManager | 24 class DriveNotificationManager |
| 25 : public ProfileKeyedService, | 25 : public BrowserContextKeyedService, |
| 26 public syncer::InvalidationHandler { | 26 public syncer::InvalidationHandler { |
| 27 public: | 27 public: |
| 28 explicit DriveNotificationManager(Profile* profile); | 28 explicit DriveNotificationManager(Profile* profile); |
| 29 virtual ~DriveNotificationManager(); | 29 virtual ~DriveNotificationManager(); |
| 30 | 30 |
| 31 // ProfileKeyedService override. | 31 // BrowserContextKeyedService override. |
| 32 virtual void Shutdown() OVERRIDE; | 32 virtual void Shutdown() OVERRIDE; |
| 33 | 33 |
| 34 // syncer::InvalidationHandler implementation. | 34 // syncer::InvalidationHandler implementation. |
| 35 virtual void OnInvalidatorStateChange( | 35 virtual void OnInvalidatorStateChange( |
| 36 syncer::InvalidatorState state) OVERRIDE; | 36 syncer::InvalidatorState state) OVERRIDE; |
| 37 virtual void OnIncomingInvalidation( | 37 virtual void OnIncomingInvalidation( |
| 38 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | 38 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
| 39 | 39 |
| 40 void AddObserver(DriveNotificationObserver* observer); | 40 void AddObserver(DriveNotificationObserver* observer); |
| 41 void RemoveObserver(DriveNotificationObserver* observer); | 41 void RemoveObserver(DriveNotificationObserver* observer); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Note: This should remain the last member so it'll be destroyed and | 86 // Note: This should remain the last member so it'll be destroyed and |
| 87 // invalidate its weak pointers before any other members are destroyed. | 87 // invalidate its weak pointers before any other members are destroyed. |
| 88 base::WeakPtrFactory<DriveNotificationManager> weak_ptr_factory_; | 88 base::WeakPtrFactory<DriveNotificationManager> weak_ptr_factory_; |
| 89 | 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(DriveNotificationManager); | 90 DISALLOW_COPY_AND_ASSIGN(DriveNotificationManager); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 } // namespace google_apis | 93 } // namespace google_apis |
| 94 | 94 |
| 95 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_NOTIFICATION_MANAGER_H_ | 95 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_NOTIFICATION_MANAGER_H_ |
| OLD | NEW |