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

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

Issue 2203673002: [Sync] Move //components/sync_driver to //components/sync/driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sd-a
Patch Set: Full change rebased on static lib. Created 4 years, 4 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/generic_change_processor.cc
diff --git a/components/sync_driver/generic_change_processor.cc b/components/sync/driver/generic_change_processor.cc
similarity index 89%
rename from components/sync_driver/generic_change_processor.cc
rename to components/sync/driver/generic_change_processor.cc
index 581b565a82bfe9283f5443b4653ada9b2b628db9..f7abe0506bd0ca258640018106c4268b20db0024 100644
--- a/components/sync_driver/generic_change_processor.cc
+++ b/components/sync/driver/generic_change_processor.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/sync_driver/generic_change_processor.h"
+#include "components/sync/driver/generic_change_processor.h"
#include <stddef.h>
@@ -25,9 +25,9 @@
#include "components/sync/core/read_transaction.h"
#include "components/sync/core/write_node.h"
#include "components/sync/core/write_transaction.h"
+#include "components/sync/driver/sync_api_component_factory.h"
+#include "components/sync/driver/sync_client.h"
#include "components/sync/syncable/entry.h" // TODO(tim): Bug 123674.
-#include "components/sync_driver/sync_api_component_factory.h"
-#include "components/sync_driver/sync_client.h"
namespace sync_driver {
@@ -38,7 +38,7 @@ const int kContextSizeLimit = 1024; // Datatype context size limit.
void SetNodeSpecifics(const sync_pb::EntitySpecifics& entity_specifics,
syncer::WriteNode* write_node) {
if (syncer::GetModelTypeFromSpecifics(entity_specifics) ==
- syncer::PASSWORDS) {
+ syncer::PASSWORDS) {
write_node->SetPasswordSpecifics(
entity_specifics.password().client_only_encrypted_data());
} else {
@@ -60,8 +60,7 @@ void SetAttachmentMetadata(const syncer::AttachmentIdList& attachment_ids,
DCHECK(write_node);
sync_pb::AttachmentMetadata attachment_metadata;
std::transform(
- attachment_ids.begin(),
- attachment_ids.end(),
+ attachment_ids.begin(), attachment_ids.end(),
RepeatedFieldBackInserter(attachment_metadata.mutable_record()),
AttachmentIdToRecord);
write_node->SetAttachmentMetadata(attachment_metadata);
@@ -157,15 +156,16 @@ void GenericChangeProcessor::ApplyChangesFromSyncModel(
const syncer::ImmutableChangeRecordList& changes) {
DCHECK(CalledOnValidThread());
DCHECK(syncer_changes_.empty());
- for (syncer::ChangeRecordList::const_iterator it =
- changes.Get().begin(); it != changes.Get().end(); ++it) {
+ for (syncer::ChangeRecordList::const_iterator it = changes.Get().begin();
+ it != changes.Get().end(); ++it) {
if (it->action == syncer::ChangeRecord::ACTION_DELETE) {
std::unique_ptr<sync_pb::EntitySpecifics> specifics;
if (it->specifics.has_password()) {
DCHECK(it->extra.get());
specifics.reset(new sync_pb::EntitySpecifics(it->specifics));
- specifics->mutable_password()->mutable_client_only_encrypted_data()->
- CopyFrom(it->extra->unencrypted());
+ specifics->mutable_password()
+ ->mutable_client_only_encrypted_data()
+ ->CopyFrom(it->extra->unencrypted());
}
const syncer::AttachmentIdList empty_list_of_attachment_ids;
syncer_changes_.push_back(syncer::SyncChange(
@@ -175,14 +175,14 @@ void GenericChangeProcessor::ApplyChangesFromSyncModel(
empty_list_of_attachment_ids, attachment_service_proxy_)));
} else {
syncer::SyncChange::SyncChangeType action =
- (it->action == syncer::ChangeRecord::ACTION_ADD) ?
- syncer::SyncChange::ACTION_ADD : syncer::SyncChange::ACTION_UPDATE;
+ (it->action == syncer::ChangeRecord::ACTION_ADD)
+ ? syncer::SyncChange::ACTION_ADD
+ : syncer::SyncChange::ACTION_UPDATE;
// Need to load specifics from node.
syncer::ReadNode read_node(trans);
if (read_node.InitByIdLookup(it->id) != syncer::BaseNode::INIT_OK) {
syncer::SyncError error(
- FROM_HERE,
- syncer::SyncError::DATATYPE_ERROR,
+ FROM_HERE, syncer::SyncError::DATATYPE_ERROR,
"Failed to look up data for received change with id " +
base::Int64ToString(it->id),
syncer::GetModelTypeFromSpecifics(it->specifics));
@@ -202,15 +202,13 @@ void GenericChangeProcessor::CommitChangesFromSyncModel() {
return;
if (!local_service_.get()) {
syncer::ModelType type = syncer_changes_[0].sync_data().GetDataType();
- syncer::SyncError error(FROM_HERE,
- syncer::SyncError::DATATYPE_ERROR,
- "Local service destroyed.",
- type);
+ syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR,
+ "Local service destroyed.", type);
error_handler()->OnSingleDataTypeUnrecoverableError(error);
return;
}
- syncer::SyncError error = local_service_->ProcessSyncChanges(FROM_HERE,
- syncer_changes_);
+ syncer::SyncError error =
+ local_service_->ProcessSyncChanges(FROM_HERE, syncer_changes_);
syncer_changes_.clear();
if (error.IsSet())
error_handler()->OnSingleDataTypeUnrecoverableError(error);
@@ -233,10 +231,8 @@ syncer::SyncError GenericChangeProcessor::UpdateDataTypeContext(
DCHECK_EQ(type_, type);
if (context.size() > static_cast<size_t>(kContextSizeLimit)) {
- return syncer::SyncError(FROM_HERE,
- syncer::SyncError::DATATYPE_ERROR,
- "Context size limit exceeded.",
- type);
+ return syncer::SyncError(FROM_HERE, syncer::SyncError::DATATYPE_ERROR,
+ "Context size limit exceeded.", type);
}
syncer::WriteTransaction trans(FROM_HERE, share_handle());
@@ -261,8 +257,7 @@ syncer::SyncError GenericChangeProcessor::GetAllSyncDataReturnError(
syncer::ReadTransaction trans(FROM_HERE, share_handle());
syncer::ReadNode root(&trans);
if (root.InitTypeRoot(type_) != syncer::BaseNode::INIT_OK) {
- syncer::SyncError error(FROM_HERE,
- syncer::SyncError::DATATYPE_ERROR,
+ syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR,
"Server did not create the top-level " + type_name +
" node. We might be running against an out-of-"
"date server.",
@@ -279,13 +274,10 @@ syncer::SyncError GenericChangeProcessor::GetAllSyncDataReturnError(
for (std::vector<int64_t>::iterator it = child_ids.begin();
it != child_ids.end(); ++it) {
syncer::ReadNode sync_child_node(&trans);
- if (sync_child_node.InitByIdLookup(*it) !=
- syncer::BaseNode::INIT_OK) {
+ if (sync_child_node.InitByIdLookup(*it) != syncer::BaseNode::INIT_OK) {
syncer::SyncError error(
- FROM_HERE,
- syncer::SyncError::DATATYPE_ERROR,
- "Failed to fetch child node for type " + type_name + ".",
- type_);
+ FROM_HERE, syncer::SyncError::DATATYPE_ERROR,
+ "Failed to fetch child node for type " + type_name + ".", type_);
return error;
}
current_sync_data->push_back(BuildRemoteSyncData(
@@ -301,9 +293,8 @@ bool GenericChangeProcessor::GetDataTypeContext(std::string* context) const {
if (!context_proto.has_context())
return false;
- DCHECK_EQ(type_,
- syncer::GetModelTypeFromSpecificsFieldNumber(
- context_proto.data_type_id()));
+ DCHECK_EQ(type_, syncer::GetModelTypeFromSpecificsFieldNumber(
+ context_proto.data_type_id()));
*context = context_proto.context();
return true;
}
@@ -333,10 +324,10 @@ syncer::SyncError LogLookupFailure(
switch (lookup_result) {
case syncer::BaseNode::INIT_FAILED_ENTRY_NOT_GOOD: {
syncer::SyncError error;
- error.Reset(from_here,
- error_prefix +
- "could not find entry matching the lookup criteria.",
- type);
+ error.Reset(
+ from_here,
+ error_prefix + "could not find entry matching the lookup criteria.",
+ type);
error_handler->OnSingleDataTypeUnrecoverableError(error);
LOG(ERROR) << "Delete: Bad entry.";
return error;
@@ -384,12 +375,11 @@ syncer::SyncError AttemptDelete(const syncer::SyncChange& change,
if (change.sync_data().IsLocal()) {
const std::string& tag = syncer::SyncDataLocal(change.sync_data()).GetTag();
if (tag.empty()) {
- syncer::SyncError error(
- FROM_HERE,
- syncer::SyncError::DATATYPE_ERROR,
- "Failed to delete " + type_str + " node. Local data, empty tag. " +
- change.location().ToString(),
- type);
+ syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR,
+ "Failed to delete " + type_str +
+ " node. Local data, empty tag. " +
+ change.location().ToString(),
+ type);
error_handler->OnSingleDataTypeUnrecoverableError(error);
NOTREACHED();
return error;
@@ -398,21 +388,21 @@ syncer::SyncError AttemptDelete(const syncer::SyncChange& change,
syncer::BaseNode::InitByLookupResult result =
node->InitByClientTagLookup(change.sync_data().GetDataType(), tag);
if (result != syncer::BaseNode::INIT_OK) {
- return LogLookupFailure(
- result, FROM_HERE,
- "Failed to delete " + type_str + " node. Local data. " +
- change.location().ToString(),
- type, error_handler);
+ return LogLookupFailure(result, FROM_HERE,
+ "Failed to delete " + type_str +
+ " node. Local data. " +
+ change.location().ToString(),
+ type, error_handler);
}
} else {
syncer::BaseNode::InitByLookupResult result = node->InitByIdLookup(
syncer::SyncDataRemote(change.sync_data()).GetId());
if (result != syncer::BaseNode::INIT_OK) {
- return LogLookupFailure(
- result, FROM_HERE,
- "Failed to delete " + type_str + " node. Non-local data. " +
- change.location().ToString(),
- type, error_handler);
+ return LogLookupFailure(result, FROM_HERE,
+ "Failed to delete " + type_str +
+ " node. Non-local data. " +
+ change.location().ToString(),
+ type, error_handler);
}
}
if (IsActOnceDataType(type))
@@ -441,8 +431,7 @@ syncer::SyncError GenericChangeProcessor::ProcessSyncChanges(
syncer::WriteTransaction trans(from_here, share_handle());
for (syncer::SyncChangeList::const_iterator iter = list_of_changes.begin();
- iter != list_of_changes.end();
- ++iter) {
+ iter != list_of_changes.end(); ++iter) {
const syncer::SyncChange& change = *iter;
DCHECK_EQ(change.sync_data().GetDataType(), type_);
std::string type_str = syncer::ModelTypeToString(type_);
@@ -459,8 +448,8 @@ syncer::SyncError GenericChangeProcessor::ProcessSyncChanges(
merge_result_->num_items_deleted() + 1);
}
} else if (change.change_type() == syncer::SyncChange::ACTION_ADD) {
- syncer::SyncError error = HandleActionAdd(
- change, type_str, trans, &sync_node, &new_attachments);
+ syncer::SyncError error = HandleActionAdd(change, type_str, trans,
+ &sync_node, &new_attachments);
if (error.IsSet()) {
return error;
}
@@ -472,8 +461,7 @@ syncer::SyncError GenericChangeProcessor::ProcessSyncChanges(
}
} else {
syncer::SyncError error(
- FROM_HERE,
- syncer::SyncError::DATATYPE_ERROR,
+ FROM_HERE, syncer::SyncError::DATATYPE_ERROR,
"Received unset SyncChange in the change processor, " +
change.location().ToString(),
type_);
@@ -489,8 +477,7 @@ syncer::SyncError GenericChangeProcessor::ProcessSyncChanges(
// which would initialize attachment_service_. Fail if it isn't so.
if (!attachment_service_.get()) {
syncer::SyncError error(
- FROM_HERE,
- syncer::SyncError::DATATYPE_ERROR,
+ FROM_HERE, syncer::SyncError::DATATYPE_ERROR,
"Datatype performs attachment operation without initializing "
"attachment store",
type_);
@@ -544,8 +531,8 @@ syncer::SyncError GenericChangeProcessor::HandleActionAdd(
}
case syncer::WriteNode::INIT_FAILED_SET_PREDECESSOR: {
syncer::SyncError error;
- error.Reset(
- FROM_HERE, error_prefix + "failed to set predecessor", type_);
+ error.Reset(FROM_HERE, error_prefix + "failed to set predecessor",
+ type_);
error_handler()->OnSingleDataTypeUnrecoverableError(error);
LOG(ERROR) << "Create: Bad predecessor.";
return error;
@@ -651,7 +638,8 @@ bool GenericChangeProcessor::SyncModelHasUserCreatedNodes(bool* has_nodes) {
DCHECK(CalledOnValidThread());
DCHECK(has_nodes);
std::string type_name = syncer::ModelTypeToString(type_);
- std::string err_str = "Server did not create the top-level " + type_name +
+ std::string err_str =
+ "Server did not create the top-level " + type_name +
" node. We might be running against an out-of-date server.";
*has_nodes = false;
syncer::ReadTransaction trans(FROM_HERE, share_handle());
@@ -675,8 +663,7 @@ bool GenericChangeProcessor::CryptoReadyIfNecessary() {
return !encrypted_types.Has(type_) || trans.GetCryptographer()->is_ready();
}
-void GenericChangeProcessor::StartImpl() {
-}
+void GenericChangeProcessor::StartImpl() {}
syncer::UserShare* GenericChangeProcessor::share_handle() const {
DCHECK(CalledOnValidThread());
« no previous file with comments | « components/sync/driver/generic_change_processor.h ('k') | components/sync/driver/generic_change_processor_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698