diff options
author | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-04 21:10:21 +0000 |
---|---|---|
committer | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-04 21:10:21 +0000 |
commit | d7f9c93561d24d5f46b0b54a025a82224dc6b778 (patch) | |
tree | 6c1cd6e387b83f7541a1535d373321131e78abc2 /sync/internal_api/write_transaction.cc | |
parent | b64e521a4734417c33bd6758296c8eb7c3a8fe3f (diff) | |
download | chromium_src-d7f9c93561d24d5f46b0b54a025a82224dc6b778.zip chromium_src-d7f9c93561d24d5f46b0b54a025a82224dc6b778.tar.gz chromium_src-d7f9c93561d24d5f46b0b54a025a82224dc6b778.tar.bz2 |
[Sync] Add plumbing of context from client to server
The datatype context is now written into the directory and plumbed up to the
server on every GetUpdates or Commit request. GetUpdatesResponses also now
overwrite the context if the version returned is the same or higher.
BUG=345420
Review URL: https://codereview.chromium.org/215973007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261873 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/internal_api/write_transaction.cc')
-rw-r--r-- | sync/internal_api/write_transaction.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sync/internal_api/write_transaction.cc b/sync/internal_api/write_transaction.cc index d33093da..b0ed6a2 100644 --- a/sync/internal_api/write_transaction.cc +++ b/sync/internal_api/write_transaction.cc @@ -4,6 +4,7 @@ #include "sync/internal_api/public/write_transaction.h" +#include "sync/syncable/directory.h" #include "sync/syncable/syncable_write_transaction.h" namespace syncer { @@ -36,4 +37,27 @@ syncable::BaseTransaction* WriteTransaction::GetWrappedTrans() const { return transaction_; } +void WriteTransaction::SetDataTypeContext(ModelType type, + const std::string& context) { + sync_pb::DataTypeContext local_context; + GetDirectory()->GetDataTypeContext(transaction_, + type, + &local_context); + if (local_context.context() == context) + return; + + if (!local_context.has_data_type_id()) { + local_context.set_data_type_id( + syncer::GetSpecificsFieldNumberFromModelType(type)); + } + DCHECK_EQ(syncer::GetSpecificsFieldNumberFromModelType(type), + local_context.data_type_id()); + DCHECK_GE(local_context.version(), 0); + local_context.set_version(local_context.version() + 1); + local_context.set_context(context); + GetDirectory()->SetDataTypeContext(transaction_, + type, + local_context); +} + } // namespace syncer |