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

Side by Side Diff: components/invalidation/non_blocking_invalidator.h

Issue 1191393008: Introduce a layering in the invalidation component as public and impl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Explicitly forbid content to prevent future additions Created 5 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
OLDNEW
(Empty)
1 // Copyright 2014 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.
4 //
5 // An implementation of SyncNotifier that wraps InvalidationNotifier
6 // on its own thread.
7
8 #ifndef COMPONENTS_INVALIDATION_NON_BLOCKING_INVALIDATOR_H_
9 #define COMPONENTS_INVALIDATION_NON_BLOCKING_INVALIDATOR_H_
10
11 #include <string>
12
13 #include "base/basictypes.h"
14 #include "base/callback.h"
15 #include "base/compiler_specific.h"
16 #include "base/memory/ref_counted.h"
17 #include "base/memory/weak_ptr.h"
18 #include "components/invalidation/invalidation_export.h"
19 #include "components/invalidation/invalidation_state_tracker.h"
20 #include "components/invalidation/invalidator.h"
21 #include "components/invalidation/invalidator_registrar.h"
22 #include "components/invalidation/invalidator_state.h"
23 #include "components/invalidation/unacked_invalidation_set.h"
24 #include "jingle/notifier/base/notifier_options.h"
25
26 namespace base {
27 class SingleThreadTaskRunner;
28 } // namespace base
29
30 namespace syncer {
31 class SyncNetworkChannel;
32 class GCMNetworkChannelDelegate;
33
34 // Callback type for function that creates SyncNetworkChannel. This function
35 // gets passed into NonBlockingInvalidator constructor.
36 typedef base::Callback<scoped_ptr<SyncNetworkChannel>(void)>
37 NetworkChannelCreator;
38
39 class INVALIDATION_EXPORT_PRIVATE NonBlockingInvalidator
40 : public Invalidator,
41 public InvalidationStateTracker {
42 public:
43 // |invalidation_state_tracker| must be initialized and must outlive |this|.
44 NonBlockingInvalidator(
45 NetworkChannelCreator network_channel_creator,
46 const std::string& invalidator_client_id,
47 const UnackedInvalidationsMap& saved_invalidations,
48 const std::string& invalidation_bootstrap_data,
49 InvalidationStateTracker* invalidation_state_tracker,
50 const std::string& client_info,
51 const scoped_refptr<net::URLRequestContextGetter>&
52 request_context_getter);
53
54 ~NonBlockingInvalidator() override;
55
56 // Invalidator implementation.
57 void RegisterHandler(InvalidationHandler* handler) override;
58 bool UpdateRegisteredIds(InvalidationHandler* handler,
59 const ObjectIdSet& ids) override;
60 void UnregisterHandler(InvalidationHandler* handler) override;
61 InvalidatorState GetInvalidatorState() const override;
62 void UpdateCredentials(const std::string& email,
63 const std::string& token) override;
64 void RequestDetailedStatus(base::Callback<void(const base::DictionaryValue&)>
65 callback) const override;
66
67 // Static functions to construct callback that creates network channel for
68 // SyncSystemResources. The goal is to pass network channel to invalidator at
69 // the same time not exposing channel specific parameters to invalidator and
70 // channel implementation to client of invalidator.
71 static NetworkChannelCreator MakePushClientChannelCreator(
72 const notifier::NotifierOptions& notifier_options);
73 static NetworkChannelCreator MakeGCMNetworkChannelCreator(
74 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
75 scoped_ptr<GCMNetworkChannelDelegate> delegate);
76
77 // These methods are forwarded to the invalidation_state_tracker_.
78 void ClearAndSetNewClientId(const std::string& data) override;
79 std::string GetInvalidatorClientId() const override;
80 void SetBootstrapData(const std::string& data) override;
81 std::string GetBootstrapData() const override;
82 void SetSavedInvalidations(const UnackedInvalidationsMap& states) override;
83 UnackedInvalidationsMap GetSavedInvalidations() const override;
84 void Clear() override;
85
86 private:
87 void OnInvalidatorStateChange(InvalidatorState state);
88 void OnIncomingInvalidation(const ObjectIdInvalidationMap& invalidation_map);
89 std::string GetOwnerName() const;
90
91 friend class NonBlockingInvalidatorTestDelegate;
92
93 struct InitializeOptions;
94 class Core;
95
96 InvalidatorRegistrar registrar_;
97 InvalidationStateTracker* invalidation_state_tracker_;
98
99 // The real guts of NonBlockingInvalidator, which allows this class to live
100 // completely on the parent thread.
101 scoped_refptr<Core> core_;
102 scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_;
103 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
104
105 base::WeakPtrFactory<NonBlockingInvalidator> weak_ptr_factory_;
106
107 DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidator);
108 };
109
110 } // namespace syncer
111
112 #endif // COMPONENTS_INVALIDATION_NON_BLOCKING_INVALIDATOR_H_
OLDNEW
« no previous file with comments | « components/invalidation/mock_ack_handler.cc ('k') | components/invalidation/non_blocking_invalidator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698