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() || | 60 if (nudge_tracker.IsGetUpdatesRequired(base::TimeTicks::Now()) || |
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 |
112 void Syncer::ApplyUpdates(SyncSession* session) { | 126 void Syncer::ApplyUpdates(SyncSession* session) { |
113 TRACE_EVENT0("sync", "ApplyUpdates"); | 127 TRACE_EVENT0("sync", "ApplyUpdates"); |
114 | 128 |
115 ApplyControlDataUpdates(session->context()->directory()); | 129 ApplyControlDataUpdates(session->context()->directory()); |
116 | 130 |
117 UpdateHandlerMap* handler_map = session->context()->update_handler_map(); | 131 UpdateHandlerMap* handler_map = session->context()->update_handler_map(); |
118 for (UpdateHandlerMap::iterator it = handler_map->begin(); | 132 for (UpdateHandlerMap::iterator it = handler_map->begin(); |
119 it != handler_map->end(); ++it) { | 133 it != handler_map->end(); ++it) { |
120 it->second->ApplyUpdates(session->mutable_status_controller()); | 134 it->second->ApplyUpdates(session->mutable_status_controller()); |
121 } | 135 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) { | 208 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) { |
195 if (!ExitRequested()) { | 209 if (!ExitRequested()) { |
196 session->SendSyncCycleEndEventNotification(source); | 210 session->SendSyncCycleEndEventNotification(source); |
197 return true; | 211 return true; |
198 } else { | 212 } else { |
199 return false; | 213 return false; |
200 } | 214 } |
201 } | 215 } |
202 | 216 |
203 } // namespace syncer | 217 } // namespace syncer |
OLD | NEW |