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 #include "base/threading/non_thread_safe.h" | 5 #include "base/threading/non_thread_safe.h" |
6 #include "chrome/browser/invalidation/invalidation_service.h" | 6 #include "chrome/browser/invalidation/invalidation_service.h" |
7 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" | 7 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" |
8 | 8 |
9 #ifndef CHROME_BROWSER_INVALIDATION_P2P_INVALIDATION_SERVICE_H_ | 9 #ifndef CHROME_BROWSER_INVALIDATION_P2P_INVALIDATION_SERVICE_H_ |
10 #define CHROME_BROWSER_INVALIDATION_P2P_INVALIDATION_SERVICE_H_ | 10 #define CHROME_BROWSER_INVALIDATION_P2P_INVALIDATION_SERVICE_H_ |
11 | 11 |
12 namespace syncer { | 12 namespace syncer { |
13 class P2PInvalidator; | 13 class P2PInvalidator; |
14 } | 14 } |
15 | 15 |
16 class Profile; | 16 class Profile; |
17 | 17 |
18 namespace invalidation { | 18 namespace invalidation { |
19 | 19 |
20 class InvalidationLogger; | 20 class InvalidationLogger; |
21 | 21 |
22 // This service is a wrapper around P2PInvalidator. Unlike other | 22 // This service is a wrapper around P2PInvalidator. Unlike other |
23 // InvalidationServices, it can both send and receive invalidations. It is used | 23 // InvalidationServices, it can both send and receive invalidations. It is used |
24 // only in tests, where we're unable to connect to a real invalidations server. | 24 // only in tests, where we're unable to connect to a real invalidations server. |
25 class P2PInvalidationService | 25 class P2PInvalidationService |
26 : public base::NonThreadSafe, | 26 : public base::NonThreadSafe, |
27 public InvalidationService { | 27 public InvalidationService { |
28 public: | 28 public: |
29 explicit P2PInvalidationService(Profile* profile); | 29 P2PInvalidationService(Profile* profile, |
30 scoped_ptr<InvalidationAuthProvider> auth_provider); | |
rlarocque
2014/02/25 18:29:08
This may be unnecessary. The P2P Invalidation Ser
Mattias Nissler (ping if slow)
2014/02/26 09:47:09
OK, good to know. I'll see whether I can get away
| |
30 virtual ~P2PInvalidationService(); | 31 virtual ~P2PInvalidationService(); |
31 | 32 |
32 // Overrides BrowserContextKeyedService method. | 33 // Overrides BrowserContextKeyedService method. |
33 virtual void Shutdown() OVERRIDE; | 34 virtual void Shutdown() OVERRIDE; |
34 | 35 |
35 // InvalidationService implementation. | 36 // InvalidationService implementation. |
36 // It is an error to have registered handlers when Shutdown() is called. | 37 // It is an error to have registered handlers when Shutdown() is called. |
37 virtual void RegisterInvalidationHandler( | 38 virtual void RegisterInvalidationHandler( |
38 syncer::InvalidationHandler* handler) OVERRIDE; | 39 syncer::InvalidationHandler* handler) OVERRIDE; |
39 virtual void UpdateRegisteredInvalidationIds( | 40 virtual void UpdateRegisteredInvalidationIds( |
40 syncer::InvalidationHandler* handler, | 41 syncer::InvalidationHandler* handler, |
41 const syncer::ObjectIdSet& ids) OVERRIDE; | 42 const syncer::ObjectIdSet& ids) OVERRIDE; |
42 virtual void UnregisterInvalidationHandler( | 43 virtual void UnregisterInvalidationHandler( |
43 syncer::InvalidationHandler* handler) OVERRIDE; | 44 syncer::InvalidationHandler* handler) OVERRIDE; |
44 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; | 45 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; |
45 virtual std::string GetInvalidatorClientId() const OVERRIDE; | 46 virtual std::string GetInvalidatorClientId() const OVERRIDE; |
46 virtual InvalidationLogger* GetInvalidationLogger() OVERRIDE; | 47 virtual InvalidationLogger* GetInvalidationLogger() OVERRIDE; |
48 virtual InvalidationAuthProvider* GetInvalidationAuthProvider() OVERRIDE; | |
47 | 49 |
48 void UpdateCredentials(const std::string& username, | 50 void UpdateCredentials(const std::string& username, |
49 const std::string& password); | 51 const std::string& password); |
50 | 52 |
51 void SendInvalidation(const syncer::ObjectIdSet& ids); | 53 void SendInvalidation(const syncer::ObjectIdSet& ids); |
52 | 54 |
53 private: | 55 private: |
56 scoped_ptr<InvalidationAuthProvider> auth_provider_; | |
54 scoped_ptr<syncer::P2PInvalidator> invalidator_; | 57 scoped_ptr<syncer::P2PInvalidator> invalidator_; |
55 std::string invalidator_id_; | 58 std::string invalidator_id_; |
56 | 59 |
57 DISALLOW_COPY_AND_ASSIGN(P2PInvalidationService); | 60 DISALLOW_COPY_AND_ASSIGN(P2PInvalidationService); |
58 }; | 61 }; |
59 | 62 |
60 } // namespace invalidation | 63 } // namespace invalidation |
61 | 64 |
62 #endif // CHROME_BROWSER_INVALIDATION_P2P_INVALIDATION_SERVICE_H_ | 65 #endif // CHROME_BROWSER_INVALIDATION_P2P_INVALIDATION_SERVICE_H_ |
OLD | NEW |