Componentize AccountReconcilor.
[chromium-blink-merge.git] / chrome / browser / invalidation / invalidation_service_android.h
blob039bacb38b86cb55832960382000565f8e519ca1
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_
6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/threading/non_thread_safe.h"
12 #include "chrome/browser/invalidation/invalidation_logger.h"
13 #include "chrome/browser/invalidation/invalidation_service.h"
14 #include "components/keyed_service/core/keyed_service.h"
15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h"
17 #include "sync/notifier/invalidator_registrar.h"
19 class Profile;
21 namespace invalidation {
22 class InvalidationControllerAndroid;
23 class InvalidationLogger;
25 // This InvalidationService is used to deliver invalidations on Android. The
26 // Android operating system has its own mechanisms for delivering invalidations.
27 // This class uses the NotificationService to communicate with a thin wrapper
28 // around Android's invalidations service.
29 class InvalidationServiceAndroid
30 : public base::NonThreadSafe,
31 public InvalidationService,
32 public content::NotificationObserver {
33 public:
34 // Takes ownership of |invalidation_controller|.
35 InvalidationServiceAndroid(
36 Profile* profile,
37 InvalidationControllerAndroid* invalidation_controller);
38 virtual ~InvalidationServiceAndroid();
40 // InvalidationService implementation.
42 // Note that this implementation does not properly support Ack-tracking,
43 // fetching the invalidator state, or querying the client's ID. Support for
44 // exposing the client ID should be available soon; see crbug.com/172391.
45 virtual void RegisterInvalidationHandler(
46 syncer::InvalidationHandler* handler) OVERRIDE;
47 virtual void UpdateRegisteredInvalidationIds(
48 syncer::InvalidationHandler* handler,
49 const syncer::ObjectIdSet& ids) OVERRIDE;
50 virtual void UnregisterInvalidationHandler(
51 syncer::InvalidationHandler* handler) OVERRIDE;
52 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE;
53 virtual std::string GetInvalidatorClientId() const OVERRIDE;
54 virtual InvalidationLogger* GetInvalidationLogger() OVERRIDE;
55 virtual void RequestDetailedStatus(
56 base::Callback<void(const base::DictionaryValue&)> caller) const
57 OVERRIDE;
58 virtual InvalidationAuthProvider* GetInvalidationAuthProvider() OVERRIDE;
60 // content::NotificationObserver implementation.
61 virtual void Observe(int type,
62 const content::NotificationSource& source,
63 const content::NotificationDetails& details) OVERRIDE;
65 // The InvalidationServiceAndroid always reports that it is enabled.
66 // This is used only by unit tests.
67 void TriggerStateChangeForTest(syncer::InvalidatorState state);
69 private:
70 syncer::InvalidatorRegistrar invalidator_registrar_;
71 content::NotificationRegistrar registrar_;
72 syncer::InvalidatorState invalidator_state_;
73 scoped_ptr<InvalidationControllerAndroid> invalidation_controller_;
75 // The invalidation logger object we use to record state changes
76 // and invalidations.
77 InvalidationLogger logger_;
79 DISALLOW_COPY_AND_ASSIGN(InvalidationServiceAndroid);
82 } // namespace invalidation
84 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_ANDROID_H_