| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/sessions/sync_session.h" | 5 #include "chrome/browser/sync/sessions/sync_session.h" |
| 6 #include "chrome/browser/sync/syncable/directory_manager.h" | 6 #include "chrome/browser/sync/syncable/directory_manager.h" |
| 7 #include "chrome/browser/sync/syncable/model_type.h" | 7 #include "chrome/browser/sync/syncable/model_type.h" |
| 8 | 8 |
| 9 namespace browser_sync { | 9 namespace browser_sync { |
| 10 namespace sessions { | 10 namespace sessions { |
| 11 | 11 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 34 // most recent, while the type/payload map gets merged. | 34 // most recent, while the type/payload map gets merged. |
| 35 CoalescePayloads(&source_.types, session.source_.types); | 35 CoalescePayloads(&source_.types, session.source_.types); |
| 36 source_.updates_source = session.source_.updates_source; | 36 source_.updates_source = session.source_.updates_source; |
| 37 | 37 |
| 38 std::vector<ModelSafeWorker*> temp; | 38 std::vector<ModelSafeWorker*> temp; |
| 39 std::set_union(workers_.begin(), workers_.end(), | 39 std::set_union(workers_.begin(), workers_.end(), |
| 40 session.workers_.begin(), session.workers_.end(), | 40 session.workers_.begin(), session.workers_.end(), |
| 41 std::back_inserter(temp)); | 41 std::back_inserter(temp)); |
| 42 workers_.swap(temp); | 42 workers_.swap(temp); |
| 43 | 43 |
| 44 ModelSafeRoutingInfo temp_r; | 44 // We have to update the model safe routing info to the union. In case the |
| 45 std::set_union(routing_info_.begin(), routing_info_.end(), | 45 // same key is present in both pick the one from session. |
| 46 session.routing_info_.begin(), session.routing_info_.end(), | 46 for (ModelSafeRoutingInfo::const_iterator it = |
| 47 std::insert_iterator<ModelSafeRoutingInfo>(temp_r, temp_r.begin())); | 47 session.routing_info_.begin(); |
| 48 routing_info_.swap(temp_r); | 48 it != session.routing_info_.end(); |
| 49 ++it) { |
| 50 routing_info_[it->first] = it->second; |
| 51 } |
| 49 } | 52 } |
| 50 | 53 |
| 51 void SyncSession::ResetTransientState() { | 54 void SyncSession::ResetTransientState() { |
| 52 status_controller_.reset(new StatusController(routing_info_)); | 55 status_controller_.reset(new StatusController(routing_info_)); |
| 53 } | 56 } |
| 54 | 57 |
| 55 SyncSessionSnapshot SyncSession::TakeSnapshot() const { | 58 SyncSessionSnapshot SyncSession::TakeSnapshot() const { |
| 56 syncable::ScopedDirLookup dir(context_->directory_manager(), | 59 syncable::ScopedDirLookup dir(context_->directory_manager(), |
| 57 context_->account_name()); | 60 context_->account_name()); |
| 58 if (!dir.good()) | 61 if (!dir.good()) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 return ((status->commit_ids().size() < status->unsynced_handles().size()) && | 103 return ((status->commit_ids().size() < status->unsynced_handles().size()) && |
| 101 status->syncer_status().num_successful_commits > 0) || | 104 status->syncer_status().num_successful_commits > 0) || |
| 102 status->conflict_sets_built() || | 105 status->conflict_sets_built() || |
| 103 status->conflicts_resolved(); | 106 status->conflicts_resolved(); |
| 104 // Or, we have conflicting updates, but we're making progress on | 107 // Or, we have conflicting updates, but we're making progress on |
| 105 // resolving them... | 108 // resolving them... |
| 106 } | 109 } |
| 107 | 110 |
| 108 } // namespace sessions | 111 } // namespace sessions |
| 109 } // namespace browser_sync | 112 } // namespace browser_sync |
| OLD | NEW |