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

Unified Diff: components/sync/core_impl/sync_manager_impl.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 5 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/core_impl/sync_manager_impl.cc
diff --git a/sync/internal_api/sync_manager_impl.cc b/components/sync/core_impl/sync_manager_impl.cc
similarity index 86%
rename from sync/internal_api/sync_manager_impl.cc
rename to components/sync/core_impl/sync_manager_impl.cc
index cc59e645b06d03c999a4206cb3ea9d19bb22156a..9a0270ce4383ae91ce151d9bf5017918818fef43 100644
--- a/sync/internal_api/sync_manager_impl.cc
+++ b/components/sync/core_impl/sync_manager_impl.cc
@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "sync/internal_api/sync_manager_impl.h"
+#include "components/sync/core_impl/sync_manager_impl.h"
#include <stddef.h>
#include <stdint.h>
+
#include <string>
#include <utility>
@@ -21,33 +22,33 @@
#include "base/strings/string_number_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
-#include "sync/engine/sync_scheduler.h"
-#include "sync/engine/syncer_types.h"
-#include "sync/internal_api/change_reorder_buffer.h"
-#include "sync/internal_api/model_type_connector_proxy.h"
-#include "sync/internal_api/public/base/cancelation_signal.h"
-#include "sync/internal_api/public/base/invalidation_interface.h"
-#include "sync/internal_api/public/base/model_type.h"
-#include "sync/internal_api/public/base_node.h"
-#include "sync/internal_api/public/configure_reason.h"
-#include "sync/internal_api/public/engine/polling_constants.h"
-#include "sync/internal_api/public/http_post_provider_factory.h"
-#include "sync/internal_api/public/internal_components_factory.h"
-#include "sync/internal_api/public/read_node.h"
-#include "sync/internal_api/public/read_transaction.h"
-#include "sync/internal_api/public/user_share.h"
-#include "sync/internal_api/public/util/experiments.h"
-#include "sync/internal_api/public/write_node.h"
-#include "sync/internal_api/public/write_transaction.h"
-#include "sync/internal_api/syncapi_internal.h"
-#include "sync/internal_api/syncapi_server_connection_manager.h"
-#include "sync/protocol/proto_value_conversions.h"
-#include "sync/protocol/sync.pb.h"
-#include "sync/sessions/directory_type_debug_info_emitter.h"
-#include "sync/syncable/directory.h"
-#include "sync/syncable/entry.h"
-#include "sync/syncable/in_memory_directory_backing_store.h"
-#include "sync/syncable/on_disk_directory_backing_store.h"
+#include "components/sync/base/cancelation_signal.h"
+#include "components/sync/base/experiments.h"
+#include "components/sync/base/invalidation_interface.h"
+#include "components/sync/base/model_type.h"
+#include "components/sync/core/base_node.h"
+#include "components/sync/core/configure_reason.h"
+#include "components/sync/core/http_post_provider_factory.h"
+#include "components/sync/core/internal_components_factory.h"
+#include "components/sync/core/read_node.h"
+#include "components/sync/core/read_transaction.h"
+#include "components/sync/core/user_share.h"
+#include "components/sync/core/write_node.h"
+#include "components/sync/core/write_transaction.h"
+#include "components/sync/core_impl/change_reorder_buffer.h"
+#include "components/sync/core_impl/model_type_connector_proxy.h"
+#include "components/sync/core_impl/syncapi_internal.h"
+#include "components/sync/core_impl/syncapi_server_connection_manager.h"
+#include "components/sync/engine/polling_constants.h"
+#include "components/sync/engine_impl/sync_scheduler.h"
+#include "components/sync/engine_impl/syncer_types.h"
+#include "components/sync/protocol/proto_value_conversions.h"
+#include "components/sync/protocol/sync.pb.h"
+#include "components/sync/sessions_impl/directory_type_debug_info_emitter.h"
+#include "components/sync/syncable/directory.h"
+#include "components/sync/syncable/entry.h"
+#include "components/sync/syncable/in_memory_directory_backing_store.h"
+#include "components/sync/syncable/on_disk_directory_backing_store.h"
using base::TimeDelta;
using sync_pb::GetUpdatesCallerInfo;
@@ -144,8 +145,7 @@ bool SyncManagerImpl::VisiblePropertiesDiffer(
}
if (a.ref(syncable::IS_DIR) != b.ref(syncable::IS_DIR))
return true;
- if (!AreSpecificsEqual(cryptographer,
- a.ref(syncable::SPECIFICS),
+ if (!AreSpecificsEqual(cryptographer, a.ref(syncable::SPECIFICS),
b.ref(syncable::SPECIFICS))) {
return true;
}
@@ -195,19 +195,16 @@ void SyncManagerImpl::ConfigureSyncer(
DCHECK(initialized_);
DVLOG(1) << "Configuring -"
- << "\n\t" << "current types: "
+ << "\n\t"
+ << "current types: "
<< ModelTypeSetToString(GetRoutingInfoTypes(new_routing_info))
- << "\n\t" << "types to download: "
- << ModelTypeSetToString(to_download)
- << "\n\t" << "types to purge: "
- << ModelTypeSetToString(to_purge)
- << "\n\t" << "types to journal: "
- << ModelTypeSetToString(to_journal)
- << "\n\t" << "types to unapply: "
- << ModelTypeSetToString(to_unapply);
- if (!PurgeDisabledTypes(to_purge,
- to_journal,
- to_unapply)) {
+ << "\n\t"
+ << "types to download: " << ModelTypeSetToString(to_download)
+ << "\n\t"
+ << "types to purge: " << ModelTypeSetToString(to_purge) << "\n\t"
+ << "types to journal: " << ModelTypeSetToString(to_journal) << "\n\t"
+ << "types to unapply: " << ModelTypeSetToString(to_unapply);
+ if (!PurgeDisabledTypes(to_purge, to_journal, to_unapply)) {
// We failed to cleanup the types. Invoke the ready task without actually
// configuring any types. The caller should detect this as a configuration
// failure and act appropriately.
@@ -215,11 +212,8 @@ void SyncManagerImpl::ConfigureSyncer(
return;
}
- ConfigurationParams params(GetSourceFromReason(reason),
- to_download,
- new_routing_info,
- ready_task,
- retry_task);
+ ConfigurationParams params(GetSourceFromReason(reason), to_download,
+ new_routing_info, ready_task, retry_task);
scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time());
scheduler_->ScheduleConfiguration(params);
@@ -267,13 +261,10 @@ void SyncManagerImpl::Init(InitArgs* args) {
args->credentials.account_id, absolute_db_path);
DCHECK(backing_store.get());
- share_.directory.reset(
- new syncable::Directory(
- backing_store.release(),
- args->unrecoverable_error_handler,
- report_unrecoverable_error_function_,
- sync_encryption_handler_.get(),
- sync_encryption_handler_->GetCryptographerUnsafe()));
+ share_.directory.reset(new syncable::Directory(
+ backing_store.release(), args->unrecoverable_error_handler,
+ report_unrecoverable_error_function_, sync_encryption_handler_.get(),
+ sync_encryption_handler_->GetCryptographerUnsafe()));
share_.sync_credentials = args->credentials;
// UserShare is accessible to a lot of code that doesn't need access to the
@@ -398,8 +389,7 @@ void SyncManagerImpl::OnPassphraseTypeChanged(
}
void SyncManagerImpl::OnLocalSetPassphraseEncryption(
- const SyncEncryptionHandler::NigoriState& nigori_state) {
-}
+ const SyncEncryptionHandler::NigoriState& nigori_state) {}
void SyncManagerImpl::StartSyncingNormally(
const ModelSafeRoutingInfo& routing_info,
@@ -411,8 +401,7 @@ void SyncManagerImpl::StartSyncingNormally(
// mode.
DCHECK(thread_checker_.CalledOnValidThread());
session_context_->SetRoutingInfo(routing_info);
- scheduler_->Start(SyncScheduler::NORMAL_MODE,
- last_poll_time);
+ scheduler_->Start(SyncScheduler::NORMAL_MODE, last_poll_time);
}
syncable::Directory* SyncManagerImpl::directory() {
@@ -462,8 +451,8 @@ bool SyncManagerImpl::OpenDirectory(const std::string& username) {
bool SyncManagerImpl::PurgePartiallySyncedTypes() {
ModelTypeSet partially_synced_types = ModelTypeSet::All();
partially_synced_types.RemoveAll(directory()->InitialSyncEndedTypes());
- partially_synced_types.RemoveAll(GetTypesWithEmptyProgressMarkerToken(
- ModelTypeSet::All()));
+ partially_synced_types.RemoveAll(
+ GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()));
DVLOG(1) << "Purging partially synced types "
<< ModelTypeSetToString(partially_synced_types);
@@ -472,14 +461,12 @@ bool SyncManagerImpl::PurgePartiallySyncedTypes() {
if (partially_synced_types.Empty())
return true;
return directory()->PurgeEntriesWithTypeIn(partially_synced_types,
- ModelTypeSet(),
- ModelTypeSet());
+ ModelTypeSet(), ModelTypeSet());
}
-bool SyncManagerImpl::PurgeDisabledTypes(
- ModelTypeSet to_purge,
- ModelTypeSet to_journal,
- ModelTypeSet to_unapply) {
+bool SyncManagerImpl::PurgeDisabledTypes(ModelTypeSet to_purge,
+ ModelTypeSet to_journal,
+ ModelTypeSet to_unapply) {
if (to_purge.Empty())
return true;
DVLOG(1) << "Purging disabled types " << ModelTypeSetToString(to_purge);
@@ -579,7 +566,7 @@ void SyncManagerImpl::OnIPAddressChanged() {
}
void SyncManagerImpl::OnConnectionTypeChanged(
- net::NetworkChangeNotifier::ConnectionType) {
+ net::NetworkChangeNotifier::ConnectionType) {
if (!observing_network_connectivity_changes_) {
DVLOG(1) << "Connection type change dropped.";
return;
@@ -596,8 +583,7 @@ void SyncManagerImpl::OnNetworkConnectivityChangedImpl() {
void SyncManagerImpl::OnServerConnectionEvent(
const ServerConnectionEvent& event) {
DCHECK(thread_checker_.CalledOnValidThread());
- if (event.connection_code ==
- HttpResponse::SERVER_CONNECTION_OK) {
+ if (event.connection_code == HttpResponse::SERVER_CONNECTION_OK) {
FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
OnConnectionStatusChange(CONNECTION_OK));
}
@@ -623,18 +609,15 @@ void SyncManagerImpl::HandleTransactionCompleteChangeEvent(
return;
// Call commit.
- for (ModelTypeSet::Iterator it = models_with_changes.First();
- it.Good(); it.Inc()) {
+ for (ModelTypeSet::Iterator it = models_with_changes.First(); it.Good();
+ it.Inc()) {
change_delegate_->OnChangesComplete(it.Get());
change_observer_.Call(
- FROM_HERE,
- &SyncManager::ChangeObserver::OnChangesComplete,
- it.Get());
+ FROM_HERE, &SyncManager::ChangeObserver::OnChangesComplete, it.Get());
}
}
-ModelTypeSet
-SyncManagerImpl::HandleTransactionEndingChangeEvent(
+ModelTypeSet SyncManagerImpl::HandleTransactionEndingChangeEvent(
const ImmutableWriteTransactionInfo& write_transaction_info,
syncable::BaseTransaction* trans) {
// This notification happens immediately before a syncable WriteTransaction
@@ -651,15 +634,15 @@ SyncManagerImpl::HandleTransactionEndingChangeEvent(
ModelTypeSet models_with_changes;
for (ChangeRecordMap::const_iterator it = change_records_.begin();
- it != change_records_.end(); ++it) {
+ it != change_records_.end(); ++it) {
DCHECK(!it->second.Get().empty());
ModelType type = ModelTypeFromInt(it->first);
- change_delegate_->
- OnChangesApplied(type, trans->directory()->GetTransactionVersion(type),
- &read_trans, it->second);
+ change_delegate_->OnChangesApplied(
+ type, trans->directory()->GetTransactionVersion(type), &read_trans,
+ it->second);
change_observer_.Call(FROM_HERE,
- &SyncManager::ChangeObserver::OnChangesApplied,
- type, write_transaction_info.Get().id, it->second);
+ &SyncManager::ChangeObserver::OnChangesApplied, type,
+ write_transaction_info.Get().id, it->second);
models_with_changes.Put(type);
}
change_records_.clear();
@@ -671,8 +654,8 @@ void SyncManagerImpl::HandleCalculateChangesChangeEventFromSyncApi(
syncable::BaseTransaction* trans,
std::vector<int64_t>* entries_changed) {
// We have been notified about a user action changing a sync model.
- LOG_IF(WARNING, !change_records_.empty()) <<
- "CALCULATE_CHANGES called with unapplied old changes.";
+ LOG_IF(WARNING, !change_records_.empty())
+ << "CALCULATE_CHANGES called with unapplied old changes.";
// The mutated model type, or UNSPECIFIED if nothing was mutated.
ModelTypeSet mutated_model_types;
@@ -680,7 +663,8 @@ void SyncManagerImpl::HandleCalculateChangesChangeEventFromSyncApi(
const syncable::ImmutableEntryKernelMutationMap& mutations =
write_transaction_info.Get().mutations;
for (syncable::EntryKernelMutationMap::const_iterator it =
- mutations.Get().begin(); it != mutations.Get().end(); ++it) {
+ mutations.Get().begin();
+ it != mutations.Get().end(); ++it) {
if (!it->second.mutated.ref(syncable::IS_UNSYNCED)) {
continue;
}
@@ -704,8 +688,7 @@ void SyncManagerImpl::HandleCalculateChangesChangeEventFromSyncApi(
if (weak_handle_this_.IsInitialized()) {
weak_handle_this_.Call(FROM_HERE,
&SyncManagerImpl::RequestNudgeForDataTypes,
- FROM_HERE,
- mutated_model_types);
+ FROM_HERE, mutated_model_types);
} else {
NOTREACHED();
}
@@ -752,8 +735,8 @@ void SyncManagerImpl::HandleCalculateChangesChangeEventFromSyncer(
std::vector<int64_t>* entries_changed) {
// We only expect one notification per sync step, so change_buffers_ should
// contain no pending entries.
- LOG_IF(WARNING, !change_records_.empty()) <<
- "CALCULATE_CHANGES called with unapplied old changes.";
+ LOG_IF(WARNING, !change_records_.empty())
+ << "CALCULATE_CHANGES called with unapplied old changes.";
ChangeReorderBuffer change_buffers[MODEL_TYPE_COUNT];
@@ -761,7 +744,8 @@ void SyncManagerImpl::HandleCalculateChangesChangeEventFromSyncer(
const syncable::ImmutableEntryKernelMutationMap& mutations =
write_transaction_info.Get().mutations;
for (syncable::EntryKernelMutationMap::const_iterator it =
- mutations.Get().begin(); it != mutations.Get().end(); ++it) {
+ mutations.Get().begin();
+ it != mutations.Get().end(); ++it) {
bool existed_before = !it->second.original.ref(syncable::IS_DEL);
bool exists_now = !it->second.mutated.ref(syncable::IS_DEL);
@@ -844,9 +828,8 @@ void SyncManagerImpl::OnSyncCycleEvent(const SyncCycleEvent& event) {
}
void SyncManagerImpl::OnActionableError(const SyncProtocolError& error) {
- FOR_EACH_OBSERVER(
- SyncManager::Observer, observers_,
- OnActionableError(error));
+ FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
+ OnActionableError(error));
}
void SyncManagerImpl::OnRetryTimeChanged(base::Time) {}
@@ -854,15 +837,13 @@ void SyncManagerImpl::OnRetryTimeChanged(base::Time) {}
void SyncManagerImpl::OnThrottledTypesChanged(ModelTypeSet) {}
void SyncManagerImpl::OnMigrationRequested(ModelTypeSet types) {
- FOR_EACH_OBSERVER(
- SyncManager::Observer, observers_,
- OnMigrationRequested(types));
+ FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
+ OnMigrationRequested(types));
}
void SyncManagerImpl::OnProtocolEvent(const ProtocolEvent& event) {
protocol_event_buffer_.RecordProtocolEvent(event);
- FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
- OnProtocolEvent(event));
+ FOR_EACH_OBSERVER(SyncManager::Observer, observers_, OnProtocolEvent(event));
}
void SyncManagerImpl::SetJsEventHandler(
@@ -912,8 +893,7 @@ void SyncManagerImpl::RefreshTypes(ModelTypeSet types) {
if (types.Empty()) {
LOG(WARNING) << "Sync received refresh request with no types specified.";
} else {
- scheduler_->ScheduleLocalRefreshRequest(
- types, FROM_HERE);
+ scheduler_->ScheduleLocalRefreshRequest(types, FROM_HERE);
}
}
@@ -953,21 +933,22 @@ bool SyncManagerImpl::ReceivedExperiment(Experiments* experiments) {
ReadNode favicon_sync_node(&trans);
if (favicon_sync_node.InitByClientTagLookup(
- syncer::EXPERIMENTS,
- syncer::kFaviconSyncTag) == BaseNode::INIT_OK) {
+ syncer::EXPERIMENTS, syncer::kFaviconSyncTag) == BaseNode::INIT_OK) {
experiments->favicon_sync_limit =
- favicon_sync_node.GetExperimentsSpecifics().favicon_sync().
- favicon_sync_limit();
+ favicon_sync_node.GetExperimentsSpecifics()
+ .favicon_sync()
+ .favicon_sync_limit();
found_experiment = true;
}
ReadNode pre_commit_update_avoidance_node(&trans);
if (pre_commit_update_avoidance_node.InitByClientTagLookup(
- syncer::EXPERIMENTS,
- syncer::kPreCommitUpdateAvoidanceTag) == BaseNode::INIT_OK) {
+ syncer::EXPERIMENTS, syncer::kPreCommitUpdateAvoidanceTag) ==
+ BaseNode::INIT_OK) {
session_context_->set_server_enabled_pre_commit_update_avoidance(
- pre_commit_update_avoidance_node.GetExperimentsSpecifics().
- pre_commit_update_avoidance().enabled());
+ pre_commit_update_avoidance_node.GetExperimentsSpecifics()
+ .pre_commit_update_avoidance()
+ .enabled());
// We don't bother setting found_experiment. The frontend doesn't need to
// know about this.
}
@@ -997,7 +978,7 @@ SyncEncryptionHandler* SyncManagerImpl::GetEncryptionHandler() {
}
ScopedVector<syncer::ProtocolEvent>
- SyncManagerImpl::GetBufferedProtocolEvents() {
+SyncManagerImpl::GetBufferedProtocolEvents() {
return protocol_event_buffer_.GetBufferedProtocolEvents();
}
« no previous file with comments | « components/sync/core_impl/sync_manager_impl.h ('k') | components/sync/core_impl/sync_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698