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

Side by Side Diff: components/sync/engine_impl/get_updates_delegate.h

Issue 2258873003: [Sync] Move sessions/ to engine/cycle/ and rename things to match. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 4 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 2014 The Chromium Authors. All rights reserved. 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 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 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_GET_UPDATES_DELEGATE_H_ 5 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_GET_UPDATES_DELEGATE_H_
6 #define COMPONENTS_SYNC_ENGINE_IMPL_GET_UPDATES_DELEGATE_H_ 6 #define COMPONENTS_SYNC_ENGINE_IMPL_GET_UPDATES_DELEGATE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "components/sync/engine/events/protocol_event.h" 11 #include "components/sync/engine/events/protocol_event.h"
12 #include "components/sync/engine_impl/cycle/nudge_tracker.h"
13 #include "components/sync/engine_impl/cycle/status_controller.h"
12 #include "components/sync/engine_impl/model_type_registry.h" 14 #include "components/sync/engine_impl/model_type_registry.h"
13 #include "components/sync/protocol/sync.pb.h" 15 #include "components/sync/protocol/sync.pb.h"
14 #include "components/sync/sessions_impl/nudge_tracker.h"
15 #include "components/sync/sessions_impl/status_controller.h"
16 16
17 namespace syncer { 17 namespace syncer {
18 18
19 class GetUpdatesProcessor; 19 class GetUpdatesProcessor;
20 20
21 // Interface for GetUpdates functionality that dependends on the requested 21 // Interface for GetUpdates functionality that dependends on the requested
22 // GetUpdate type (normal, configuration, poll). The GetUpdatesProcessor is 22 // GetUpdate type (normal, configuration, poll). The GetUpdatesProcessor is
23 // given an appropriate GetUpdatesDelegate to handle type specific functionality 23 // given an appropriate GetUpdatesDelegate to handle type specific functionality
24 // on construction. 24 // on construction.
25 class GetUpdatesDelegate { 25 class GetUpdatesDelegate {
26 public: 26 public:
27 GetUpdatesDelegate(); 27 GetUpdatesDelegate();
28 virtual ~GetUpdatesDelegate() = 0; 28 virtual ~GetUpdatesDelegate() = 0;
29 29
30 // Populates GetUpdate message fields that depende on GetUpdates request type. 30 // Populates GetUpdate message fields that depende on GetUpdates request type.
31 virtual void HelpPopulateGuMessage( 31 virtual void HelpPopulateGuMessage(
32 sync_pb::GetUpdatesMessage* get_updates) const = 0; 32 sync_pb::GetUpdatesMessage* get_updates) const = 0;
33 33
34 // Applies pending updates to non-control types. 34 // Applies pending updates to non-control types.
35 virtual void ApplyUpdates(ModelTypeSet gu_types, 35 virtual void ApplyUpdates(ModelTypeSet gu_types,
36 sessions::StatusController* status, 36 StatusController* status,
37 UpdateHandlerMap* update_handler_map) const = 0; 37 UpdateHandlerMap* update_handler_map) const = 0;
38 38
39 virtual std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( 39 virtual std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent(
40 base::Time timestamp, 40 base::Time timestamp,
41 const sync_pb::ClientToServerMessage& request) const = 0; 41 const sync_pb::ClientToServerMessage& request) const = 0;
42 }; 42 };
43 43
44 // Functionality specific to the normal GetUpdate request. 44 // Functionality specific to the normal GetUpdate request.
45 class NormalGetUpdatesDelegate : public GetUpdatesDelegate { 45 class NormalGetUpdatesDelegate : public GetUpdatesDelegate {
46 public: 46 public:
47 explicit NormalGetUpdatesDelegate( 47 explicit NormalGetUpdatesDelegate(const NudgeTracker& nudge_tracker);
48 const sessions::NudgeTracker& nudge_tracker);
49 ~NormalGetUpdatesDelegate() override; 48 ~NormalGetUpdatesDelegate() override;
50 49
51 // Uses the member NudgeTracker to populate some fields of this GU message. 50 // Uses the member NudgeTracker to populate some fields of this GU message.
52 void HelpPopulateGuMessage( 51 void HelpPopulateGuMessage(
53 sync_pb::GetUpdatesMessage* get_updates) const override; 52 sync_pb::GetUpdatesMessage* get_updates) const override;
54 53
55 // Applies pending updates on the appropriate data type threads. 54 // Applies pending updates on the appropriate data type threads.
56 void ApplyUpdates(ModelTypeSet gu_types, 55 void ApplyUpdates(ModelTypeSet gu_types,
57 sessions::StatusController* status, 56 StatusController* status,
58 UpdateHandlerMap* update_handler_map) const override; 57 UpdateHandlerMap* update_handler_map) const override;
59 58
60 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( 59 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent(
61 base::Time timestamp, 60 base::Time timestamp,
62 const sync_pb::ClientToServerMessage& request) const override; 61 const sync_pb::ClientToServerMessage& request) const override;
63 62
64 private: 63 private:
65 const sessions::NudgeTracker& nudge_tracker_; 64 const NudgeTracker& nudge_tracker_;
66 65
67 DISALLOW_COPY_AND_ASSIGN(NormalGetUpdatesDelegate); 66 DISALLOW_COPY_AND_ASSIGN(NormalGetUpdatesDelegate);
68 }; 67 };
69 68
70 // Functionality specific to the configure GetUpdate request. 69 // Functionality specific to the configure GetUpdate request.
71 class ConfigureGetUpdatesDelegate : public GetUpdatesDelegate { 70 class ConfigureGetUpdatesDelegate : public GetUpdatesDelegate {
72 public: 71 public:
73 ConfigureGetUpdatesDelegate( 72 ConfigureGetUpdatesDelegate(
74 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); 73 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source);
75 ~ConfigureGetUpdatesDelegate() override; 74 ~ConfigureGetUpdatesDelegate() override;
76 75
77 // Sets the 'source' and 'origin' fields for this request. 76 // Sets the 'source' and 'origin' fields for this request.
78 void HelpPopulateGuMessage( 77 void HelpPopulateGuMessage(
79 sync_pb::GetUpdatesMessage* get_updates) const override; 78 sync_pb::GetUpdatesMessage* get_updates) const override;
80 79
81 // Applies updates passively (ie. on the sync thread). 80 // Applies updates passively (ie. on the sync thread).
82 // 81 //
83 // This is safe only if the ChangeProcessor is not listening to changes at 82 // This is safe only if the ChangeProcessor is not listening to changes at
84 // this time. 83 // this time.
85 void ApplyUpdates(ModelTypeSet gu_types, 84 void ApplyUpdates(ModelTypeSet gu_types,
86 sessions::StatusController* status, 85 StatusController* status,
87 UpdateHandlerMap* update_handler_map) const override; 86 UpdateHandlerMap* update_handler_map) const override;
88 87
89 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( 88 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent(
90 base::Time timestamp, 89 base::Time timestamp,
91 const sync_pb::ClientToServerMessage& request) const override; 90 const sync_pb::ClientToServerMessage& request) const override;
92 91
93 private: 92 private:
94 static sync_pb::SyncEnums::GetUpdatesOrigin ConvertConfigureSourceToOrigin( 93 static sync_pb::SyncEnums::GetUpdatesOrigin ConvertConfigureSourceToOrigin(
95 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); 94 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source);
96 95
97 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source_; 96 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source_;
98 97
99 DISALLOW_COPY_AND_ASSIGN(ConfigureGetUpdatesDelegate); 98 DISALLOW_COPY_AND_ASSIGN(ConfigureGetUpdatesDelegate);
100 }; 99 };
101 100
102 // Functionality specific to the poll GetUpdate request. 101 // Functionality specific to the poll GetUpdate request.
103 class PollGetUpdatesDelegate : public GetUpdatesDelegate { 102 class PollGetUpdatesDelegate : public GetUpdatesDelegate {
104 public: 103 public:
105 PollGetUpdatesDelegate(); 104 PollGetUpdatesDelegate();
106 ~PollGetUpdatesDelegate() override; 105 ~PollGetUpdatesDelegate() override;
107 106
108 // Sets the 'source' and 'origin' to indicate this is a poll request. 107 // Sets the 'source' and 'origin' to indicate this is a poll request.
109 void HelpPopulateGuMessage( 108 void HelpPopulateGuMessage(
110 sync_pb::GetUpdatesMessage* get_updates) const override; 109 sync_pb::GetUpdatesMessage* get_updates) const override;
111 110
112 // Applies updates on the appropriate data type thread. 111 // Applies updates on the appropriate data type thread.
113 void ApplyUpdates(ModelTypeSet gu_types, 112 void ApplyUpdates(ModelTypeSet gu_types,
114 sessions::StatusController* status, 113 StatusController* status,
115 UpdateHandlerMap* update_handler_map) const override; 114 UpdateHandlerMap* update_handler_map) const override;
116 115
117 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent( 116 std::unique_ptr<ProtocolEvent> GetNetworkRequestEvent(
118 base::Time timestamp, 117 base::Time timestamp,
119 const sync_pb::ClientToServerMessage& request) const override; 118 const sync_pb::ClientToServerMessage& request) const override;
120 119
121 private: 120 private:
122 DISALLOW_COPY_AND_ASSIGN(PollGetUpdatesDelegate); 121 DISALLOW_COPY_AND_ASSIGN(PollGetUpdatesDelegate);
123 }; 122 };
124 123
125 } // namespace syncer 124 } // namespace syncer
126 125
127 #endif // SYNC_ENGINE_IMPL_GET_UPDATES_DELEGATE_H_ 126 #endif // SYNC_ENGINE_IMPL_GET_UPDATES_DELEGATE_H_
OLDNEW
« no previous file with comments | « components/sync/engine_impl/get_commit_ids.cc ('k') | components/sync/engine_impl/get_updates_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698