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