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

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

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 #include "components/sync/engine_impl/get_updates_delegate.h" 5 #include "components/sync/engine_impl/get_updates_delegate.h"
6 6
7 #include "components/sync/engine/events/configure_get_updates_request_event.h" 7 #include "components/sync/engine/events/configure_get_updates_request_event.h"
8 #include "components/sync/engine/events/normal_get_updates_request_event.h" 8 #include "components/sync/engine/events/normal_get_updates_request_event.h"
9 #include "components/sync/engine/events/poll_get_updates_request_event.h" 9 #include "components/sync/engine/events/poll_get_updates_request_event.h"
10 #include "components/sync/engine_impl/directory_update_handler.h" 10 #include "components/sync/engine_impl/directory_update_handler.h"
11 #include "components/sync/engine_impl/get_updates_processor.h" 11 #include "components/sync/engine_impl/get_updates_processor.h"
12 12
13 namespace syncer { 13 namespace syncer {
14 14
15 namespace { 15 namespace {
16 16
17 void NonPassiveApplyUpdates(ModelTypeSet gu_types, 17 void NonPassiveApplyUpdates(ModelTypeSet gu_types,
18 sessions::StatusController* status_controller, 18 StatusController* status_controller,
19 UpdateHandlerMap* update_handler_map) { 19 UpdateHandlerMap* update_handler_map) {
20 for (UpdateHandlerMap::iterator it = update_handler_map->begin(); 20 for (UpdateHandlerMap::iterator it = update_handler_map->begin();
21 it != update_handler_map->end(); ++it) { 21 it != update_handler_map->end(); ++it) {
22 if (gu_types.Has(it->first)) 22 if (gu_types.Has(it->first))
23 it->second->ApplyUpdates(status_controller); 23 it->second->ApplyUpdates(status_controller);
24 } 24 }
25 } 25 }
26 26
27 void PassiveApplyUpdates(ModelTypeSet gu_types, 27 void PassiveApplyUpdates(ModelTypeSet gu_types,
28 sessions::StatusController* status_controller, 28 StatusController* status_controller,
29 UpdateHandlerMap* update_handler_map) { 29 UpdateHandlerMap* update_handler_map) {
30 for (UpdateHandlerMap::iterator it = update_handler_map->begin(); 30 for (UpdateHandlerMap::iterator it = update_handler_map->begin();
31 it != update_handler_map->end(); ++it) { 31 it != update_handler_map->end(); ++it) {
32 if (gu_types.Has(it->first)) 32 if (gu_types.Has(it->first))
33 it->second->PassiveApplyUpdates(status_controller); 33 it->second->PassiveApplyUpdates(status_controller);
34 } 34 }
35 } 35 }
36 36
37 } // namespace 37 } // namespace
38 38
39 GetUpdatesDelegate::GetUpdatesDelegate() {} 39 GetUpdatesDelegate::GetUpdatesDelegate() {}
40 40
41 GetUpdatesDelegate::~GetUpdatesDelegate() {} 41 GetUpdatesDelegate::~GetUpdatesDelegate() {}
42 42
43 NormalGetUpdatesDelegate::NormalGetUpdatesDelegate( 43 NormalGetUpdatesDelegate::NormalGetUpdatesDelegate(
44 const sessions::NudgeTracker& nudge_tracker) 44 const NudgeTracker& nudge_tracker)
45 : nudge_tracker_(nudge_tracker) {} 45 : nudge_tracker_(nudge_tracker) {}
46 46
47 NormalGetUpdatesDelegate::~NormalGetUpdatesDelegate() {} 47 NormalGetUpdatesDelegate::~NormalGetUpdatesDelegate() {}
48 48
49 // This function assumes the progress markers have already been populated. 49 // This function assumes the progress markers have already been populated.
50 void NormalGetUpdatesDelegate::HelpPopulateGuMessage( 50 void NormalGetUpdatesDelegate::HelpPopulateGuMessage(
51 sync_pb::GetUpdatesMessage* get_updates) const { 51 sync_pb::GetUpdatesMessage* get_updates) const {
52 // Set legacy GetUpdatesMessage.GetUpdatesCallerInfo information. 52 // Set legacy GetUpdatesMessage.GetUpdatesCallerInfo information.
53 get_updates->mutable_caller_info()->set_source( 53 get_updates->mutable_caller_info()->set_source(
54 nudge_tracker_.GetLegacySource()); 54 nudge_tracker_.GetLegacySource());
(...skipping 18 matching lines...) Expand all
73 << "Throttled types should have been removed from the request_types."; 73 << "Throttled types should have been removed from the request_types.";
74 74
75 nudge_tracker_.SetLegacyNotificationHint(type, progress_marker); 75 nudge_tracker_.SetLegacyNotificationHint(type, progress_marker);
76 nudge_tracker_.FillProtoMessage( 76 nudge_tracker_.FillProtoMessage(
77 type, progress_marker->mutable_get_update_triggers()); 77 type, progress_marker->mutable_get_update_triggers());
78 } 78 }
79 } 79 }
80 80
81 void NormalGetUpdatesDelegate::ApplyUpdates( 81 void NormalGetUpdatesDelegate::ApplyUpdates(
82 ModelTypeSet gu_types, 82 ModelTypeSet gu_types,
83 sessions::StatusController* status_controller, 83 StatusController* status_controller,
84 UpdateHandlerMap* update_handler_map) const { 84 UpdateHandlerMap* update_handler_map) const {
85 NonPassiveApplyUpdates(gu_types, status_controller, update_handler_map); 85 NonPassiveApplyUpdates(gu_types, status_controller, update_handler_map);
86 } 86 }
87 87
88 std::unique_ptr<ProtocolEvent> NormalGetUpdatesDelegate::GetNetworkRequestEvent( 88 std::unique_ptr<ProtocolEvent> NormalGetUpdatesDelegate::GetNetworkRequestEvent(
89 base::Time timestamp, 89 base::Time timestamp,
90 const sync_pb::ClientToServerMessage& request) const { 90 const sync_pb::ClientToServerMessage& request) const {
91 return std::unique_ptr<ProtocolEvent>( 91 return std::unique_ptr<ProtocolEvent>(
92 new NormalGetUpdatesRequestEvent(timestamp, nudge_tracker_, request)); 92 new NormalGetUpdatesRequestEvent(timestamp, nudge_tracker_, request));
93 } 93 }
94 94
95 ConfigureGetUpdatesDelegate::ConfigureGetUpdatesDelegate( 95 ConfigureGetUpdatesDelegate::ConfigureGetUpdatesDelegate(
96 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) 96 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source)
97 : source_(source) {} 97 : source_(source) {}
98 98
99 ConfigureGetUpdatesDelegate::~ConfigureGetUpdatesDelegate() {} 99 ConfigureGetUpdatesDelegate::~ConfigureGetUpdatesDelegate() {}
100 100
101 void ConfigureGetUpdatesDelegate::HelpPopulateGuMessage( 101 void ConfigureGetUpdatesDelegate::HelpPopulateGuMessage(
102 sync_pb::GetUpdatesMessage* get_updates) const { 102 sync_pb::GetUpdatesMessage* get_updates) const {
103 get_updates->mutable_caller_info()->set_source(source_); 103 get_updates->mutable_caller_info()->set_source(source_);
104 get_updates->set_get_updates_origin(ConvertConfigureSourceToOrigin(source_)); 104 get_updates->set_get_updates_origin(ConvertConfigureSourceToOrigin(source_));
105 } 105 }
106 106
107 void ConfigureGetUpdatesDelegate::ApplyUpdates( 107 void ConfigureGetUpdatesDelegate::ApplyUpdates(
108 ModelTypeSet gu_types, 108 ModelTypeSet gu_types,
109 sessions::StatusController* status_controller, 109 StatusController* status_controller,
110 UpdateHandlerMap* update_handler_map) const { 110 UpdateHandlerMap* update_handler_map) const {
111 PassiveApplyUpdates(gu_types, status_controller, update_handler_map); 111 PassiveApplyUpdates(gu_types, status_controller, update_handler_map);
112 } 112 }
113 113
114 std::unique_ptr<ProtocolEvent> 114 std::unique_ptr<ProtocolEvent>
115 ConfigureGetUpdatesDelegate::GetNetworkRequestEvent( 115 ConfigureGetUpdatesDelegate::GetNetworkRequestEvent(
116 base::Time timestamp, 116 base::Time timestamp,
117 const sync_pb::ClientToServerMessage& request) const { 117 const sync_pb::ClientToServerMessage& request) const {
118 return std::unique_ptr<ProtocolEvent>(new ConfigureGetUpdatesRequestEvent( 118 return std::unique_ptr<ProtocolEvent>(new ConfigureGetUpdatesRequestEvent(
119 timestamp, ConvertConfigureSourceToOrigin(source_), request)); 119 timestamp, ConvertConfigureSourceToOrigin(source_), request));
(...skipping 29 matching lines...) Expand all
149 // Set legacy GetUpdatesMessage.GetUpdatesCallerInfo information. 149 // Set legacy GetUpdatesMessage.GetUpdatesCallerInfo information.
150 get_updates->mutable_caller_info()->set_source( 150 get_updates->mutable_caller_info()->set_source(
151 sync_pb::GetUpdatesCallerInfo::PERIODIC); 151 sync_pb::GetUpdatesCallerInfo::PERIODIC);
152 152
153 // Set the new and improved version of source, too. 153 // Set the new and improved version of source, too.
154 get_updates->set_get_updates_origin(sync_pb::SyncEnums::PERIODIC); 154 get_updates->set_get_updates_origin(sync_pb::SyncEnums::PERIODIC);
155 } 155 }
156 156
157 void PollGetUpdatesDelegate::ApplyUpdates( 157 void PollGetUpdatesDelegate::ApplyUpdates(
158 ModelTypeSet gu_types, 158 ModelTypeSet gu_types,
159 sessions::StatusController* status_controller, 159 StatusController* status_controller,
160 UpdateHandlerMap* update_handler_map) const { 160 UpdateHandlerMap* update_handler_map) const {
161 NonPassiveApplyUpdates(gu_types, status_controller, update_handler_map); 161 NonPassiveApplyUpdates(gu_types, status_controller, update_handler_map);
162 } 162 }
163 163
164 std::unique_ptr<ProtocolEvent> PollGetUpdatesDelegate::GetNetworkRequestEvent( 164 std::unique_ptr<ProtocolEvent> PollGetUpdatesDelegate::GetNetworkRequestEvent(
165 base::Time timestamp, 165 base::Time timestamp,
166 const sync_pb::ClientToServerMessage& request) const { 166 const sync_pb::ClientToServerMessage& request) const {
167 return std::unique_ptr<ProtocolEvent>( 167 return std::unique_ptr<ProtocolEvent>(
168 new PollGetUpdatesRequestEvent(timestamp, request)); 168 new PollGetUpdatesRequestEvent(timestamp, request));
169 } 169 }
170 170
171 } // namespace syncer 171 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine_impl/get_updates_delegate.h ('k') | components/sync/engine_impl/get_updates_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698