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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 bool Syncer::ExitRequested() { | 51 bool Syncer::ExitRequested() { |
52 return cancelation_signal_->IsSignalled(); | 52 return cancelation_signal_->IsSignalled(); |
53 } | 53 } |
54 | 54 |
55 bool Syncer::NormalSyncShare(ModelTypeSet request_types, | 55 bool Syncer::NormalSyncShare(ModelTypeSet request_types, |
56 const NudgeTracker& nudge_tracker, | 56 const NudgeTracker& nudge_tracker, |
57 SyncSession* session) { | 57 SyncSession* session) { |
58 HandleCycleBegin(session); | 58 HandleCycleBegin(session); |
59 VLOG(1) << "Downloading types " << ModelTypeSetToString(request_types); | 59 VLOG(1) << "Downloading types " << ModelTypeSetToString(request_types); |
60 if (nudge_tracker.IsGetUpdatesRequired(base::TimeTicks::Now()) || | 60 if (nudge_tracker.IsGetUpdatesRequired() || |
61 session->context()->ShouldFetchUpdatesBeforeCommit()) { | 61 session->context()->ShouldFetchUpdatesBeforeCommit()) { |
62 if (!DownloadAndApplyUpdates( | 62 if (!DownloadAndApplyUpdates( |
63 request_types, | 63 request_types, |
64 session, | 64 session, |
65 base::Bind(&download::BuildNormalDownloadUpdates, | 65 base::Bind(&download::BuildNormalDownloadUpdates, |
66 session, | 66 session, |
67 kCreateMobileBookmarksFolder, | 67 kCreateMobileBookmarksFolder, |
68 request_types, | 68 request_types, |
69 base::ConstRef(nudge_tracker)))) { | 69 base::ConstRef(nudge_tracker)))) { |
70 return HandleCycleEnd(session, nudge_tracker.updates_source()); | 70 return HandleCycleEnd(session, nudge_tracker.updates_source()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 DownloadAndApplyUpdates( | 102 DownloadAndApplyUpdates( |
103 request_types, | 103 request_types, |
104 session, | 104 session, |
105 base::Bind(&download::BuildDownloadUpdatesForPoll, | 105 base::Bind(&download::BuildDownloadUpdatesForPoll, |
106 session, | 106 session, |
107 kCreateMobileBookmarksFolder, | 107 kCreateMobileBookmarksFolder, |
108 request_types)); | 108 request_types)); |
109 return HandleCycleEnd(session, sync_pb::GetUpdatesCallerInfo::PERIODIC); | 109 return HandleCycleEnd(session, sync_pb::GetUpdatesCallerInfo::PERIODIC); |
110 } | 110 } |
111 | 111 |
112 bool Syncer::RetrySyncShare(ModelTypeSet request_types, | |
113 SyncSession* session) { | |
114 HandleCycleBegin(session); | |
115 VLOG(1) << "Retrying types " << ModelTypeSetToString(request_types); | |
116 DownloadAndApplyUpdates( | |
117 request_types, | |
118 session, | |
119 base::Bind(&download::BuildDownloadUpdatesForRetry, | |
120 session, | |
121 kCreateMobileBookmarksFolder, | |
122 request_types)); | |
123 return HandleCycleEnd(session, sync_pb::GetUpdatesCallerInfo::RETRY); | |
124 } | |
125 | |
126 void Syncer::ApplyUpdates(SyncSession* session) { | 112 void Syncer::ApplyUpdates(SyncSession* session) { |
127 TRACE_EVENT0("sync", "ApplyUpdates"); | 113 TRACE_EVENT0("sync", "ApplyUpdates"); |
128 | 114 |
129 ApplyControlDataUpdates(session->context()->directory()); | 115 ApplyControlDataUpdates(session->context()->directory()); |
130 | 116 |
131 UpdateHandlerMap* handler_map = session->context()->update_handler_map(); | 117 UpdateHandlerMap* handler_map = session->context()->update_handler_map(); |
132 for (UpdateHandlerMap::iterator it = handler_map->begin(); | 118 for (UpdateHandlerMap::iterator it = handler_map->begin(); |
133 it != handler_map->end(); ++it) { | 119 it != handler_map->end(); ++it) { |
134 it->second->ApplyUpdates(session->mutable_status_controller()); | 120 it->second->ApplyUpdates(session->mutable_status_controller()); |
135 } | 121 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) { | 194 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) { |
209 if (!ExitRequested()) { | 195 if (!ExitRequested()) { |
210 session->SendSyncCycleEndEventNotification(source); | 196 session->SendSyncCycleEndEventNotification(source); |
211 return true; | 197 return true; |
212 } else { | 198 } else { |
213 return false; | 199 return false; |
214 } | 200 } |
215 } | 201 } |
216 | 202 |
217 } // namespace syncer | 203 } // namespace syncer |
OLD | NEW |