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

Side by Side Diff: sync/notifier/non_blocking_invalidator.h

Issue 116533006: Control invalidations network channel from TiclInvalidationService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 11 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 // An implementation of SyncNotifier that wraps InvalidationNotifier 5 // An implementation of SyncNotifier that wraps InvalidationNotifier
6 // on its own thread. 6 // on its own thread.
7 7
8 #ifndef SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_ 8 #ifndef SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_
9 #define SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_ 9 #define SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/callback.h"
14 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
17 #include "jingle/notifier/base/notifier_options.h" 18 #include "jingle/notifier/base/notifier_options.h"
18 #include "sync/base/sync_export.h" 19 #include "sync/base/sync_export.h"
19 #include "sync/internal_api/public/util/weak_handle.h" 20 #include "sync/internal_api/public/util/weak_handle.h"
20 #include "sync/notifier/invalidation_handler.h" 21 #include "sync/notifier/invalidation_handler.h"
21 #include "sync/notifier/invalidation_state_tracker.h" 22 #include "sync/notifier/invalidation_state_tracker.h"
22 #include "sync/notifier/invalidator.h" 23 #include "sync/notifier/invalidator.h"
23 #include "sync/notifier/invalidator_registrar.h" 24 #include "sync/notifier/invalidator_registrar.h"
24 25
25 namespace base { 26 namespace base {
26 class SingleThreadTaskRunner; 27 class SingleThreadTaskRunner;
27 } // namespace base 28 } // namespace base
28 29
29 namespace syncer { 30 namespace syncer {
31 class SyncNetworkChannel;
32
33 // Callback type for function that creates SyncNetworkChannel. This function
34 // gets passed into NonBlockingInvalidator constructor.
35 typedef base::Callback<scoped_ptr<SyncNetworkChannel>(void)>
36 NetworkChannelCreator;
30 37
31 class SYNC_EXPORT_PRIVATE NonBlockingInvalidator 38 class SYNC_EXPORT_PRIVATE NonBlockingInvalidator
32 : public Invalidator, 39 : public Invalidator,
33 // InvalidationHandler to "observe" our Core via WeakHandle. 40 // InvalidationHandler to "observe" our Core via WeakHandle.
34 public InvalidationHandler { 41 public InvalidationHandler {
35 public: 42 public:
36 // |invalidation_state_tracker| must be initialized. 43 // |invalidation_state_tracker| must be initialized.
37 NonBlockingInvalidator( 44 NonBlockingInvalidator(
38 const notifier::NotifierOptions& notifier_options, 45 NetworkChannelCreator network_channel_creator,
39 const std::string& invalidator_client_id, 46 const std::string& invalidator_client_id,
40 const UnackedInvalidationsMap& saved_invalidations, 47 const UnackedInvalidationsMap& saved_invalidations,
41 const std::string& invalidation_bootstrap_data, 48 const std::string& invalidation_bootstrap_data,
42 const WeakHandle<InvalidationStateTracker>& 49 const WeakHandle<InvalidationStateTracker>&
43 invalidation_state_tracker, 50 invalidation_state_tracker,
44 const std::string& client_info); 51 const std::string& client_info,
52 const scoped_refptr<net::URLRequestContextGetter>&
53 request_context_getter);
45 54
46 virtual ~NonBlockingInvalidator(); 55 virtual ~NonBlockingInvalidator();
47 56
48 // Invalidator implementation. 57 // Invalidator implementation.
49 virtual void RegisterHandler(InvalidationHandler* handler) OVERRIDE; 58 virtual void RegisterHandler(InvalidationHandler* handler) OVERRIDE;
50 virtual void UpdateRegisteredIds(InvalidationHandler* handler, 59 virtual void UpdateRegisteredIds(InvalidationHandler* handler,
51 const ObjectIdSet& ids) OVERRIDE; 60 const ObjectIdSet& ids) OVERRIDE;
52 virtual void UnregisterHandler(InvalidationHandler* handler) OVERRIDE; 61 virtual void UnregisterHandler(InvalidationHandler* handler) OVERRIDE;
53 virtual InvalidatorState GetInvalidatorState() const OVERRIDE; 62 virtual InvalidatorState GetInvalidatorState() const OVERRIDE;
54 virtual void UpdateCredentials( 63 virtual void UpdateCredentials(
55 const std::string& email, const std::string& token) OVERRIDE; 64 const std::string& email, const std::string& token) OVERRIDE;
56 65
57 // InvalidationHandler implementation. 66 // InvalidationHandler implementation.
58 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; 67 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE;
59 virtual void OnIncomingInvalidation( 68 virtual void OnIncomingInvalidation(
60 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; 69 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
61 70
71 // Static functions to construct callback that creates network channel for
72 // SyncSystemResources. The goal is to pass network channel to invalidator at
73 // the same time not exposing channel specific parameters to invalidator and
74 // channel implementation to client of invalidator.
75 static NetworkChannelCreator MakePushClientChannelCreator(
76 const notifier::NotifierOptions& notifier_options);
77 static NetworkChannelCreator MakeGCMNetworkChannelCreator();
62 private: 78 private:
79 struct InitializeOptions;
63 class Core; 80 class Core;
64 81
65 InvalidatorRegistrar registrar_; 82 InvalidatorRegistrar registrar_;
66 83
67 // The real guts of NonBlockingInvalidator, which allows this class to live 84 // The real guts of NonBlockingInvalidator, which allows this class to live
68 // completely on the parent thread. 85 // completely on the parent thread.
69 scoped_refptr<Core> core_; 86 scoped_refptr<Core> core_;
70 scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_; 87 scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_;
71 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; 88 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
72 89
73 base::WeakPtrFactory<NonBlockingInvalidator> weak_ptr_factory_; 90 base::WeakPtrFactory<NonBlockingInvalidator> weak_ptr_factory_;
74 91
75 DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidator); 92 DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidator);
76 }; 93 };
77 94
78 } // namespace syncer 95 } // namespace syncer
79 96
80 #endif // SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_ 97 #endif // SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_
OLDNEW
« no previous file with comments | « sync/notifier/invalidation_notifier_unittest.cc ('k') | sync/notifier/non_blocking_invalidator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698