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

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

Issue 17911005: Merge 208347 "Revert 208315 "Make use of InvalidationService"" (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1547/src/
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
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 #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_frontend.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 #include "sync/notifier/object_id_invalidation_map.h" 8 #include "sync/notifier/object_id_invalidation_map.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 // This service is a wrapper around P2PInvalidator. Unlike other 21 // This service is a wrapper around P2PInvalidator. Unlike other
22 // InvalidationServices, it can both send and receive invalidations. It is used 22 // InvalidationServices, it can both send and receive invalidations. It is used
23 // only in tests, where we're unable to connect to a real invalidations server. 23 // only in tests, where we're unable to connect to a real invalidations server.
24 class P2PInvalidationService 24 class P2PInvalidationService
25 : public base::NonThreadSafe, 25 : public base::NonThreadSafe,
26 public InvalidationService { 26 public BrowserContextKeyedService,
27 public InvalidationFrontend {
27 public: 28 public:
28 explicit P2PInvalidationService(Profile* profile); 29 explicit P2PInvalidationService(Profile* profile);
29 virtual ~P2PInvalidationService(); 30 virtual ~P2PInvalidationService();
30 31
31 // Overrides BrowserContextKeyedService method. 32 // Overrides BrowserContextKeyedService method.
32 virtual void Shutdown() OVERRIDE; 33 virtual void Shutdown() OVERRIDE;
33 34
34 // InvalidationService implementation. 35 // InvalidationFrontend implementation.
35 // It is an error to have registered handlers when Shutdown() is called. 36 // It is an error to have registered handlers when Shutdown() is called.
36 virtual void RegisterInvalidationHandler( 37 virtual void RegisterInvalidationHandler(
37 syncer::InvalidationHandler* handler) OVERRIDE; 38 syncer::InvalidationHandler* handler) OVERRIDE;
38 virtual void UpdateRegisteredInvalidationIds( 39 virtual void UpdateRegisteredInvalidationIds(
39 syncer::InvalidationHandler* handler, 40 syncer::InvalidationHandler* handler,
40 const syncer::ObjectIdSet& ids) OVERRIDE; 41 const syncer::ObjectIdSet& ids) OVERRIDE;
41 virtual void UnregisterInvalidationHandler( 42 virtual void UnregisterInvalidationHandler(
42 syncer::InvalidationHandler* handler) OVERRIDE; 43 syncer::InvalidationHandler* handler) OVERRIDE;
43 virtual void AcknowledgeInvalidation( 44 virtual void AcknowledgeInvalidation(
44 const invalidation::ObjectId& id, 45 const invalidation::ObjectId& id,
45 const syncer::AckHandle& ack_handle) OVERRIDE; 46 const syncer::AckHandle& ack_handle) OVERRIDE;
46 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; 47 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE;
47 virtual std::string GetInvalidatorClientId() const OVERRIDE; 48 virtual std::string GetInvalidatorClientId() const;
48 49
49 void UpdateCredentials(const std::string& username, 50 void UpdateCredentials(const std::string& username,
50 const std::string& password); 51 const std::string& password);
51 52
52 void SendInvalidation( 53 void SendInvalidation(
53 const syncer::ObjectIdInvalidationMap& invalidation_map); 54 const syncer::ObjectIdInvalidationMap& invalidation_map);
54 55
55 private: 56 private:
56 scoped_ptr<syncer::P2PInvalidator> invalidator_; 57 scoped_ptr<syncer::P2PInvalidator> invalidator_;
57 std::string invalidator_id_; 58 std::string invalidator_id_;
58 59
59 DISALLOW_COPY_AND_ASSIGN(P2PInvalidationService); 60 DISALLOW_COPY_AND_ASSIGN(P2PInvalidationService);
60 }; 61 };
61 62
62 } // namespace invalidation 63 } // namespace invalidation
63 64
64 #endif // CHROME_BROWSER_INVALIDATION_P2P_INVALIDATION_SERVICE_H_ 65 #endif // CHROME_BROWSER_INVALIDATION_P2P_INVALIDATION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698