OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_ |
6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_ | 6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" |
10 #include "base/threading/non_thread_safe.h" | 11 #include "base/threading/non_thread_safe.h" |
11 #include "chrome/browser/invalidation/invalidation_service.h" | 12 #include "chrome/browser/invalidation/invalidation_service.h" |
12 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 13 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
13 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
15 #include "sync/notifier/invalidator_registrar.h" | 16 #include "sync/notifier/invalidator_registrar.h" |
16 | 17 |
17 class Profile; | 18 class Profile; |
18 | 19 |
19 namespace invalidation { | 20 namespace invalidation { |
20 | 21 |
| 22 class InvalidationControllerAndroid; |
| 23 |
21 // This InvalidationService is used to deliver invalidations on Android. The | 24 // This InvalidationService is used to deliver invalidations on Android. The |
22 // Android operating system has its own mechanisms for delivering invalidations. | 25 // Android operating system has its own mechanisms for delivering invalidations. |
23 // This class uses the NotificationService to communicate with a thin wrapper | 26 // This class uses the NotificationService to communicate with a thin wrapper |
24 // around Android's invalidations service. | 27 // around Android's invalidations service. |
25 class InvalidationServiceAndroid | 28 class InvalidationServiceAndroid |
26 : public base::NonThreadSafe, | 29 : public base::NonThreadSafe, |
27 public InvalidationService, | 30 public InvalidationService, |
28 public content::NotificationObserver { | 31 public content::NotificationObserver { |
29 public: | 32 public: |
30 explicit InvalidationServiceAndroid(Profile* profile); | 33 // Takes ownership of |invalidation_controller|. |
| 34 InvalidationServiceAndroid( |
| 35 Profile* profile, |
| 36 InvalidationControllerAndroid* invalidation_controller); |
31 virtual ~InvalidationServiceAndroid(); | 37 virtual ~InvalidationServiceAndroid(); |
32 | 38 |
33 // InvalidationService implementation. | 39 // InvalidationService implementation. |
34 // | 40 // |
35 // Note that this implementation does not properly support Ack-tracking, | 41 // Note that this implementation does not properly support Ack-tracking, |
36 // fetching the invalidator state, or querying the client's ID. Support for | 42 // fetching the invalidator state, or querying the client's ID. Support for |
37 // exposing the client ID should be available soon; see crbug.com/172391. | 43 // exposing the client ID should be available soon; see crbug.com/172391. |
38 virtual void RegisterInvalidationHandler( | 44 virtual void RegisterInvalidationHandler( |
39 syncer::InvalidationHandler* handler) OVERRIDE; | 45 syncer::InvalidationHandler* handler) OVERRIDE; |
40 virtual void UpdateRegisteredInvalidationIds( | 46 virtual void UpdateRegisteredInvalidationIds( |
(...skipping 13 matching lines...) Expand all Loading... |
54 const content::NotificationDetails& details) OVERRIDE; | 60 const content::NotificationDetails& details) OVERRIDE; |
55 | 61 |
56 // The InvalidationServiceAndroid always reports that it is enabled. | 62 // The InvalidationServiceAndroid always reports that it is enabled. |
57 // This is used only by unit tests. | 63 // This is used only by unit tests. |
58 void TriggerStateChangeForTest(syncer::InvalidatorState state); | 64 void TriggerStateChangeForTest(syncer::InvalidatorState state); |
59 | 65 |
60 private: | 66 private: |
61 syncer::InvalidatorRegistrar invalidator_registrar_; | 67 syncer::InvalidatorRegistrar invalidator_registrar_; |
62 content::NotificationRegistrar registrar_; | 68 content::NotificationRegistrar registrar_; |
63 syncer::InvalidatorState invalidator_state_; | 69 syncer::InvalidatorState invalidator_state_; |
| 70 scoped_ptr<InvalidationControllerAndroid> invalidation_controller_; |
64 | 71 |
65 DISALLOW_COPY_AND_ASSIGN(InvalidationServiceAndroid); | 72 DISALLOW_COPY_AND_ASSIGN(InvalidationServiceAndroid); |
66 }; | 73 }; |
67 | 74 |
68 } // namespace invalidation | 75 } // namespace invalidation |
69 | 76 |
70 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_ | 77 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_ |
OLD | NEW |