OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ | |
6 #define CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ | |
7 | |
8 #include "base/threading/non_thread_safe.h" | |
9 #include "chrome/browser/invalidation/invalidation_frontend.h" | |
10 #include "chrome/browser/invalidation/invalidator_storage.h" | |
11 #include "chrome/browser/profiles/profile_keyed_service.h" | |
12 #include "chrome/browser/signin/signin_global_error.h" | |
13 #include "content/public/browser/notification_observer.h" | |
14 #include "content/public/browser/notification_registrar.h" | |
15 #include "sync/notifier/invalidation_handler.h" | |
16 #include "sync/notifier/invalidator_registrar.h" | |
17 | |
18 class Profile; | |
19 class SigninManager; | |
20 class TokenService; | |
21 | |
22 namespace syncer { | |
23 class Invalidator; | |
24 } | |
25 | |
26 namespace invalidation { | |
27 | |
28 // This InvalidationService wraps the C++ Invalidation Client (TICL) library. | |
29 // It provides invalidations for desktop platforms (Win, Mac, Linux). | |
30 class TiclInvalidationService | |
31 : public base::NonThreadSafe, | |
32 public ProfileKeyedService, | |
33 public InvalidationFrontend, | |
34 public content::NotificationObserver, | |
35 public syncer::InvalidationHandler { | |
36 public: | |
37 TiclInvalidationService(SigninManager* signin, | |
38 TokenService* token_service); | |
39 virtual ~TiclInvalidationService(); | |
40 | |
41 void Init(Profile* profile); | |
dcheng
2013/05/03 18:07:34
Out of curiosity, is there a particular reason tha
rlarocque
2013/05/03 22:16:14
I think that's probably historical reasons. Takin
| |
42 | |
43 // InvalidationFrontend implementation. | |
44 // It is an error to have registered handlers when Shutdown() is called. | |
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 void AcknowledgeInvalidation( | |
53 const invalidation::ObjectId& id, | |
54 const syncer::AckHandle& ack_handle) OVERRIDE; | |
55 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; | |
56 virtual std::string GetInvalidatorClientId() const; | |
57 | |
58 // content::NotificationObserver implementation. | |
59 virtual void Observe(int type, | |
60 const content::NotificationSource& source, | |
61 const content::NotificationDetails& details) OVERRIDE; | |
62 | |
63 // syncer::InvalidationHandler implementation. | |
64 virtual void OnInvalidatorStateChange( | |
65 syncer::InvalidatorState state) OVERRIDE; | |
66 virtual void OnIncomingInvalidation( | |
67 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | |
68 | |
69 // Override of ProfileKeyedService methods. | |
70 virtual void Shutdown() OVERRIDE; | |
71 | |
72 protected: | |
73 // Constructor for tests. | |
74 TiclInvalidationService(SigninManager* signin, | |
tim (not reviewing)
2013/05/03 17:48:23
Rather than rely on the comment, why not have an I
rlarocque
2013/05/03 22:16:14
Done.
| |
75 TokenService* token_service, | |
76 Profile* profile, | |
77 syncer::Invalidator* invalidator); | |
78 friend class TiclInvalidationServiceTestDelegate; | |
79 | |
80 private: | |
81 bool IsReadyToStart(); | |
82 bool IsStarted(); | |
83 | |
84 void Start(); | |
85 void UpdateToken(); | |
86 void Stop(); | |
87 | |
88 Profile* profile_; | |
89 SigninManager* signin_manager_; | |
90 TokenService* token_service_; | |
91 | |
92 scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_; | |
93 scoped_ptr<InvalidatorStorage> invalidator_storage_; | |
94 scoped_ptr<syncer::Invalidator> invalidator_; | |
95 | |
96 content::NotificationRegistrar notification_registrar_; | |
97 | |
98 DISALLOW_COPY_AND_ASSIGN(TiclInvalidationService); | |
99 }; | |
100 | |
101 } | |
tim (not reviewing)
2013/05/03 17:48:23
// namespace invalidation
rlarocque
2013/05/03 22:16:14
Done.
| |
102 | |
103 #endif // CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ | |
OLD | NEW |