Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: chrome/browser/invalidation/ticl_invalidation_service.h

Issue 15580002: Make use of InvalidationService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First set of review fixes Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_TICL_INVALIDATION_SERVICE_H_ 5 #ifndef CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_
6 #define CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ 6 #define CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/threading/non_thread_safe.h" 9 #include "base/threading/non_thread_safe.h"
10 #include "chrome/browser/invalidation/invalidation_frontend.h" 10 #include "chrome/browser/invalidation/invalidation_service.h"
11 #include "chrome/browser/invalidation/invalidator_storage.h" 11 #include "chrome/browser/invalidation/invalidator_storage.h"
12 #include "chrome/browser/signin/signin_global_error.h" 12 #include "chrome/browser/signin/signin_global_error.h"
13 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" 13 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
14 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
16 #include "sync/notifier/invalidation_handler.h" 16 #include "sync/notifier/invalidation_handler.h"
17 #include "sync/notifier/invalidator_registrar.h" 17 #include "sync/notifier/invalidator_registrar.h"
18 18
19 class Profile; 19 class Profile;
20 class SigninManagerBase; 20 class SigninManagerBase;
21 class TokenService; 21 class TokenService;
22 22
23 namespace syncer { 23 namespace syncer {
24 class Invalidator; 24 class Invalidator;
25 } 25 }
26 26
27 namespace extensions {
28 class PushMessagingApiTest;
dcheng 2013/05/23 00:35:45 Ick. Can you file a bug to clean this up and assig
rlarocque 2013/05/23 21:43:27 Done. See crbug.com/243482.
29 }
30
27 namespace invalidation { 31 namespace invalidation {
28 32
29 // This InvalidationService wraps the C++ Invalidation Client (TICL) library. 33 // This InvalidationService wraps the C++ Invalidation Client (TICL) library.
30 // It provides invalidations for desktop platforms (Win, Mac, Linux). 34 // It provides invalidations for desktop platforms (Win, Mac, Linux).
31 class TiclInvalidationService 35 class TiclInvalidationService
32 : public base::NonThreadSafe, 36 : public base::NonThreadSafe,
33 public ProfileKeyedService, 37 public InvalidationService,
34 public InvalidationFrontend,
35 public content::NotificationObserver, 38 public content::NotificationObserver,
36 public syncer::InvalidationHandler { 39 public syncer::InvalidationHandler {
37 public: 40 public:
38 TiclInvalidationService(SigninManagerBase* signin, 41 TiclInvalidationService(SigninManagerBase* signin,
39 TokenService* token_service, 42 TokenService* token_service,
40 Profile* profile); 43 Profile* profile);
41 virtual ~TiclInvalidationService(); 44 virtual ~TiclInvalidationService();
42 45
43 void Init(); 46 void Init();
44 47
45 // InvalidationFrontend implementation. 48 // InvalidationService implementation.
46 // It is an error to have registered handlers when Shutdown() is called. 49 // It is an error to have registered handlers when Shutdown() is called.
47 virtual void RegisterInvalidationHandler( 50 virtual void RegisterInvalidationHandler(
48 syncer::InvalidationHandler* handler) OVERRIDE; 51 syncer::InvalidationHandler* handler) OVERRIDE;
49 virtual void UpdateRegisteredInvalidationIds( 52 virtual void UpdateRegisteredInvalidationIds(
50 syncer::InvalidationHandler* handler, 53 syncer::InvalidationHandler* handler,
51 const syncer::ObjectIdSet& ids) OVERRIDE; 54 const syncer::ObjectIdSet& ids) OVERRIDE;
52 virtual void UnregisterInvalidationHandler( 55 virtual void UnregisterInvalidationHandler(
53 syncer::InvalidationHandler* handler) OVERRIDE; 56 syncer::InvalidationHandler* handler) OVERRIDE;
54 virtual void AcknowledgeInvalidation( 57 virtual void AcknowledgeInvalidation(
55 const invalidation::ObjectId& id, 58 const invalidation::ObjectId& id,
56 const syncer::AckHandle& ack_handle) OVERRIDE; 59 const syncer::AckHandle& ack_handle) OVERRIDE;
57 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; 60 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE;
58 virtual std::string GetInvalidatorClientId() const; 61 virtual std::string GetInvalidatorClientId() const OVERRIDE;
59 62
60 // content::NotificationObserver implementation. 63 // content::NotificationObserver implementation.
61 virtual void Observe(int type, 64 virtual void Observe(int type,
62 const content::NotificationSource& source, 65 const content::NotificationSource& source,
63 const content::NotificationDetails& details) OVERRIDE; 66 const content::NotificationDetails& details) OVERRIDE;
64 67
65 // syncer::InvalidationHandler implementation. 68 // syncer::InvalidationHandler implementation.
66 virtual void OnInvalidatorStateChange( 69 virtual void OnInvalidatorStateChange(
67 syncer::InvalidatorState state) OVERRIDE; 70 syncer::InvalidatorState state) OVERRIDE;
68 virtual void OnIncomingInvalidation( 71 virtual void OnIncomingInvalidation(
69 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; 72 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
70 73
71 // Overrides ProfileKeyedService method. 74 // Overrides ProfileKeyedService method.
72 virtual void Shutdown() OVERRIDE; 75 virtual void Shutdown() OVERRIDE;
73 76
74 protected: 77 protected:
75 // Initializes with an injected invalidator. 78 // Initializes with an injected invalidator.
76 void InitForTest(syncer::Invalidator* invalidator); 79 void InitForTest(syncer::Invalidator* invalidator);
77 80
78 friend class TiclInvalidationServiceTestDelegate; 81 friend class TiclInvalidationServiceTestDelegate;
82 friend class extensions::PushMessagingApiTest;
79 83
80 private: 84 private:
81 bool IsReadyToStart(); 85 bool IsReadyToStart();
82 bool IsStarted(); 86 bool IsStarted();
83 87
84 void Start(); 88 void Start();
85 void UpdateToken(); 89 void UpdateToken();
86 void StopInvalidator(); 90 void StopInvalidator();
87 void Logout(); 91 void Logout();
88 92
89 Profile *const profile_; 93 Profile *const profile_;
90 SigninManagerBase *const signin_manager_; 94 SigninManagerBase *const signin_manager_;
91 TokenService *const token_service_; 95 TokenService *const token_service_;
92 96
93 scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_; 97 scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_;
94 scoped_ptr<InvalidatorStorage> invalidator_storage_; 98 scoped_ptr<InvalidatorStorage> invalidator_storage_;
95 scoped_ptr<syncer::Invalidator> invalidator_; 99 scoped_ptr<syncer::Invalidator> invalidator_;
96 100
97 content::NotificationRegistrar notification_registrar_; 101 content::NotificationRegistrar notification_registrar_;
98 102
99 DISALLOW_COPY_AND_ASSIGN(TiclInvalidationService); 103 DISALLOW_COPY_AND_ASSIGN(TiclInvalidationService);
100 }; 104 };
101 105
102 } 106 }
103 107
104 #endif // CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ 108 #endif // CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698