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