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

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 7 years 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:
43
rlarocque 2014/01/02 18:56:11 nit: remove extra newline.
pavely 2014/01/03 00:33:25 Done.
36 // |invalidation_state_tracker| must be initialized. 44 // |invalidation_state_tracker| must be initialized.
37 NonBlockingInvalidator( 45 NonBlockingInvalidator(
38 const notifier::NotifierOptions& notifier_options, 46 NetworkChannelCreator network_channel_creator,
39 const std::string& invalidator_client_id, 47 const std::string& invalidator_client_id,
40 const UnackedInvalidationsMap& saved_invalidations, 48 const UnackedInvalidationsMap& saved_invalidations,
41 const std::string& invalidation_bootstrap_data, 49 const std::string& invalidation_bootstrap_data,
42 const WeakHandle<InvalidationStateTracker>& 50 const WeakHandle<InvalidationStateTracker>&
43 invalidation_state_tracker, 51 invalidation_state_tracker,
44 const std::string& client_info); 52 const std::string& client_info,
53 const scoped_refptr<net::URLRequestContextGetter>&
54 request_context_getter);
45 55
46 virtual ~NonBlockingInvalidator(); 56 virtual ~NonBlockingInvalidator();
47 57
48 // Invalidator implementation. 58 // Invalidator implementation.
49 virtual void RegisterHandler(InvalidationHandler* handler) OVERRIDE; 59 virtual void RegisterHandler(InvalidationHandler* handler) OVERRIDE;
50 virtual void UpdateRegisteredIds(InvalidationHandler* handler, 60 virtual void UpdateRegisteredIds(InvalidationHandler* handler,
51 const ObjectIdSet& ids) OVERRIDE; 61 const ObjectIdSet& ids) OVERRIDE;
52 virtual void UnregisterHandler(InvalidationHandler* handler) OVERRIDE; 62 virtual void UnregisterHandler(InvalidationHandler* handler) OVERRIDE;
53 virtual InvalidatorState GetInvalidatorState() const OVERRIDE; 63 virtual InvalidatorState GetInvalidatorState() const OVERRIDE;
54 virtual void UpdateCredentials( 64 virtual void UpdateCredentials(
55 const std::string& email, const std::string& token) OVERRIDE; 65 const std::string& email, const std::string& token) OVERRIDE;
56 66
57 // InvalidationHandler implementation. 67 // InvalidationHandler implementation.
58 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; 68 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE;
59 virtual void OnIncomingInvalidation( 69 virtual void OnIncomingInvalidation(
60 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; 70 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
61 71
72 // Static functions to construct callback that creates network channel for
73 // SyncSystemResources. The goal is to pass network channel to invalidator at
74 // the same time not exposing channel specific parameters to invalidator and
75 // channel implementation to client of invalidator.
76 static NetworkChannelCreator MakePushClientChannelCreator(
77 const notifier::NotifierOptions& notifier_options);
78 static NetworkChannelCreator MakeGCMNetworkChannelCreator();
62 private: 79 private:
80 struct InitializeOptions;
63 class Core; 81 class Core;
64 82
65 InvalidatorRegistrar registrar_; 83 InvalidatorRegistrar registrar_;
66 84
67 // The real guts of NonBlockingInvalidator, which allows this class to live 85 // The real guts of NonBlockingInvalidator, which allows this class to live
68 // completely on the parent thread. 86 // completely on the parent thread.
69 scoped_refptr<Core> core_; 87 scoped_refptr<Core> core_;
70 scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_; 88 scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_;
71 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; 89 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
72 90
73 base::WeakPtrFactory<NonBlockingInvalidator> weak_ptr_factory_; 91 base::WeakPtrFactory<NonBlockingInvalidator> weak_ptr_factory_;
74 92
75 DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidator); 93 DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidator);
76 }; 94 };
77 95
78 } // namespace syncer 96 } // namespace syncer
79 97
80 #endif // SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_ 98 #endif // SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698