Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: components/sync_sessions/sessions_sync_manager.cc

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/sync_sessions/sessions_sync_manager.h" 5 #include "components/sync_sessions/sessions_sync_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility>
8 9
9 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
10 #include "build/build_config.h" 11 #include "build/build_config.h"
11 #include "components/sync_driver/local_device_info_provider.h" 12 #include "components/sync_driver/local_device_info_provider.h"
12 #include "components/sync_sessions/sync_sessions_client.h" 13 #include "components/sync_sessions/sync_sessions_client.h"
13 #include "components/sync_sessions/synced_tab_delegate.h" 14 #include "components/sync_sessions/synced_tab_delegate.h"
14 #include "components/sync_sessions/synced_window_delegate.h" 15 #include "components/sync_sessions/synced_window_delegate.h"
15 #include "components/sync_sessions/synced_window_delegates_getter.h" 16 #include "components/sync_sessions/synced_window_delegates_getter.h"
16 #include "components/variations/variations_associated_data.h" 17 #include "components/variations/variations_associated_data.h"
17 #include "sync/api/sync_error.h" 18 #include "sync/api/sync_error.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 : sessions_client_(sessions_client), 73 : sessions_client_(sessions_client),
73 session_tracker_(sessions_client), 74 session_tracker_(sessions_client),
74 favicon_cache_(sessions_client->GetFaviconService(), 75 favicon_cache_(sessions_client->GetFaviconService(),
75 sessions_client->GetHistoryService(), 76 sessions_client->GetHistoryService(),
76 kMaxSyncFavicons), 77 kMaxSyncFavicons),
77 local_tab_pool_out_of_sync_(true), 78 local_tab_pool_out_of_sync_(true),
78 sync_prefs_(sync_prefs), 79 sync_prefs_(sync_prefs),
79 local_device_(local_device), 80 local_device_(local_device),
80 local_session_header_node_id_(TabNodePool::kInvalidTabNodeID), 81 local_session_header_node_id_(TabNodePool::kInvalidTabNodeID),
81 stale_session_threshold_days_(kDefaultStaleSessionThresholdDays), 82 stale_session_threshold_days_(kDefaultStaleSessionThresholdDays),
82 local_event_router_(router.Pass()), 83 local_event_router_(std::move(router)),
83 page_revisit_broadcaster_(this, sessions_client), 84 page_revisit_broadcaster_(this, sessions_client),
84 sessions_updated_callback_(sessions_updated_callback), 85 sessions_updated_callback_(sessions_updated_callback),
85 datatype_refresh_callback_(datatype_refresh_callback) { 86 datatype_refresh_callback_(datatype_refresh_callback) {}
86 }
87 87
88 SessionsSyncManager::~SessionsSyncManager() {} 88 SessionsSyncManager::~SessionsSyncManager() {}
89 89
90 // Returns the GUID-based string that should be used for 90 // Returns the GUID-based string that should be used for
91 // |SessionsSyncManager::current_machine_tag_|. 91 // |SessionsSyncManager::current_machine_tag_|.
92 static std::string BuildMachineTag(const std::string& cache_guid) { 92 static std::string BuildMachineTag(const std::string& cache_guid) {
93 std::string machine_tag = "session_sync"; 93 std::string machine_tag = "session_sync";
94 machine_tag.append(cache_guid); 94 machine_tag.append(cache_guid);
95 return machine_tag; 95 return machine_tag;
96 } 96 }
97 97
98 syncer::SyncMergeResult SessionsSyncManager::MergeDataAndStartSyncing( 98 syncer::SyncMergeResult SessionsSyncManager::MergeDataAndStartSyncing(
99 syncer::ModelType type, 99 syncer::ModelType type,
100 const syncer::SyncDataList& initial_sync_data, 100 const syncer::SyncDataList& initial_sync_data,
101 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 101 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
102 scoped_ptr<syncer::SyncErrorFactory> error_handler) { 102 scoped_ptr<syncer::SyncErrorFactory> error_handler) {
103 syncer::SyncMergeResult merge_result(type); 103 syncer::SyncMergeResult merge_result(type);
104 DCHECK(session_tracker_.Empty()); 104 DCHECK(session_tracker_.Empty());
105 DCHECK_EQ(0U, local_tab_pool_.Capacity()); 105 DCHECK_EQ(0U, local_tab_pool_.Capacity());
106 106
107 error_handler_ = error_handler.Pass(); 107 error_handler_ = std::move(error_handler);
108 sync_processor_ = sync_processor.Pass(); 108 sync_processor_ = std::move(sync_processor);
109 109
110 local_session_header_node_id_ = TabNodePool::kInvalidTabNodeID; 110 local_session_header_node_id_ = TabNodePool::kInvalidTabNodeID;
111 111
112 // Make sure we have a machine tag. We do this now (versus earlier) as it's 112 // Make sure we have a machine tag. We do this now (versus earlier) as it's
113 // a conveniently safe time to assert sync is ready and the cache_guid is 113 // a conveniently safe time to assert sync is ready and the cache_guid is
114 // initialized. 114 // initialized.
115 if (current_machine_tag_.empty()) { 115 if (current_machine_tag_.empty()) {
116 InitializeCurrentMachineTag(); 116 InitializeCurrentMachineTag();
117 } 117 }
118 118
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 page_revisit_broadcaster_.OnPageVisit( 344 page_revisit_broadcaster_.OnPageVisit(
345 new_url, tab->GetTransitionAtIndex(current_index)); 345 new_url, tab->GetTransitionAtIndex(current_index));
346 } 346 }
347 347
348 session_tracker_.GetSession(current_machine_tag())->modified_time = 348 session_tracker_.GetSession(current_machine_tag())->modified_time =
349 base::Time::Now(); 349 base::Time::Now();
350 } 350 }
351 351
352 void SessionsSyncManager::RebuildAssociations() { 352 void SessionsSyncManager::RebuildAssociations() {
353 syncer::SyncDataList data(sync_processor_->GetAllSyncData(syncer::SESSIONS)); 353 syncer::SyncDataList data(sync_processor_->GetAllSyncData(syncer::SESSIONS));
354 scoped_ptr<syncer::SyncErrorFactory> error_handler(error_handler_.Pass()); 354 scoped_ptr<syncer::SyncErrorFactory> error_handler(std::move(error_handler_));
355 scoped_ptr<syncer::SyncChangeProcessor> processor(sync_processor_.Pass()); 355 scoped_ptr<syncer::SyncChangeProcessor> processor(std::move(sync_processor_));
356 356
357 StopSyncing(syncer::SESSIONS); 357 StopSyncing(syncer::SESSIONS);
358 MergeDataAndStartSyncing(syncer::SESSIONS, data, processor.Pass(), 358 MergeDataAndStartSyncing(syncer::SESSIONS, data, std::move(processor),
359 error_handler.Pass()); 359 std::move(error_handler));
360 } 360 }
361 361
362 bool SessionsSyncManager::IsValidSessionHeader( 362 bool SessionsSyncManager::IsValidSessionHeader(
363 const sync_pb::SessionHeader& header) { 363 const sync_pb::SessionHeader& header) {
364 // Verify that tab IDs appear only once within a session. 364 // Verify that tab IDs appear only once within a session.
365 // Intended to prevent http://crbug.com/360822. 365 // Intended to prevent http://crbug.com/360822.
366 std::set<int> session_tab_ids; 366 std::set<int> session_tab_ids;
367 for (int i = 0; i < header.window_size(); ++i) { 367 for (int i = 0; i < header.window_size(); ++i) {
368 const sync_pb::SessionWindow& window = header.window(i); 368 const sync_pb::SessionWindow& window = header.window(i);
369 for (int j = 0; j < window.tab_size(); ++j) { 369 for (int j = 0; j < window.tab_size(); ++j) {
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 << session_age_in_days << ", deleting."; 1050 << session_age_in_days << ", deleting.";
1051 DeleteForeignSessionInternal(session_tag, &changes); 1051 DeleteForeignSessionInternal(session_tag, &changes);
1052 } 1052 }
1053 } 1053 }
1054 1054
1055 if (!changes.empty()) 1055 if (!changes.empty())
1056 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); 1056 sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
1057 } 1057 }
1058 1058
1059 }; // namespace browser_sync 1059 }; // namespace browser_sync
OLDNEW
« no previous file with comments | « components/sync_sessions/revisit/sessions_page_revisit_observer.cc ('k') | components/syncable_prefs/pref_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698