OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/syncer.h" | 5 #include "sync/engine/syncer.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 VLOG(1) << "Downloading types " << ModelTypeSetToString(request_types); | 63 VLOG(1) << "Downloading types " << ModelTypeSetToString(request_types); |
64 NormalGetUpdatesDelegate normal_delegate(nudge_tracker); | 64 NormalGetUpdatesDelegate normal_delegate(nudge_tracker); |
65 GetUpdatesProcessor get_updates_processor( | 65 GetUpdatesProcessor get_updates_processor( |
66 session->context()->model_type_registry()->update_handler_map(), | 66 session->context()->model_type_registry()->update_handler_map(), |
67 normal_delegate); | 67 normal_delegate); |
68 if (!DownloadAndApplyUpdates( | 68 if (!DownloadAndApplyUpdates( |
69 request_types, | 69 request_types, |
70 session, | 70 session, |
71 &get_updates_processor, | 71 &get_updates_processor, |
72 kCreateMobileBookmarksFolder)) { | 72 kCreateMobileBookmarksFolder)) { |
73 return HandleCycleEnd(session, nudge_tracker.updates_source()); | 73 return HandleCycleEnd(session, nudge_tracker.GetLegacySource()); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 VLOG(1) << "Committing from types " << ModelTypeSetToString(request_types); | 77 VLOG(1) << "Committing from types " << ModelTypeSetToString(request_types); |
78 CommitProcessor commit_processor( | 78 CommitProcessor commit_processor( |
79 session->context()->model_type_registry()->commit_contributor_map()); | 79 session->context()->model_type_registry()->commit_contributor_map()); |
80 SyncerError commit_result = | 80 SyncerError commit_result = |
81 BuildAndPostCommits(request_types, session, &commit_processor); | 81 BuildAndPostCommits(request_types, session, &commit_processor); |
82 session->mutable_status_controller()->set_commit_result(commit_result); | 82 session->mutable_status_controller()->set_commit_result(commit_result); |
83 | 83 |
84 return HandleCycleEnd(session, nudge_tracker.updates_source()); | 84 return HandleCycleEnd(session, nudge_tracker.GetLegacySource()); |
85 } | 85 } |
86 | 86 |
87 bool Syncer::ConfigureSyncShare( | 87 bool Syncer::ConfigureSyncShare( |
88 ModelTypeSet request_types, | 88 ModelTypeSet request_types, |
89 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, | 89 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, |
90 SyncSession* session) { | 90 SyncSession* session) { |
91 VLOG(1) << "Configuring types " << ModelTypeSetToString(request_types); | 91 VLOG(1) << "Configuring types " << ModelTypeSetToString(request_types); |
92 HandleCycleBegin(session); | 92 HandleCycleBegin(session); |
93 ConfigureGetUpdatesDelegate configure_delegate(source); | 93 ConfigureGetUpdatesDelegate configure_delegate(source); |
94 GetUpdatesProcessor get_updates_processor( | 94 GetUpdatesProcessor get_updates_processor( |
(...skipping 16 matching lines...) Expand all Loading... |
111 session->context()->model_type_registry()->update_handler_map(), | 111 session->context()->model_type_registry()->update_handler_map(), |
112 poll_delegate); | 112 poll_delegate); |
113 DownloadAndApplyUpdates( | 113 DownloadAndApplyUpdates( |
114 request_types, | 114 request_types, |
115 session, | 115 session, |
116 &get_updates_processor, | 116 &get_updates_processor, |
117 kCreateMobileBookmarksFolder); | 117 kCreateMobileBookmarksFolder); |
118 return HandleCycleEnd(session, sync_pb::GetUpdatesCallerInfo::PERIODIC); | 118 return HandleCycleEnd(session, sync_pb::GetUpdatesCallerInfo::PERIODIC); |
119 } | 119 } |
120 | 120 |
121 bool Syncer::RetrySyncShare(ModelTypeSet request_types, | |
122 SyncSession* session) { | |
123 VLOG(1) << "Retrying types " << ModelTypeSetToString(request_types); | |
124 HandleCycleBegin(session); | |
125 RetryGetUpdatesDelegate retry_delegate; | |
126 GetUpdatesProcessor get_updates_processor( | |
127 session->context()->model_type_registry()->update_handler_map(), | |
128 retry_delegate); | |
129 DownloadAndApplyUpdates( | |
130 request_types, | |
131 session, | |
132 &get_updates_processor, | |
133 kCreateMobileBookmarksFolder); | |
134 return HandleCycleEnd(session, sync_pb::GetUpdatesCallerInfo::RETRY); | |
135 } | |
136 | |
137 bool Syncer::DownloadAndApplyUpdates( | 121 bool Syncer::DownloadAndApplyUpdates( |
138 ModelTypeSet request_types, | 122 ModelTypeSet request_types, |
139 SyncSession* session, | 123 SyncSession* session, |
140 GetUpdatesProcessor* get_updates_processor, | 124 GetUpdatesProcessor* get_updates_processor, |
141 bool create_mobile_bookmarks_folder) { | 125 bool create_mobile_bookmarks_folder) { |
142 SyncerError download_result = UNSET; | 126 SyncerError download_result = UNSET; |
143 do { | 127 do { |
144 download_result = get_updates_processor->DownloadUpdates( | 128 download_result = get_updates_processor->DownloadUpdates( |
145 request_types, | 129 request_types, |
146 session, | 130 session, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) { | 201 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) { |
218 if (!ExitRequested()) { | 202 if (!ExitRequested()) { |
219 session->SendSyncCycleEndEventNotification(source); | 203 session->SendSyncCycleEndEventNotification(source); |
220 return true; | 204 return true; |
221 } else { | 205 } else { |
222 return false; | 206 return false; |
223 } | 207 } |
224 } | 208 } |
225 | 209 |
226 } // namespace syncer | 210 } // namespace syncer |
OLD | NEW |