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

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

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. 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 "sync/engine/get_updates_delegate.h" 5 #include "components/sync/engine_impl/get_updates_delegate.h"
6 6
7 #include "sync/engine/directory_update_handler.h" 7 #include "components/sync/engine/events/configure_get_updates_request_event.h"
8 #include "sync/engine/get_updates_processor.h" 8 #include "components/sync/engine/events/normal_get_updates_request_event.h"
9 #include "sync/internal_api/public/events/configure_get_updates_request_event.h" 9 #include "components/sync/engine/events/poll_get_updates_request_event.h"
10 #include "sync/internal_api/public/events/normal_get_updates_request_event.h" 10 #include "components/sync/engine_impl/directory_update_handler.h"
11 #include "sync/internal_api/public/events/poll_get_updates_request_event.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( 17 void NonPassiveApplyUpdates(ModelTypeSet gu_types,
18 ModelTypeSet gu_types, 18 sessions::StatusController* status_controller,
19 sessions::StatusController* status_controller, 19 UpdateHandlerMap* update_handler_map) {
20 UpdateHandlerMap* update_handler_map) {
21 for (UpdateHandlerMap::iterator it = update_handler_map->begin(); 20 for (UpdateHandlerMap::iterator it = update_handler_map->begin();
22 it != update_handler_map->end(); ++it) { 21 it != update_handler_map->end(); ++it) {
23 if (gu_types.Has(it->first)) 22 if (gu_types.Has(it->first))
24 it->second->ApplyUpdates(status_controller); 23 it->second->ApplyUpdates(status_controller);
25 } 24 }
26 } 25 }
27 26
28 void PassiveApplyUpdates( 27 void PassiveApplyUpdates(ModelTypeSet gu_types,
29 ModelTypeSet gu_types, 28 sessions::StatusController* status_controller,
30 sessions::StatusController* status_controller, 29 UpdateHandlerMap* update_handler_map) {
31 UpdateHandlerMap* update_handler_map) {
32 for (UpdateHandlerMap::iterator it = update_handler_map->begin(); 30 for (UpdateHandlerMap::iterator it = update_handler_map->begin();
33 it != update_handler_map->end(); ++it) { 31 it != update_handler_map->end(); ++it) {
34 if (gu_types.Has(it->first)) 32 if (gu_types.Has(it->first))
35 it->second->PassiveApplyUpdates(status_controller); 33 it->second->PassiveApplyUpdates(status_controller);
36 } 34 }
37 } 35 }
38 36
39 } // namespace 37 } // namespace
40 38
41 GetUpdatesDelegate::GetUpdatesDelegate() {} 39 GetUpdatesDelegate::GetUpdatesDelegate() {}
42 40
43 GetUpdatesDelegate::~GetUpdatesDelegate() {} 41 GetUpdatesDelegate::~GetUpdatesDelegate() {}
44 42
45 NormalGetUpdatesDelegate::NormalGetUpdatesDelegate( 43 NormalGetUpdatesDelegate::NormalGetUpdatesDelegate(
46 const sessions::NudgeTracker& nudge_tracker) 44 const sessions::NudgeTracker& nudge_tracker)
47 : nudge_tracker_(nudge_tracker) {} 45 : nudge_tracker_(nudge_tracker) {}
48 46
49 NormalGetUpdatesDelegate::~NormalGetUpdatesDelegate() {} 47 NormalGetUpdatesDelegate::~NormalGetUpdatesDelegate() {}
50 48
51 // This function assumes the progress markers have already been populated. 49 // This function assumes the progress markers have already been populated.
52 void NormalGetUpdatesDelegate::HelpPopulateGuMessage( 50 void NormalGetUpdatesDelegate::HelpPopulateGuMessage(
53 sync_pb::GetUpdatesMessage* get_updates) const { 51 sync_pb::GetUpdatesMessage* get_updates) const {
54 // Set legacy GetUpdatesMessage.GetUpdatesCallerInfo information. 52 // Set legacy GetUpdatesMessage.GetUpdatesCallerInfo information.
55 get_updates->mutable_caller_info()->set_source( 53 get_updates->mutable_caller_info()->set_source(
56 nudge_tracker_.GetLegacySource()); 54 nudge_tracker_.GetLegacySource());
57 55
58 // Set the new and improved version of source, too. 56 // Set the new and improved version of source, too.
59 get_updates->set_get_updates_origin(sync_pb::SyncEnums::GU_TRIGGER); 57 get_updates->set_get_updates_origin(sync_pb::SyncEnums::GU_TRIGGER);
60 get_updates->set_is_retry(nudge_tracker_.IsRetryRequired()); 58 get_updates->set_is_retry(nudge_tracker_.IsRetryRequired());
61 59
62 // Special case: A GU performed for no other reason than retry will have its 60 // Special case: A GU performed for no other reason than retry will have its
63 // origin set to RETRY. 61 // origin set to RETRY.
64 if (nudge_tracker_.GetLegacySource() == sync_pb::GetUpdatesCallerInfo::RETRY) 62 if (nudge_tracker_.GetLegacySource() == sync_pb::GetUpdatesCallerInfo::RETRY)
65 get_updates->set_get_updates_origin(sync_pb::SyncEnums::RETRY); 63 get_updates->set_get_updates_origin(sync_pb::SyncEnums::RETRY);
66 64
67 // Fill in the notification hints. 65 // Fill in the notification hints.
68 for (int i = 0; i < get_updates->from_progress_marker_size(); ++i) { 66 for (int i = 0; i < get_updates->from_progress_marker_size(); ++i) {
69 sync_pb::DataTypeProgressMarker* progress_marker = 67 sync_pb::DataTypeProgressMarker* progress_marker =
70 get_updates->mutable_from_progress_marker(i); 68 get_updates->mutable_from_progress_marker(i);
71 ModelType type = GetModelTypeFromSpecificsFieldNumber( 69 ModelType type =
72 progress_marker->data_type_id()); 70 GetModelTypeFromSpecificsFieldNumber(progress_marker->data_type_id());
73 71
74 DCHECK(!nudge_tracker_.IsTypeThrottled(type)) 72 DCHECK(!nudge_tracker_.IsTypeThrottled(type))
75 << "Throttled types should have been removed from the request_types."; 73 << "Throttled types should have been removed from the request_types.";
76 74
77 nudge_tracker_.SetLegacyNotificationHint(type, progress_marker); 75 nudge_tracker_.SetLegacyNotificationHint(type, progress_marker);
78 nudge_tracker_.FillProtoMessage( 76 nudge_tracker_.FillProtoMessage(
79 type, 77 type, progress_marker->mutable_get_update_triggers());
80 progress_marker->mutable_get_update_triggers());
81 } 78 }
82 } 79 }
83 80
84 void NormalGetUpdatesDelegate::ApplyUpdates( 81 void NormalGetUpdatesDelegate::ApplyUpdates(
85 ModelTypeSet gu_types, 82 ModelTypeSet gu_types,
86 sessions::StatusController* status_controller, 83 sessions::StatusController* status_controller,
87 UpdateHandlerMap* update_handler_map) const { 84 UpdateHandlerMap* update_handler_map) const {
88 NonPassiveApplyUpdates(gu_types, status_controller, update_handler_map); 85 NonPassiveApplyUpdates(gu_types, status_controller, update_handler_map);
89 } 86 }
90 87
91 std::unique_ptr<ProtocolEvent> NormalGetUpdatesDelegate::GetNetworkRequestEvent( 88 std::unique_ptr<ProtocolEvent> NormalGetUpdatesDelegate::GetNetworkRequestEvent(
92 base::Time timestamp, 89 base::Time timestamp,
93 const sync_pb::ClientToServerMessage& request) const { 90 const sync_pb::ClientToServerMessage& request) const {
94 return std::unique_ptr<ProtocolEvent>( 91 return std::unique_ptr<ProtocolEvent>(
95 new NormalGetUpdatesRequestEvent(timestamp, nudge_tracker_, request)); 92 new NormalGetUpdatesRequestEvent(timestamp, nudge_tracker_, request));
96 } 93 }
97 94
98 ConfigureGetUpdatesDelegate::ConfigureGetUpdatesDelegate( 95 ConfigureGetUpdatesDelegate::ConfigureGetUpdatesDelegate(
99 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) : source_(source) {} 96 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source)
97 : source_(source) {}
100 98
101 ConfigureGetUpdatesDelegate::~ConfigureGetUpdatesDelegate() {} 99 ConfigureGetUpdatesDelegate::~ConfigureGetUpdatesDelegate() {}
102 100
103 void ConfigureGetUpdatesDelegate::HelpPopulateGuMessage( 101 void ConfigureGetUpdatesDelegate::HelpPopulateGuMessage(
104 sync_pb::GetUpdatesMessage* get_updates) const { 102 sync_pb::GetUpdatesMessage* get_updates) const {
105 get_updates->mutable_caller_info()->set_source(source_); 103 get_updates->mutable_caller_info()->set_source(source_);
106 get_updates->set_get_updates_origin(ConvertConfigureSourceToOrigin(source_)); 104 get_updates->set_get_updates_origin(ConvertConfigureSourceToOrigin(source_));
107 } 105 }
108 106
109 void ConfigureGetUpdatesDelegate::ApplyUpdates( 107 void ConfigureGetUpdatesDelegate::ApplyUpdates(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 162 }
165 163
166 std::unique_ptr<ProtocolEvent> PollGetUpdatesDelegate::GetNetworkRequestEvent( 164 std::unique_ptr<ProtocolEvent> PollGetUpdatesDelegate::GetNetworkRequestEvent(
167 base::Time timestamp, 165 base::Time timestamp,
168 const sync_pb::ClientToServerMessage& request) const { 166 const sync_pb::ClientToServerMessage& request) const {
169 return std::unique_ptr<ProtocolEvent>( 167 return std::unique_ptr<ProtocolEvent>(
170 new PollGetUpdatesRequestEvent(timestamp, request)); 168 new PollGetUpdatesRequestEvent(timestamp, request));
171 } 169 }
172 170
173 } // 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