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

Unified Diff: components/sync/driver/model_association_manager.cc

Issue 2388163002: [Sync] Move //components/sync to the syncer namespace, take 2. (Closed)
Patch Set: Rebase. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: components/sync/driver/model_association_manager.cc
diff --git a/components/sync/driver/model_association_manager.cc b/components/sync/driver/model_association_manager.cc
index 3475c7a32cdae0bb99c2567bd20e831633291f59..14d0b4a9961c36c167bddd0b42e8d445f0219d43 100644
--- a/components/sync/driver/model_association_manager.cc
+++ b/components/sync/driver/model_association_manager.cc
@@ -17,43 +17,37 @@
#include "components/sync/api/sync_merge_result.h"
#include "components/sync/base/model_type.h"
-using syncer::ModelTypeSet;
-
-namespace sync_driver {
+namespace syncer {
namespace {
-static const syncer::ModelType kStartOrder[] = {
- syncer::NIGORI, // Listed for completeness.
- syncer::DEVICE_INFO, // Listed for completeness.
- syncer::EXPERIMENTS, // Listed for completeness.
- syncer::PROXY_TABS, // Listed for completeness.
+static const ModelType kStartOrder[] = {
+ NIGORI, // Listed for completeness.
+ DEVICE_INFO, // Listed for completeness.
+ EXPERIMENTS, // Listed for completeness.
+ PROXY_TABS, // Listed for completeness.
// Kick off the association of the non-UI types first so they can associate
// in parallel with the UI types.
- syncer::PASSWORDS, syncer::AUTOFILL, syncer::AUTOFILL_PROFILE,
- syncer::AUTOFILL_WALLET_DATA, syncer::AUTOFILL_WALLET_METADATA,
- syncer::EXTENSION_SETTINGS, syncer::APP_SETTINGS, syncer::TYPED_URLS,
- syncer::HISTORY_DELETE_DIRECTIVES, syncer::SYNCED_NOTIFICATIONS,
- syncer::SYNCED_NOTIFICATION_APP_INFO,
+ PASSWORDS, AUTOFILL, AUTOFILL_PROFILE, AUTOFILL_WALLET_DATA,
+ AUTOFILL_WALLET_METADATA, EXTENSION_SETTINGS, APP_SETTINGS, TYPED_URLS,
+ HISTORY_DELETE_DIRECTIVES, SYNCED_NOTIFICATIONS,
+ SYNCED_NOTIFICATION_APP_INFO,
// UI thread data types.
- syncer::BOOKMARKS,
- syncer::SUPERVISED_USERS, // Syncing supervised users on initial login
- // might block creating a new supervised user,
- // so we want to do it early.
- syncer::PREFERENCES, syncer::PRIORITY_PREFERENCES, syncer::EXTENSIONS,
- syncer::APPS, syncer::APP_LIST, syncer::ARC_PACKAGE, syncer::READING_LIST,
- syncer::THEMES, syncer::SEARCH_ENGINES, syncer::SESSIONS,
- syncer::APP_NOTIFICATIONS, syncer::DICTIONARY, syncer::FAVICON_IMAGES,
- syncer::FAVICON_TRACKING, syncer::PRINTERS,
- syncer::SUPERVISED_USER_SETTINGS, syncer::SUPERVISED_USER_SHARED_SETTINGS,
- syncer::SUPERVISED_USER_WHITELISTS, syncer::ARTICLES,
- syncer::WIFI_CREDENTIALS,
+ BOOKMARKS,
+ SUPERVISED_USERS, // Syncing supervised users on initial login
+ // might block creating a new supervised user,
+ // so we want to do it early.
+ PREFERENCES, PRIORITY_PREFERENCES, EXTENSIONS, APPS, APP_LIST, ARC_PACKAGE,
+ READING_LIST, THEMES, SEARCH_ENGINES, SESSIONS, APP_NOTIFICATIONS,
+ DICTIONARY, FAVICON_IMAGES, FAVICON_TRACKING, PRINTERS,
+ SUPERVISED_USER_SETTINGS, SUPERVISED_USER_SHARED_SETTINGS,
+ SUPERVISED_USER_WHITELISTS, ARTICLES, WIFI_CREDENTIALS,
};
static_assert(arraysize(kStartOrder) ==
- syncer::MODEL_TYPE_COUNT - syncer::FIRST_REAL_MODEL_TYPE,
+ MODEL_TYPE_COUNT - FIRST_REAL_MODEL_TYPE,
"kStartOrder must have MODEL_TYPE_COUNT - "
"FIRST_REAL_MODEL_TYPE elements");
@@ -62,13 +56,13 @@ static_assert(arraysize(kStartOrder) ==
// unfinished types.
const int64_t kAssociationTimeOutInSeconds = 600;
-syncer::DataTypeAssociationStats BuildAssociationStatsFromMergeResults(
- const syncer::SyncMergeResult& local_merge_result,
- const syncer::SyncMergeResult& syncer_merge_result,
+DataTypeAssociationStats BuildAssociationStatsFromMergeResults(
+ const SyncMergeResult& local_merge_result,
+ const SyncMergeResult& syncer_merge_result,
const base::TimeDelta& association_wait_time,
const base::TimeDelta& association_time) {
DCHECK_EQ(local_merge_result.model_type(), syncer_merge_result.model_type());
- syncer::DataTypeAssociationStats stats;
+ DataTypeAssociationStats stats;
stats.had_error =
local_merge_result.error().IsSet() || syncer_merge_result.error().IsSet();
stats.num_local_items_before_association =
@@ -114,7 +108,7 @@ ModelAssociationManager::ModelAssociationManager(
ModelAssociationManager::~ModelAssociationManager() {}
-void ModelAssociationManager::Initialize(syncer::ModelTypeSet desired_types) {
+void ModelAssociationManager::Initialize(ModelTypeSet desired_types) {
// state_ can be INITIALIZED if types are reconfigured when
// data is being downloaded, so StartAssociationAsync() is never called for
// the first configuration.
@@ -122,14 +116,13 @@ void ModelAssociationManager::Initialize(syncer::ModelTypeSet desired_types) {
// Only keep types that have controllers.
desired_types_.Clear();
- for (syncer::ModelTypeSet::Iterator it = desired_types.First(); it.Good();
- it.Inc()) {
+ for (ModelTypeSet::Iterator it = desired_types.First(); it.Good(); it.Inc()) {
if (controllers_->find(it.Get()) != controllers_->end())
desired_types_.Put(it.Get());
}
DVLOG(1) << "ModelAssociationManager: Initializing for "
- << syncer::ModelTypeSetToString(desired_types_);
+ << ModelTypeSetToString(desired_types_);
state_ = INITIALIZED;
notified_about_ready_for_configure_ = false;
@@ -138,7 +131,7 @@ void ModelAssociationManager::Initialize(syncer::ModelTypeSet desired_types) {
LoadEnabledTypes();
}
-void ModelAssociationManager::StopDatatype(const syncer::SyncError& error,
+void ModelAssociationManager::StopDatatype(const SyncError& error,
DataTypeController* dtc) {
loaded_types_.Remove(dtc->type());
associated_types_.Remove(dtc->type());
@@ -159,7 +152,7 @@ void ModelAssociationManager::StopDisabledTypes() {
if (dtc->state() != DataTypeController::NOT_RUNNING &&
!desired_types_.Has(dtc->type())) {
DVLOG(1) << "ModelAssociationManager: stop " << dtc->name();
- StopDatatype(syncer::SyncError(), dtc);
+ StopDatatype(SyncError(), dtc);
}
}
}
@@ -167,7 +160,7 @@ void ModelAssociationManager::StopDisabledTypes() {
void ModelAssociationManager::LoadEnabledTypes() {
// Load in kStartOrder.
for (size_t i = 0; i < arraysize(kStartOrder); i++) {
- syncer::ModelType type = kStartOrder[i];
+ ModelType type = kStartOrder[i];
if (!desired_types_.Has(type))
continue;
@@ -184,10 +177,10 @@ void ModelAssociationManager::LoadEnabledTypes() {
}
void ModelAssociationManager::StartAssociationAsync(
- const syncer::ModelTypeSet& types_to_associate) {
+ const ModelTypeSet& types_to_associate) {
DCHECK_EQ(INITIALIZED, state_);
DVLOG(1) << "Starting association for "
- << syncer::ModelTypeSetToString(types_to_associate);
+ << ModelTypeSetToString(types_to_associate);
state_ = ASSOCIATING;
association_start_time_ = base::TimeTicks::Now();
@@ -214,7 +207,7 @@ void ModelAssociationManager::StartAssociationAsync(
// Start association of types that are loaded in specified order.
for (size_t i = 0; i < arraysize(kStartOrder); i++) {
- syncer::ModelType type = kStartOrder[i];
+ ModelType type = kStartOrder[i];
if (!associating_types_.Has(type) || !loaded_types_.Has(type))
continue;
@@ -241,7 +234,7 @@ void ModelAssociationManager::Stop() {
it != controllers_->end(); ++it) {
DataTypeController* dtc = (*it).second.get();
if (dtc->state() != DataTypeController::NOT_RUNNING) {
- StopDatatype(syncer::SyncError(), dtc);
+ StopDatatype(SyncError(), dtc);
DVLOG(1) << "ModelAssociationManager: Stopped " << dtc->name();
}
}
@@ -262,18 +255,17 @@ void ModelAssociationManager::Stop() {
}
}
-void ModelAssociationManager::ModelLoadCallback(
- syncer::ModelType type,
- const syncer::SyncError& error) {
+void ModelAssociationManager::ModelLoadCallback(ModelType type,
+ const SyncError& error) {
DVLOG(1) << "ModelAssociationManager: ModelLoadCallback for "
- << syncer::ModelTypeToString(type);
+ << ModelTypeToString(type);
if (error.IsSet()) {
- syncer::SyncMergeResult local_merge_result(type);
+ SyncMergeResult local_merge_result(type);
local_merge_result.set_error(error);
TypeStartCallback(type, base::TimeTicks::Now(),
DataTypeController::ASSOCIATION_FAILED,
- local_merge_result, syncer::SyncMergeResult(type));
+ local_merge_result, SyncMergeResult(type));
return;
}
@@ -302,11 +294,11 @@ void ModelAssociationManager::ModelLoadCallback(
}
void ModelAssociationManager::TypeStartCallback(
- syncer::ModelType type,
+ ModelType type,
base::TimeTicks type_start_time,
DataTypeController::ConfigureResult start_result,
- const syncer::SyncMergeResult& local_merge_result,
- const syncer::SyncMergeResult& syncer_merge_result) {
+ const SyncMergeResult& local_merge_result,
+ const SyncMergeResult& syncer_merge_result) {
if (desired_types_.Has(type) &&
!DataTypeController::IsSuccessfulResult(start_result)) {
DVLOG(1) << "ModelAssociationManager: Type encountered an error.";
@@ -343,14 +335,13 @@ void ModelAssociationManager::TypeStartCallback(
// Track the merge results if we succeeded or an association failure
// occurred.
- if (syncer::ProtocolTypes().Has(type)) {
+ if (ProtocolTypes().Has(type)) {
base::TimeDelta association_wait_time =
std::max(base::TimeDelta(), type_start_time - association_start_time_);
base::TimeDelta association_time = base::TimeTicks::Now() - type_start_time;
- syncer::DataTypeAssociationStats stats =
- BuildAssociationStatsFromMergeResults(
- local_merge_result, syncer_merge_result, association_wait_time,
- association_time);
+ DataTypeAssociationStats stats = BuildAssociationStatsFromMergeResults(
+ local_merge_result, syncer_merge_result, association_wait_time,
+ association_time);
delegate_->OnSingleDataTypeAssociationDone(type, stats);
}
@@ -370,7 +361,7 @@ void ModelAssociationManager::ModelAssociationDone(State new_state) {
}
DVLOG(1) << "Model association complete for "
- << syncer::ModelTypeSetToString(requested_types_);
+ << ModelTypeSetToString(requested_types_);
timer_.Stop();
@@ -383,11 +374,10 @@ void ModelAssociationManager::ModelAssociationDone(State new_state) {
dtc->state() != DataTypeController::NOT_RUNNING) {
UMA_HISTOGRAM_ENUMERATION("Sync.ConfigureFailed",
ModelTypeToHistogramInt(dtc->type()),
- syncer::MODEL_TYPE_COUNT);
- StopDatatype(
- syncer::SyncError(FROM_HERE, syncer::SyncError::DATATYPE_ERROR,
- "Association timed out.", dtc->type()),
- dtc);
+ MODEL_TYPE_COUNT);
+ StopDatatype(SyncError(FROM_HERE, SyncError::DATATYPE_ERROR,
+ "Association timed out.", dtc->type()),
+ dtc);
}
}
@@ -410,7 +400,7 @@ void ModelAssociationManager::NotifyDelegateIfReadyForConfigure() {
if (notified_about_ready_for_configure_)
return;
for (const auto& type_dtc_pair : *controllers_) {
- syncer::ModelType type = type_dtc_pair.first;
+ ModelType type = type_dtc_pair.first;
if (!desired_types_.Has(type))
continue;
DataTypeController* dtc = type_dtc_pair.second.get();
@@ -424,4 +414,4 @@ void ModelAssociationManager::NotifyDelegateIfReadyForConfigure() {
delegate_->OnAllDataTypesReadyForConfigure();
}
-} // namespace sync_driver
+} // namespace syncer
« no previous file with comments | « components/sync/driver/model_association_manager.h ('k') | components/sync/driver/model_association_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698