summaryrefslogtreecommitdiff
path: root/sync
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2013-08-30 15:14:49 +0100
committerTorne (Richard Coles) <torne@google.com>2013-08-30 15:14:49 +0100
commit424c4d7b64af9d0d8fd9624f381f469654d5e3d2 (patch)
treeaf8b16dc2ba7fc8c8bb1c9fa18b907c847f3883d /sync
parentc70ef2906f891fe7d218980660e4cda465717916 (diff)
downloadchromium_org-424c4d7b64af9d0d8fd9624f381f469654d5e3d2.tar.gz
Merge from Chromium at DEPS revision r220549
This commit was generated by merge_to_master.py. Change-Id: I8fcb82db764ec1eb0294280936c177bd9ba8a9e9
Diffstat (limited to 'sync')
-rw-r--r--sync/engine/build_commit_command.cc171
-rw-r--r--sync/engine/build_commit_command.h5
-rw-r--r--sync/js/sync_js_controller.cc2
-rw-r--r--sync/protocol/proto_value_conversions.cc29
-rw-r--r--sync/protocol/proto_value_conversions.h13
-rw-r--r--sync/protocol/session_specifics.proto2
-rw-r--r--sync/syncable/syncable_base_transaction.cc9
-rw-r--r--sync/syncable/syncable_base_transaction.h3
-rw-r--r--sync/tools/sync_client.cc3
9 files changed, 149 insertions, 88 deletions
diff --git a/sync/engine/build_commit_command.cc b/sync/engine/build_commit_command.cc
index 0143370f04..53c522122b 100644
--- a/sync/engine/build_commit_command.cc
+++ b/sync/engine/build_commit_command.cc
@@ -98,14 +98,14 @@ void BuildCommitCommand::AddClientConfigParamsToMessage(
}
namespace {
-void SetEntrySpecifics(Entry* meta_entry,
+void SetEntrySpecifics(const Entry& meta_entry,
sync_pb::SyncEntity* sync_entry) {
// Add the new style extension and the folder bit.
- sync_entry->mutable_specifics()->CopyFrom(meta_entry->Get(SPECIFICS));
- sync_entry->set_folder(meta_entry->Get(syncable::IS_DIR));
+ sync_entry->mutable_specifics()->CopyFrom(meta_entry.Get(SPECIFICS));
+ sync_entry->set_folder(meta_entry.Get(syncable::IS_DIR));
CHECK(!sync_entry->specifics().password().has_client_only_encrypted_data());
- DCHECK_EQ(meta_entry->GetModelType(), GetModelType(*sync_entry));
+ DCHECK_EQ(meta_entry.GetModelType(), GetModelType(*sync_entry));
}
} // namespace
@@ -121,7 +121,7 @@ SyncerError BuildCommitCommand::ExecuteImpl(SyncSession* session) {
for (size_t i = 0; i < batch_commit_set_.Size(); i++) {
Id id = batch_commit_set_.GetCommitIdAt(i);
sync_pb::SyncEntity* sync_entry = commit_message->add_entries();
- sync_entry->set_id_string(SyncableIdToProto(id));
+
Entry meta_entry(trans_, syncable::GET_BY_ID, id);
CHECK(meta_entry.good());
@@ -130,85 +130,96 @@ SyncerError BuildCommitCommand::ExecuteImpl(SyncSession* session) {
meta_entry.GetModelType()))
<< "Committing change to datatype that's not actively enabled.";
- string name = meta_entry.Get(syncable::NON_UNIQUE_NAME);
- CHECK(!name.empty()); // Make sure this isn't an update.
- // Note: Truncation is also performed in WriteNode::SetTitle(..). But this
- // call is still necessary to handle any title changes that might originate
- // elsewhere, or already be persisted in the directory.
- TruncateUTF8ToByteSize(name, 255, &name);
- sync_entry->set_name(name);
-
- // Set the non_unique_name. If we do, the server ignores
- // the |name| value (using |non_unique_name| instead), and will return
- // in the CommitResponse a unique name if one is generated.
- // We send both because it may aid in logging.
- sync_entry->set_non_unique_name(name);
-
- if (!meta_entry.Get(syncable::UNIQUE_CLIENT_TAG).empty()) {
- sync_entry->set_client_defined_unique_tag(
- meta_entry.Get(syncable::UNIQUE_CLIENT_TAG));
- }
+ BuildCommitItem(meta_entry, sync_entry);
+ }
- // Deleted items with server-unknown parent ids can be a problem so we set
- // the parent to 0. (TODO(sync): Still true in protocol?).
- Id new_parent_id;
- if (meta_entry.Get(syncable::IS_DEL) &&
- !meta_entry.Get(syncable::PARENT_ID).ServerKnows()) {
- new_parent_id = trans_->root_id();
- } else {
- new_parent_id = meta_entry.Get(syncable::PARENT_ID);
- }
- sync_entry->set_parent_id_string(SyncableIdToProto(new_parent_id));
-
- // If our parent has changed, send up the old one so the server
- // can correctly deal with multiple parents.
- // TODO(nick): With the server keeping track of the primary sync parent,
- // it should not be necessary to provide the old_parent_id: the version
- // number should suffice.
- if (new_parent_id != meta_entry.Get(syncable::SERVER_PARENT_ID) &&
- 0 != meta_entry.Get(syncable::BASE_VERSION) &&
- syncable::CHANGES_VERSION != meta_entry.Get(syncable::BASE_VERSION)) {
- sync_entry->set_old_parent_id(
- SyncableIdToProto(meta_entry.Get(syncable::SERVER_PARENT_ID)));
- }
- int64 version = meta_entry.Get(syncable::BASE_VERSION);
- if (syncable::CHANGES_VERSION == version || 0 == version) {
- // Undeletions are only supported for items that have a client tag.
- DCHECK(!id.ServerKnows() ||
- !meta_entry.Get(syncable::UNIQUE_CLIENT_TAG).empty())
- << meta_entry;
-
- // Version 0 means to create or undelete an object.
- sync_entry->set_version(0);
- } else {
- DCHECK(id.ServerKnows()) << meta_entry;
- sync_entry->set_version(meta_entry.Get(syncable::BASE_VERSION));
- }
- sync_entry->set_ctime(TimeToProtoTime(meta_entry.Get(syncable::CTIME)));
- sync_entry->set_mtime(TimeToProtoTime(meta_entry.Get(syncable::MTIME)));
-
- // Deletion is final on the server, let's move things and then delete them.
- if (meta_entry.Get(IS_DEL)) {
- sync_entry->set_deleted(true);
- } else {
- if (meta_entry.Get(SPECIFICS).has_bookmark()) {
- // Both insert_after_item_id and position_in_parent fields are set only
- // for legacy reasons. See comments in sync.proto for more information.
- const Id& prev_id = meta_entry.GetPredecessorId();
- string prev_id_string =
- prev_id.IsRoot() ? string() : prev_id.GetServerId();
- sync_entry->set_insert_after_item_id(prev_id_string);
- sync_entry->set_position_in_parent(
- meta_entry.Get(UNIQUE_POSITION).ToInt64());
- meta_entry.Get(UNIQUE_POSITION).ToProto(
- sync_entry->mutable_unique_position());
- }
- SetEntrySpecifics(&meta_entry, sync_entry);
- }
+ return SYNCER_OK;
+}
+
+// static.
+void BuildCommitCommand::BuildCommitItem(
+ const syncable::Entry& meta_entry,
+ sync_pb::SyncEntity* sync_entry) {
+ syncable::Id id = meta_entry.Get(syncable::ID);
+ sync_entry->set_id_string(SyncableIdToProto(id));
+
+ string name = meta_entry.Get(syncable::NON_UNIQUE_NAME);
+ CHECK(!name.empty()); // Make sure this isn't an update.
+ // Note: Truncation is also performed in WriteNode::SetTitle(..). But this
+ // call is still necessary to handle any title changes that might originate
+ // elsewhere, or already be persisted in the directory.
+ TruncateUTF8ToByteSize(name, 255, &name);
+ sync_entry->set_name(name);
+
+ // Set the non_unique_name. If we do, the server ignores
+ // the |name| value (using |non_unique_name| instead), and will return
+ // in the CommitResponse a unique name if one is generated.
+ // We send both because it may aid in logging.
+ sync_entry->set_non_unique_name(name);
+
+ if (!meta_entry.Get(syncable::UNIQUE_CLIENT_TAG).empty()) {
+ sync_entry->set_client_defined_unique_tag(
+ meta_entry.Get(syncable::UNIQUE_CLIENT_TAG));
}
- return SYNCER_OK;
+ // Deleted items with server-unknown parent ids can be a problem so we set
+ // the parent to 0. (TODO(sync): Still true in protocol?).
+ Id new_parent_id;
+ if (meta_entry.Get(syncable::IS_DEL) &&
+ !meta_entry.Get(syncable::PARENT_ID).ServerKnows()) {
+ new_parent_id = syncable::BaseTransaction::root_id();
+ } else {
+ new_parent_id = meta_entry.Get(syncable::PARENT_ID);
+ }
+ sync_entry->set_parent_id_string(SyncableIdToProto(new_parent_id));
+
+ // If our parent has changed, send up the old one so the server
+ // can correctly deal with multiple parents.
+ // TODO(nick): With the server keeping track of the primary sync parent,
+ // it should not be necessary to provide the old_parent_id: the version
+ // number should suffice.
+ if (new_parent_id != meta_entry.Get(syncable::SERVER_PARENT_ID) &&
+ 0 != meta_entry.Get(syncable::BASE_VERSION) &&
+ syncable::CHANGES_VERSION != meta_entry.Get(syncable::BASE_VERSION)) {
+ sync_entry->set_old_parent_id(
+ SyncableIdToProto(meta_entry.Get(syncable::SERVER_PARENT_ID)));
+ }
+
+ int64 version = meta_entry.Get(syncable::BASE_VERSION);
+ if (syncable::CHANGES_VERSION == version || 0 == version) {
+ // Undeletions are only supported for items that have a client tag.
+ DCHECK(!id.ServerKnows() ||
+ !meta_entry.Get(syncable::UNIQUE_CLIENT_TAG).empty())
+ << meta_entry;
+
+ // Version 0 means to create or undelete an object.
+ sync_entry->set_version(0);
+ } else {
+ DCHECK(id.ServerKnows()) << meta_entry;
+ sync_entry->set_version(meta_entry.Get(syncable::BASE_VERSION));
+ }
+ sync_entry->set_ctime(TimeToProtoTime(meta_entry.Get(syncable::CTIME)));
+ sync_entry->set_mtime(TimeToProtoTime(meta_entry.Get(syncable::MTIME)));
+
+ // Deletion is final on the server, let's move things and then delete them.
+ if (meta_entry.Get(IS_DEL)) {
+ sync_entry->set_deleted(true);
+ } else {
+ if (meta_entry.Get(SPECIFICS).has_bookmark()) {
+ // Both insert_after_item_id and position_in_parent fields are set only
+ // for legacy reasons. See comments in sync.proto for more information.
+ const Id& prev_id = meta_entry.GetPredecessorId();
+ string prev_id_string =
+ prev_id.IsRoot() ? string() : prev_id.GetServerId();
+ sync_entry->set_insert_after_item_id(prev_id_string);
+ sync_entry->set_position_in_parent(
+ meta_entry.Get(UNIQUE_POSITION).ToInt64());
+ meta_entry.Get(UNIQUE_POSITION).ToProto(
+ sync_entry->mutable_unique_position());
+ }
+ SetEntrySpecifics(meta_entry, sync_entry);
+ }
}
} // namespace syncer
diff --git a/sync/engine/build_commit_command.h b/sync/engine/build_commit_command.h
index 405cdff587..a47c62afe0 100644
--- a/sync/engine/build_commit_command.h
+++ b/sync/engine/build_commit_command.h
@@ -48,6 +48,11 @@ class SYNC_EXPORT_PRIVATE BuildCommitCommand : public SyncerCommand {
// SyncerCommand implementation.
virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE;
+ // Helper function that takes a snapshot of |meta_entry| and puts it into a
+ // protobuf suitable for use in a commit request message.
+ static void BuildCommitItem(const syncable::Entry& meta_entry,
+ sync_pb::SyncEntity* sync_entry);
+
private:
FRIEND_TEST_ALL_PREFIXES(BuildCommitCommandTest, InterpolatePosition);
diff --git a/sync/js/sync_js_controller.cc b/sync/js/sync_js_controller.cc
index 49f3cc79e6..4d3148fdd0 100644
--- a/sync/js/sync_js_controller.cc
+++ b/sync/js/sync_js_controller.cc
@@ -73,7 +73,7 @@ void SyncJsController::UpdateBackendEventHandler() {
// event handler we pass to it if we don't have any event
// handlers.
WeakHandle<JsEventHandler> backend_event_handler =
- (js_event_handlers_.size() > 0) ?
+ js_event_handlers_.might_have_observers() ?
MakeWeakHandle(AsWeakPtr()) : WeakHandle<SyncJsController>();
js_backend_.Call(FROM_HERE, &JsBackend::SetJsEventHandler,
backend_event_handler);
diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc
index f4fe44d10b..a42b902ca8 100644
--- a/sync/protocol/proto_value_conversions.cc
+++ b/sync/protocol/proto_value_conversions.cc
@@ -202,6 +202,7 @@ base::DictionaryValue* TabNavigationToValue(
SET_STR(favicon_url);
SET_ENUM(blocked_state, GetBlockedStateString);
SET_STR_REP(content_pack_categories);
+ SET_INT32(http_status_code);
return value;
}
@@ -240,11 +241,36 @@ base::DictionaryValue* TimeRangeDirectiveToValue(
return value;
}
+base::DictionaryValue* SyncedNotificationImageToValue(
+ const sync_pb::SyncedNotificationImage& proto) {
+ base::DictionaryValue* value = new base::DictionaryValue();
+ SET_STR(url);
+ return value;
+}
+
+base::DictionaryValue* SyncedNotificationProfileImageToValue(
+ const sync_pb::SyncedNotificationProfileImage& proto) {
+ base::DictionaryValue* value = new base::DictionaryValue();
+ SET_STR(image_url);
+ return value;
+}
+
+base::DictionaryValue* MediaToValue(
+ const sync_pb::Media& proto) {
+ base::DictionaryValue* value = new base::DictionaryValue();
+ SET(image, SyncedNotificationImageToValue);
+ return value;
+}
+
base::DictionaryValue* SimpleCollapsedLayoutToValue(
const sync_pb::SimpleCollapsedLayout& proto) {
base::DictionaryValue* value = new base::DictionaryValue();
SET_STR(heading);
SET_STR(description);
+ SET_STR(annotation);
+ SET_REP(media, MediaToValue);
+ SET_REP(profile_image, SyncedNotificationProfileImageToValue);
+ SET(app_icon, SyncedNotificationImageToValue);
return value;
}
@@ -258,6 +284,7 @@ base::DictionaryValue* CollapsedInfoToValue(
base::DictionaryValue* RenderInfoToValue(
const sync_pb::SyncedNotificationRenderInfo& proto) {
base::DictionaryValue* value = new base::DictionaryValue();
+ // TODO(petewil): Add the expanded info values too.
SET(collapsed_info, CollapsedInfoToValue);
return value;
}
@@ -267,6 +294,8 @@ base::DictionaryValue* CoalescedNotificationToValue(
base::DictionaryValue* value = new base::DictionaryValue();
SET_STR(key);
SET_INT32(read_state);
+ SET_INT64(creation_time_msec);
+ SET_INT32(priority);
SET(render_info, RenderInfoToValue);
return value;
}
diff --git a/sync/protocol/proto_value_conversions.h b/sync/protocol/proto_value_conversions.h
index 39b8e0e2f7..f5306d791a 100644
--- a/sync/protocol/proto_value_conversions.h
+++ b/sync/protocol/proto_value_conversions.h
@@ -43,6 +43,7 @@ class FaviconTrackingSpecifics;
class GlobalIdDirective;
class HistoryDeleteDirectiveSpecifics;
class KeystoreEncryptionFlagsSpecifics;
+class Media;
class ManagedUserSettingSpecifics;
class ManagedUserSpecifics;
class NigoriSpecifics;
@@ -57,6 +58,8 @@ class SessionTab;
class SessionWindow;
class SimpleCollapsedLayout;
class SyncCycleCompletedEventInfo;
+class SyncedNotificationImage;
+class SyncedNotificationProfileImage;
class SyncedNotificationRenderInfo;
class SyncedNotificationSpecifics;
class TabNavigation;
@@ -192,6 +195,9 @@ SYNC_EXPORT_PRIVATE base::DictionaryValue* ManagedUserSettingSpecificsToValue(
SYNC_EXPORT_PRIVATE base::DictionaryValue* ManagedUserSpecificsToValue(
const sync_pb::ManagedUserSpecifics& managed_user_specifics);
+SYNC_EXPORT_PRIVATE base::DictionaryValue* MediaToValue(
+ const sync_pb::Media& media);
+
SYNC_EXPORT_PRIVATE base::DictionaryValue* NigoriSpecificsToValue(
const sync_pb::NigoriSpecifics& nigori_specifics);
@@ -211,6 +217,13 @@ SYNC_EXPORT_PRIVATE base::DictionaryValue* SearchEngineSpecificsToValue(
SYNC_EXPORT_PRIVATE base::DictionaryValue* SessionSpecificsToValue(
const sync_pb::SessionSpecifics& session_specifics);
+SYNC_EXPORT_PRIVATE base::DictionaryValue* SyncedNotificationImageToValue(
+ const sync_pb::SyncedNotificationImage& image);
+
+SYNC_EXPORT_PRIVATE base::DictionaryValue*
+ SyncedNotificationProfileImageToValue(
+ const sync_pb::SyncedNotificationProfileImage& image);
+
SYNC_EXPORT_PRIVATE base::DictionaryValue* ThemeSpecificsToValue(
const sync_pb::ThemeSpecifics& theme_specifics);
diff --git a/sync/protocol/session_specifics.proto b/sync/protocol/session_specifics.proto
index f7b7d113ff..4bb8b3e11a 100644
--- a/sync/protocol/session_specifics.proto
+++ b/sync/protocol/session_specifics.proto
@@ -132,4 +132,6 @@ message TabNavigation {
optional BlockedState blocked_state = 18 [default=STATE_ALLOWED];
// A list of category identifiers for the URL.
repeated string content_pack_categories = 19;
+ // The status code from the last navigation.
+ optional int32 http_status_code = 20;
}
diff --git a/sync/syncable/syncable_base_transaction.cc b/sync/syncable/syncable_base_transaction.cc
index d068bb9399..a1d3e85208 100644
--- a/sync/syncable/syncable_base_transaction.cc
+++ b/sync/syncable/syncable_base_transaction.cc
@@ -10,12 +10,13 @@
namespace syncer {
namespace syncable {
-Directory* BaseTransaction::directory() const {
- return directory_;
+// static
+Id BaseTransaction::root_id() {
+ return Id();
}
-Id BaseTransaction::root_id() const {
- return Id();
+Directory* BaseTransaction::directory() const {
+ return directory_;
}
void BaseTransaction::Lock() {
diff --git a/sync/syncable/syncable_base_transaction.h b/sync/syncable/syncable_base_transaction.h
index e15a38b5e7..58c7bfafbf 100644
--- a/sync/syncable/syncable_base_transaction.h
+++ b/sync/syncable/syncable_base_transaction.h
@@ -33,8 +33,9 @@ std::string WriterTagToString(WriterTag writer_tag);
class SYNC_EXPORT BaseTransaction {
public:
+ static Id root_id();
+
Directory* directory() const;
- Id root_id() const;
virtual ~BaseTransaction();
diff --git a/sync/tools/sync_client.cc b/sync/tools/sync_client.cc
index e38254654a..b677531a2b 100644
--- a/sync/tools/sync_client.cc
+++ b/sync/tools/sync_client.cc
@@ -186,8 +186,7 @@ class LoggingJsEventHandler
};
void LogUnrecoverableErrorContext() {
- base::debug::StackTrace stack_trace;
- stack_trace.PrintBacktrace();
+ base::debug::StackTrace().Print();
}
notifier::NotifierOptions ParseNotifierOptions(