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/sessions/sync_session.h" | 5 #include "sync/sessions/sync_session.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 const std::vector<ModelSafeWorker*>& workers) | 73 const std::vector<ModelSafeWorker*>& workers) |
74 : context_(context), | 74 : context_(context), |
75 source_(source), | 75 source_(source), |
76 write_transaction_(NULL), | 76 write_transaction_(NULL), |
77 delegate_(delegate), | 77 delegate_(delegate), |
78 workers_(workers), | 78 workers_(workers), |
79 routing_info_(routing_info), | 79 routing_info_(routing_info), |
80 enabled_groups_(ComputeEnabledGroups(routing_info_, workers_)) { | 80 enabled_groups_(ComputeEnabledGroups(routing_info_, workers_)) { |
81 status_controller_.reset(new StatusController(routing_info_)); | 81 status_controller_.reset(new StatusController(routing_info_)); |
82 std::sort(workers_.begin(), workers_.end()); | 82 std::sort(workers_.begin(), workers_.end()); |
83 merged_sources_log_.push_back(source_); | |
83 } | 84 } |
84 | 85 |
85 SyncSession::~SyncSession() {} | 86 SyncSession::~SyncSession() {} |
86 | 87 |
87 void SyncSession::Coalesce(const SyncSession& session) { | 88 void SyncSession::Coalesce(const SyncSession& session) { |
88 if (context_ != session.context() || delegate_ != session.delegate_) { | 89 if (context_ != session.context() || delegate_ != session.delegate_) { |
89 NOTREACHED(); | 90 NOTREACHED(); |
90 return; | 91 return; |
91 } | 92 } |
92 | 93 |
93 // When we coalesce sessions, the sync update source gets overwritten with the | 94 // When we coalesce sessions, the sync update source gets overwritten with the |
tim (not reviewing)
2012/11/27 23:48:47
Update comment. Also, you say "merged" but you'r
rlarocque
2012/11/28 00:33:58
I think the comment should stay the same. The 'me
| |
94 // most recent, while the type/state map gets merged. | 95 // most recent, while the type/state map gets merged. |
96 merged_sources_log_.push_back(session.source_); | |
95 CoalesceStates(&source_.types, session.source_.types); | 97 CoalesceStates(&source_.types, session.source_.types); |
96 source_.updates_source = session.source_.updates_source; | 98 source_.updates_source = session.source_.updates_source; |
97 | 99 |
98 std::vector<ModelSafeWorker*> temp; | 100 std::vector<ModelSafeWorker*> temp; |
99 std::set_union(workers_.begin(), workers_.end(), | 101 std::set_union(workers_.begin(), workers_.end(), |
100 session.workers_.begin(), session.workers_.end(), | 102 session.workers_.begin(), session.workers_.end(), |
101 std::back_inserter(temp)); | 103 std::back_inserter(temp)); |
102 workers_.swap(temp); | 104 workers_.swap(temp); |
103 | 105 |
104 // We have to update the model safe routing info to the union. In case the | 106 // We have to update the model safe routing info to the union. In case the |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 SyncSessionSnapshot snapshot( | 172 SyncSessionSnapshot snapshot( |
171 status_controller_->model_neutral_state(), | 173 status_controller_->model_neutral_state(), |
172 is_share_useable, | 174 is_share_useable, |
173 initial_sync_ended, | 175 initial_sync_ended, |
174 download_progress_markers, | 176 download_progress_markers, |
175 delegate_->IsSyncingCurrentlySilenced(), | 177 delegate_->IsSyncingCurrentlySilenced(), |
176 status_controller_->num_encryption_conflicts(), | 178 status_controller_->num_encryption_conflicts(), |
177 status_controller_->num_hierarchy_conflicts(), | 179 status_controller_->num_hierarchy_conflicts(), |
178 status_controller_->num_server_conflicts(), | 180 status_controller_->num_server_conflicts(), |
179 source_, | 181 source_, |
182 merged_sources_log_, | |
180 context_->notifications_enabled(), | 183 context_->notifications_enabled(), |
181 dir->GetEntriesCount(), | 184 dir->GetEntriesCount(), |
182 status_controller_->sync_start_time(), | 185 status_controller_->sync_start_time(), |
183 num_entries_by_type, | 186 num_entries_by_type, |
184 num_to_delete_entries_by_type); | 187 num_to_delete_entries_by_type); |
185 | 188 |
186 return snapshot; | 189 return snapshot; |
187 } | 190 } |
188 | 191 |
189 void SyncSession::SendEventNotification(SyncEngineEvent::EventCause cause) { | 192 void SyncSession::SendEventNotification(SyncEngineEvent::EventCause cause) { |
(...skipping 10 matching lines...) Expand all Loading... | |
200 | 203 |
201 bool SyncSession::DidReachServer() const { | 204 bool SyncSession::DidReachServer() const { |
202 const ModelNeutralState& state = status_controller_->model_neutral_state(); | 205 const ModelNeutralState& state = status_controller_->model_neutral_state(); |
203 return state.last_get_key_result >= FIRST_SERVER_RETURN_VALUE || | 206 return state.last_get_key_result >= FIRST_SERVER_RETURN_VALUE || |
204 state.last_download_updates_result >= FIRST_SERVER_RETURN_VALUE || | 207 state.last_download_updates_result >= FIRST_SERVER_RETURN_VALUE || |
205 state.commit_result >= FIRST_SERVER_RETURN_VALUE; | 208 state.commit_result >= FIRST_SERVER_RETURN_VALUE; |
206 } | 209 } |
207 | 210 |
208 } // namespace sessions | 211 } // namespace sessions |
209 } // namespace syncer | 212 } // namespace syncer |
OLD | NEW |