OLD | NEW |
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_impl/directory_update_handler.h" | 7 #include "components/sync/engine_impl/directory_update_handler.h" |
8 #include "components/sync/engine_impl/events/configure_get_updates_request_event
.h" | 8 #include "components/sync/engine_impl/events/configure_get_updates_request_event
.h" |
9 #include "components/sync/engine_impl/events/normal_get_updates_request_event.h" | 9 #include "components/sync/engine_impl/events/normal_get_updates_request_event.h" |
10 #include "components/sync/engine_impl/events/poll_get_updates_request_event.h" | 10 #include "components/sync/engine_impl/events/poll_get_updates_request_event.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(const ModelTypeSet& gu_types, |
18 StatusController* status_controller, | 18 StatusController* status_controller, |
19 UpdateHandlerMap* update_handler_map) { | 19 UpdateHandlerMap* update_handler_map) { |
20 for (const auto& kv : *update_handler_map) { | 20 for (const auto& kv : *update_handler_map) { |
21 if (gu_types.Has(kv.first)) { | 21 if (gu_types.Has(kv.first)) { |
22 kv.second->ApplyUpdates(status_controller); | 22 kv.second->ApplyUpdates(status_controller); |
23 } | 23 } |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 void PassiveApplyUpdates(ModelTypeSet gu_types, | 27 void PassiveApplyUpdates(const ModelTypeSet& gu_types, |
28 StatusController* status_controller, | 28 StatusController* status_controller, |
29 UpdateHandlerMap* update_handler_map) { | 29 UpdateHandlerMap* update_handler_map) { |
30 for (const auto& kv : *update_handler_map) { | 30 for (const auto& kv : *update_handler_map) { |
31 if (gu_types.Has(kv.first)) { | 31 if (gu_types.Has(kv.first)) { |
32 kv.second->PassiveApplyUpdates(status_controller); | 32 kv.second->PassiveApplyUpdates(status_controller); |
33 } | 33 } |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 } // namespace | 37 } // namespace |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 DCHECK(!nudge_tracker_.IsTypeBlocked(type)) | 72 DCHECK(!nudge_tracker_.IsTypeBlocked(type)) |
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 const ModelTypeSet& gu_types, |
83 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 const ModelTypeSet& gu_types, |
109 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( |
(...skipping 29 matching lines...) Expand all Loading... |
148 sync_pb::GetUpdatesMessage* get_updates) const { | 148 sync_pb::GetUpdatesMessage* get_updates) const { |
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 const ModelTypeSet& gu_types, |
159 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 |
OLD | NEW |