summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authorzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-04 04:23:14 +0000
committerzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-04 04:23:14 +0000
commiteb38cf795583ea03914f7748f978cd08be0d03e9 (patch)
tree1465c35c90963f327deddda42ff6ffb4d1caa920 /sync
parent3d4186832b70e34cf4144d7f4a870dd6fb9d3b0f (diff)
downloadchromium_src-eb38cf795583ea03914f7748f978cd08be0d03e9.zip
chromium_src-eb38cf795583ea03914f7748f978cd08be0d03e9.tar.gz
chromium_src-eb38cf795583ea03914f7748f978cd08be0d03e9.tar.bz2
[Sync] Add context proto and directory support
Still not hooked up to anything, but the proto and directory persistence are now there. BUG=358352 Review URL: https://codereview.chromium.org/218623014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261666 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r--sync/protocol/proto_value_conversions.cc11
-rw-r--r--sync/protocol/sync.proto20
-rw-r--r--sync/syncable/directory.cc16
-rw-r--r--sync/syncable/directory.h10
-rw-r--r--sync/syncable/directory_backing_store.cc50
-rw-r--r--sync/syncable/directory_backing_store.h2
-rw-r--r--sync/syncable/directory_backing_store_unittest.cc142
-rw-r--r--sync/test/test_directory_backing_store.h1
8 files changed, 241 insertions, 11 deletions
diff --git a/sync/protocol/proto_value_conversions.cc b/sync/protocol/proto_value_conversions.cc
index 4e89928..06ecdfe 100644
--- a/sync/protocol/proto_value_conversions.cc
+++ b/sync/protocol/proto_value_conversions.cc
@@ -867,6 +867,15 @@ base::DictionaryValue* DataTypeProgressMarkerToValue(
return value;
}
+base::DictionaryValue* DataTypeContextToValue(
+ const sync_pb::DataTypeContext& proto) {
+ base::DictionaryValue* value = new base::DictionaryValue();
+ SET_INT32(data_type_id);
+ SET_STR(context);
+ SET_INT64(version);
+ return value;
+}
+
base::DictionaryValue* GetUpdatesCallerInfoToValue(
const sync_pb::GetUpdatesCallerInfo& proto) {
base::DictionaryValue* value = new base::DictionaryValue();
@@ -886,6 +895,7 @@ base::DictionaryValue* GetUpdatesMessageToValue(
SET_BOOL(need_encryption_key);
SET_BOOL(create_mobile_bookmarks_folder);
SET_ENUM(get_updates_origin, GetUpdatesOriginString);
+ SET_REP(client_contexts, DataTypeContextToValue);
return value;
}
@@ -924,6 +934,7 @@ base::DictionaryValue* GetUpdatesResponseToValue(
SyncEntitiesToValue(proto.entries(), include_specifics));
SET_INT64(changes_remaining);
SET_REP(new_progress_marker, DataTypeProgressMarkerToValue);
+ SET_REP(context_mutations, DataTypeContextToValue);
return value;
}
diff --git a/sync/protocol/sync.proto b/sync/protocol/sync.proto
index 7b0c673..675c25b 100644
--- a/sync/protocol/sync.proto
+++ b/sync/protocol/sync.proto
@@ -412,6 +412,9 @@ message CommitMessage {
// syncing a particular data type regardless of whether a commit for that
// datatype is currently being sent up.
optional ClientConfigParams config_params = 4;
+
+ // Set of optional per-client datatype contexts.
+ repeated DataTypeContext client_contexts = 5;
};
// This message communicates additional per-type information related to
@@ -630,6 +633,9 @@ message GetUpdatesMessage {
// Whether this GU also serves as a retry GU. Any GU that happens after
// retry timer timeout is a retry GU effectively.
optional bool is_retry = 10 [default = false];
+
+ // Set of optional per-client datatype contexts.
+ repeated DataTypeContext client_contexts = 11;
};
message AuthenticateMessage {
@@ -673,6 +679,17 @@ message ClientStatus {
optional bool hierarchy_conflict_detected = 1;
}
+// A single datatype's sync context. Allows the datatype to pass along
+// datatype specific information with its own server backend.
+message DataTypeContext {
+ // The type this context is associated with.
+ optional int32 data_type_id = 1;
+ // The context for the datatype.
+ optional bytes context = 2;
+ // The version of the context.
+ optional int64 version = 3;
+}
+
message ClientToServerMessage {
required string share = 1;
optional int32 protocol_version = 2 [default = 31];
@@ -836,6 +853,9 @@ message GetUpdatesResponse {
// the server has updated the set of encryption keys (e.g. due to a key
// rotation).
repeated bytes encryption_keys = 6;
+
+ // Set of optional datatype contexts server mutations.
+ repeated DataTypeContext context_mutations = 7;
};
// The metadata response for GetUpdatesMessage. This response is sent when
diff --git a/sync/syncable/directory.cc b/sync/syncable/directory.cc
index 97e7071..88fe94a 100644
--- a/sync/syncable/directory.cc
+++ b/sync/syncable/directory.cc
@@ -792,6 +792,22 @@ void Directory::IncrementTransactionVersion(ModelType type) {
kernel_->persisted_info.transaction_version[type]++;
}
+void Directory::GetDataTypeContext(BaseTransaction* trans,
+ ModelType type,
+ sync_pb::DataTypeContext* context) const {
+ ScopedKernelLock lock(this);
+ context->CopyFrom(kernel_->persisted_info.datatype_context[type]);
+}
+
+void Directory::SetDataTypeContext(
+ BaseWriteTransaction* trans,
+ ModelType type,
+ const sync_pb::DataTypeContext& context) {
+ ScopedKernelLock lock(this);
+ kernel_->persisted_info.datatype_context[type].CopyFrom(context);
+ kernel_->info_status = KERNEL_SHARE_INFO_DIRTY;
+}
+
ModelTypeSet Directory::InitialSyncEndedTypes() {
syncable::ReadTransaction trans(FROM_HERE, this);
ModelTypeSet protocol_types = ProtocolTypes();
diff --git a/sync/syncable/directory.h b/sync/syncable/directory.h
index ca8f4f1..5efa348 100644
--- a/sync/syncable/directory.h
+++ b/sync/syncable/directory.h
@@ -120,6 +120,8 @@ class SYNC_EXPORT Directory {
// opaque to the client. This is the serialization of a message of type
// ChipBag defined in sync.proto. It can contains NULL characters.
std::string bag_of_chips;
+ // The per-datatype context.
+ sync_pb::DataTypeContext datatype_context[MODEL_TYPE_COUNT];
};
// What the Directory needs on initialization to create itself and its Kernel.
@@ -196,6 +198,14 @@ class SYNC_EXPORT Directory {
int64 GetTransactionVersion(ModelType type) const;
void IncrementTransactionVersion(ModelType type);
+ // Getter/setters for the per datatype context.
+ void GetDataTypeContext(BaseTransaction* trans,
+ ModelType type,
+ sync_pb::DataTypeContext* context) const;
+ void SetDataTypeContext(BaseWriteTransaction* trans,
+ ModelType type,
+ const sync_pb::DataTypeContext& context);
+
ModelTypeSet InitialSyncEndedTypes();
bool InitialSyncEndedForType(ModelType type);
bool InitialSyncEndedForType(BaseTransaction* trans, ModelType type);
diff --git a/sync/syncable/directory_backing_store.cc b/sync/syncable/directory_backing_store.cc
index 5371f43..e466548 100644
--- a/sync/syncable/directory_backing_store.cc
+++ b/sync/syncable/directory_backing_store.cc
@@ -35,7 +35,7 @@ namespace syncable {
static const string::size_type kUpdateStatementBufferSize = 2048;
// Increment this version whenever updating DB tables.
-const int32 kCurrentDBVersion = 87;
+const int32 kCurrentDBVersion = 88;
// Iterate over the fields of |entry| and bind each to |statement| for
// updating. Returns the number of args bound.
@@ -258,8 +258,11 @@ bool DirectoryBackingStore::SaveChanges(
sql::Statement s2(db_->GetCachedStatement(
SQL_FROM_HERE,
"INSERT OR REPLACE "
- "INTO models (model_id, progress_marker, transaction_version) "
- "VALUES (?, ?, ?)"));
+ "INTO models (model_id, "
+ "progress_marker, "
+ "transaction_version, "
+ "context) "
+ "VALUES (?, ?, ?, ?)"));
ModelTypeSet protocol_types = ProtocolTypes();
for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good();
@@ -272,6 +275,9 @@ bool DirectoryBackingStore::SaveChanges(
s2.BindBlob(0, model_id.data(), model_id.length());
s2.BindBlob(1, progress_marker.data(), progress_marker.length());
s2.BindInt64(2, info.transaction_version[type]);
+ string context;
+ info.datatype_context[type].SerializeToString(&context);
+ s2.BindBlob(3, context.data(), context.length());
if (!s2.Run())
return false;
DCHECK_EQ(db_->GetLastChangeCount(), 1);
@@ -412,6 +418,12 @@ bool DirectoryBackingStore::InitializeTables() {
version_on_disk = 87;
}
+ // Version 88 migration adds datatype contexts to the models table.
+ if (version_on_disk == 87) {
+ if (MigrateVersion87To88())
+ version_on_disk = 88;
+ }
+
// If one of the migrations requested it, drop columns that aren't current.
// It's only safe to do this after migrating all the way to the current
// version.
@@ -566,7 +578,7 @@ bool DirectoryBackingStore::LoadInfo(Directory::KernelLoadInfo* info) {
sql::Statement s(
db_->GetUniqueStatement(
"SELECT model_id, progress_marker, "
- "transaction_version FROM models"));
+ "transaction_version, context FROM models"));
while (s.Step()) {
ModelType type = ModelIdToModelTypeEnum(s.ColumnBlob(0),
@@ -575,6 +587,8 @@ bool DirectoryBackingStore::LoadInfo(Directory::KernelLoadInfo* info) {
info->kernel_info.download_progress[type].ParseFromArray(
s.ColumnBlob(1), s.ColumnByteLength(1));
info->kernel_info.transaction_version[type] = s.ColumnInt64(2);
+ info->kernel_info.datatype_context[type].ParseFromArray(
+ s.ColumnBlob(3), s.ColumnByteLength(3));
}
}
if (!s.Succeeded())
@@ -1134,7 +1148,7 @@ bool DirectoryBackingStore::MigrateVersion84To85() {
// Version 85 removes the initial_sync_ended flag.
if (!db_->Execute("ALTER TABLE models RENAME TO temp_models"))
return false;
- if (!CreateModelsTable())
+ if (!CreateV81ModelsTable())
return false;
if (!db_->Execute("INSERT INTO models SELECT "
"model_id, progress_marker, transaction_version "
@@ -1284,6 +1298,15 @@ bool DirectoryBackingStore::MigrateVersion86To87() {
return true;
}
+bool DirectoryBackingStore::MigrateVersion87To88() {
+ // Version 88 adds the datatype context to the models table.
+ if (!db_->Execute("ALTER TABLE models ADD COLUMN context blob"))
+ return false;
+
+ SetVersion(88);
+ return true;
+}
+
bool DirectoryBackingStore::CreateTables() {
DVLOG(1) << "First run, creating tables";
// Create two little tables share_version and share_info
@@ -1400,8 +1423,20 @@ bool DirectoryBackingStore::CreateV75ModelsTable() {
"initial_sync_ended BOOLEAN default 0)");
}
+bool DirectoryBackingStore::CreateV81ModelsTable() {
+ // This is an old schema for the Models table, used from versions 81 to 87.
+ return db_->Execute(
+ "CREATE TABLE models ("
+ "model_id BLOB primary key, "
+ "progress_marker BLOB, "
+ // Gets set if the syncer ever gets updates from the
+ // server and the server returns 0. Lets us detect the
+ // end of the initial sync.
+ "transaction_version BIGINT default 0)");
+}
+
bool DirectoryBackingStore::CreateModelsTable() {
- // This is the current schema for the Models table, from version 81
+ // This is the current schema for the Models table, from version 88
// onward. If you change the schema, you'll probably want to double-check
// the use of this function in the v84-v85 migration.
return db_->Execute(
@@ -1411,7 +1446,8 @@ bool DirectoryBackingStore::CreateModelsTable() {
// Gets set if the syncer ever gets updates from the
// server and the server returns 0. Lets us detect the
// end of the initial sync.
- "transaction_version BIGINT default 0)");
+ "transaction_version BIGINT default 0,"
+ "context BLOB)");
}
bool DirectoryBackingStore::CreateShareInfoTable(bool is_temporary) {
diff --git a/sync/syncable/directory_backing_store.h b/sync/syncable/directory_backing_store.h
index 5b96848e..dfacebe 100644
--- a/sync/syncable/directory_backing_store.h
+++ b/sync/syncable/directory_backing_store.h
@@ -88,6 +88,7 @@ class SYNC_EXPORT_PRIVATE DirectoryBackingStore : public base::NonThreadSafe {
bool CreateModelsTable();
bool CreateV71ModelsTable();
bool CreateV75ModelsTable();
+ bool CreateV81ModelsTable();
// We don't need to load any synced and applied deleted entries, we can
// in fact just purge them forever on startup.
@@ -171,6 +172,7 @@ class SYNC_EXPORT_PRIVATE DirectoryBackingStore : public base::NonThreadSafe {
bool MigrateVersion84To85();
bool MigrateVersion85To86();
bool MigrateVersion86To87();
+ bool MigrateVersion87To88();
scoped_ptr<sql::Connection> db_;
sql::Statement save_meta_statment_;
diff --git a/sync/syncable/directory_backing_store_unittest.cc b/sync/syncable/directory_backing_store_unittest.cc
index c87f360..88e49cf 100644
--- a/sync/syncable/directory_backing_store_unittest.cc
+++ b/sync/syncable/directory_backing_store_unittest.cc
@@ -75,9 +75,10 @@ class MigrationTest : public testing::TestWithParam<int> {
void SetUpVersion85Database(sql::Connection* connection);
void SetUpVersion86Database(sql::Connection* connection);
void SetUpVersion87Database(sql::Connection* connection);
+ void SetUpVersion88Database(sql::Connection* connection);
void SetUpCurrentDatabaseAndCheckVersion(sql::Connection* connection) {
- SetUpVersion87Database(connection); // Prepopulates data.
+ SetUpVersion88Database(connection); // Prepopulates data.
scoped_ptr<TestDirectoryBackingStore> dbs(
new TestDirectoryBackingStore(GetUsername(), connection));
ASSERT_EQ(kCurrentDBVersion, dbs->GetVersion());
@@ -2650,6 +2651,121 @@ void MigrationTest::SetUpVersion87Database(sql::Connection* connection) {
ASSERT_TRUE(connection->CommitTransaction());
}
+void MigrationTest::SetUpVersion88Database(sql::Connection* connection) {
+ ASSERT_TRUE(connection->is_open());
+ ASSERT_TRUE(connection->BeginTransaction());
+ ASSERT_TRUE(connection->Execute(
+ "CREATE TABLE share_version (id VARCHAR(128) primary key, data INT);"
+ "INSERT INTO 'share_version' VALUES('nick@chromium.org',88);"
+ "CREATE TABLE models (model_id BLOB primary key, progress_marker BLOB,"
+ " transaction_version BIGINT default 0, context BLOB);"
+ "INSERT INTO 'models' VALUES(X'C2881000',X'0888810218B605',1,NULL);"
+ "CREATE TABLE 'metas'(metahandle bigint primary key ON CONFLICT FAIL,base"
+ "_version bigint default -1,server_version bigint default 0,local_exte"
+ "rnal_id bigint default 0,transaction_version bigint default 0,mtime b"
+ "igint default 0,server_mtime bigint default 0,ctime bigint default 0,"
+ "server_ctime bigint default 0,id varchar(255) default 'r',parent_id v"
+ "archar(255) default 'r',server_parent_id varchar(255) default 'r',is_"
+ "unsynced bit default 0,is_unapplied_update bit default 0,is_del bit d"
+ "efault 0,is_dir bit default 0,server_is_dir bit default 0,server_is_d"
+ "el bit default 0,non_unique_name varchar,server_non_unique_name varch"
+ "ar(255),unique_server_tag varchar,unique_client_tag varchar,unique_bo"
+ "okmark_tag varchar,specifics blob,server_specifics blob,base_server_s"
+ "pecifics blob,server_unique_position blob,unique_position blob,attach"
+ "ment_metadata blob);"
+ "INSERT INTO 'metas' VALUES(1,-1,0,0,0,"
+ META_PROTO_TIMES_VALS(1)
+ ",'r','r','r',0,0,0,1,0,0,NULL,NULL,NULL,NULL,X''"
+ ",X'',X'',NULL,X'2200',X'2200',NULL);"
+ "INSERT INTO 'metas' VALUES(6,694,694,6,0,"
+ META_PROTO_TIMES_VALS(6)
+ ",'s_ID_6','s_ID_9','s_ID_9',0,0,0,1,1,0,'The "
+ "Internet','The Internet',NULL,NULL,X'6754307476346749735A5734654D6532"
+ "73625336557753582F77673D',X'C2881000',X'C2881000',NULL,X'22247FFFFFFF"
+ "FFC000006754307476346749735A5734654D653273625336557753582F77673D',X'2"
+ "2247FFFFFFFFFC000006754307476346749735A5734654D653273625336557753582F"
+ "77673D',NULL);"
+ "INSERT INTO 'metas' VALUES(7,663,663,0,0,"
+ META_PROTO_TIMES_VALS(7)
+ ",'s_ID_7','r','r',0,0,0,1,1,0,'Google Chrome'"
+ ",'Google Chrome','google_chrome',NULL,X'',NULL,NULL,NULL,X'2200',X'22"
+ "00',NULL);"
+ "INSERT INTO 'metas' VALUES(8,664,664,0,0,"
+ META_PROTO_TIMES_VALS(8)
+ ",'s_ID_8','s_ID_7','s_ID_7',0,0,0,1,1,0,'Book"
+ "marks','Bookmarks','google_chrome_bookmarks',NULL,X'',X'C2881000',X'C"
+ "2881000',NULL,X'2200',X'2200',NULL);"
+ "INSERT INTO 'metas' VALUES(9,665,665,1,0,"
+ META_PROTO_TIMES_VALS(9)
+ ",'s_ID_9','s_ID_8','s_ID_8',0,0,0,1,1,0,'Book"
+ "mark Bar','Bookmark Bar','bookmark_bar',NULL,X'',X'C2881000',X'C28810"
+ "00',NULL,X'2200',X'2200',NULL);"
+ "INSERT INTO 'metas' VALUES(10,666,666,2,0,"
+ META_PROTO_TIMES_VALS(10)
+ ",'s_ID_10','s_ID_8','s_ID_8',0,0,0,1,1,0,'Ot"
+ "her Bookmarks','Other Bookmarks','other_bookmarks',NULL,X'',X'C288100"
+ "0',X'C2881000',NULL,X'2200',X'2200',NULL);"
+ "INSERT INTO 'metas' VALUES(11,683,683,8,0,"
+ META_PROTO_TIMES_VALS(11)
+ ",'s_ID_11','s_ID_6','s_ID_6',0,0,0,0,0,0,'Ho"
+ "me (The Chromium Projects)','Home (The Chromium Projects)',NULL,NULL,"
+ "X'50514C784A456D623579366267644237646A7A2B62314130346E493D',X'C288102"
+ "20A18687474703A2F2F6465762E6368726F6D69756D2E6F72672F1206414741545741"
+ "',X'C28810290A1D687474703A2F2F6465762E6368726F6D69756D2E6F72672F6F746"
+ "8657212084146414756415346',NULL,X'22247FFFFFFFFFF0000050514C784A456D6"
+ "23579366267644237646A7A2B62314130346E493D',X'22247FFFFFFFFFF000005051"
+ "4C784A456D623579366267644237646A7A2B62314130346E493D',NULL);"
+ "INSERT INTO 'metas' VALUES(12,685,685,9,0,"
+ META_PROTO_TIMES_VALS(12)
+ ",'s_ID_12','s_ID_6','s_ID_6',0,0,0,1,1,0,'Ex"
+ "tra Bookmarks','Extra Bookmarks',NULL,NULL,X'7867626A704A646134635A6F"
+ "616C376A49513338734B46324837773D',X'C2881000',X'C2881000',NULL,X'2224"
+ "80000000000000007867626A704A646134635A6F616C376A49513338734B463248377"
+ "73D',X'222480000000000000007867626A704A646134635A6F616C376A4951333873"
+ "4B46324837773D',NULL);"
+ "INSERT INTO 'metas' VALUES(13,687,687,10,0,"
+ META_PROTO_TIMES_VALS(13)
+ ",'s_ID_13','s_ID_6','s_ID_6',0,0,0,0,0,0,'I"
+ "CANN | Internet Corporation for Assigned Names and Numbers','ICANN | "
+ "Internet Corporation for Assigned Names and Numbers',NULL,NULL,X'3142"
+ "756B572F7741766956504179672B304A614A514B3452384A413D',X'C28810240A156"
+ "87474703A2F2F7777772E6963616E6E2E636F6D2F120B504E474158463041414646',"
+ "X'C28810200A15687474703A2F2F7777772E6963616E6E2E636F6D2F1207444141464"
+ "15346',NULL,X'22247FFFFFFFFFF200003142756B572F7741766956504179672B304"
+ "A614A514B3452384A413D',X'22247FFFFFFFFFF200003142756B572F774176695650"
+ "4179672B304A614A514B3452384A413D',NULL);"
+ "INSERT INTO 'metas' VALUES(14,692,692,11,0,"
+ META_PROTO_TIMES_VALS(14)
+ ",'s_ID_14','s_ID_6','s_ID_6',0,0,0,0,0,0,'T"
+ "he WebKit Open Source Project','The WebKit Open Source Project',NULL,"
+ "NULL,X'5A5678314E7976364579524D3177494F7236563159552F6E644C553D',X'C2"
+ "88101A0A12687474703A2F2F7765626B69742E6F72672F1204504E4758',X'C288101"
+ "C0A13687474703A2F2F7765626B69742E6F72672F781205504E473259',NULL,X'222"
+ "480000000001000005A5678314E7976364579524D3177494F7236563159552F6E644C"
+ "553D',X'222480000000001000005A5678314E7976364579524D3177494F723656315"
+ "9552F6E644C553D',NULL);"
+ "CREATE TABLE deleted_metas (metahandle bigint primary key ON CONFLICT FA"
+ "IL,base_version bigint default -1,server_version bigint default 0,loc"
+ "al_external_id bigint default 0,transaction_version bigint default 0,"
+ "mtime bigint default 0,server_mtime bigint default 0,ctime bigint def"
+ "ault 0,server_ctime bigint default 0,id varchar(255) default 'r',pare"
+ "nt_id varchar(255) default 'r',server_parent_id varchar(255) default "
+ "'r',is_unsynced bit default 0,is_unapplied_update bit default 0,is_de"
+ "l bit default 0,is_dir bit default 0,server_is_dir bit default 0,serv"
+ "er_is_del bit default 0,non_unique_name varchar,server_non_unique_nam"
+ "e varchar(255),unique_server_tag varchar,unique_client_tag varchar,un"
+ "ique_bookmark_tag varchar,specifics blob,server_specifics blob,base_s"
+ "erver_specifics blob,server_unique_position blob,unique_position blob"
+ ",attachment_metadata blob);"
+ "CREATE TABLE 'share_info' (id TEXT primary key, name TEXT, store_birthda"
+ "y TEXT, db_create_version TEXT, db_create_time INT, next_id INT defau"
+ "lt -2, cache_guid TEXT, notification_state BLOB, bag_of_chips BLOB);"
+ "INSERT INTO 'share_info' VALUES('nick@chromium.org','nick@chromium.org',"
+ "'c27e9f59-08ca-46f8-b0cc-f16a2ed778bb','Unknown',1263522064,-131078,'"
+ "9010788312004066376x-6609234393368420856x',NULL,NULL);"));
+ ASSERT_TRUE(connection->CommitTransaction());
+}
+
TEST_F(DirectoryBackingStoreTest, MigrateVersion67To68) {
sql::Connection connection;
ASSERT_TRUE(connection.OpenInMemory());
@@ -3128,6 +3244,18 @@ TEST_F(DirectoryBackingStoreTest, MigrateVersion86To87) {
EXPECT_TRUE(dbs->needs_column_refresh_);
}
+TEST_F(DirectoryBackingStoreTest, MigrateVersion87To88) {
+ sql::Connection connection;
+ ASSERT_TRUE(connection.OpenInMemory());
+ SetUpVersion87Database(&connection);
+
+ scoped_ptr<TestDirectoryBackingStore> dbs(
+ new TestDirectoryBackingStore(GetUsername(), &connection));
+ ASSERT_TRUE(dbs->MigrateVersion87To88());
+ ASSERT_EQ(88, dbs->GetVersion());
+ ASSERT_TRUE(connection.DoesColumnExist("models", "context"));
+}
+
// The purpose of this test case is to make it easier to get a dump of the
// database so you can implement a SetUpVersionYDatabase method. Here's what
// you should do:
@@ -3149,13 +3277,13 @@ TEST_F(DirectoryBackingStoreTest, MigrateToLatestAndDump) {
{
sql::Connection connection;
ASSERT_TRUE(connection.Open(GetDatabasePath()));
- SetUpVersion86Database(&connection); // Update this.
+ SetUpVersion87Database(&connection); // Update this.
scoped_ptr<TestDirectoryBackingStore> dbs(
new TestDirectoryBackingStore(GetUsername(), &connection));
- ASSERT_TRUE(dbs->MigrateVersion86To87()); // Update this.
+ ASSERT_TRUE(dbs->MigrateVersion87To88()); // Update this.
ASSERT_TRUE(LoadAndIgnoreReturnedData(dbs.get()));
- EXPECT_EQ(87, dbs->GetVersion()); // Update this.
+ EXPECT_EQ(88, dbs->GetVersion()); // Update this.
ASSERT_FALSE(dbs->needs_column_refresh_);
}
// Set breakpoint here.
@@ -3254,6 +3382,9 @@ TEST_P(MigrationTest, ToCurrentVersion) {
case 87:
SetUpVersion87Database(&connection);
break;
+ case 88:
+ SetUpVersion88Database(&connection);
+ break;
default:
// If you see this error, it may mean that you've increased the
// database version number but you haven't finished adding unit tests
@@ -3343,6 +3474,9 @@ TEST_P(MigrationTest, ToCurrentVersion) {
// Column added in version 87.
ASSERT_TRUE(connection.DoesColumnExist("metas", "attachment_metadata"));
+ // Column added in version 88.
+ ASSERT_TRUE(connection.DoesColumnExist("models", "context"));
+
// Check download_progress state (v75 migration)
ASSERT_EQ(694,
dir_info.kernel_info.download_progress[BOOKMARKS]
diff --git a/sync/test/test_directory_backing_store.h b/sync/test/test_directory_backing_store.h
index 6c74291..6e9d481 100644
--- a/sync/test/test_directory_backing_store.h
+++ b/sync/test/test_directory_backing_store.h
@@ -50,6 +50,7 @@ class TestDirectoryBackingStore : public DirectoryBackingStore {
FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, MigrateVersion84To85);
FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, MigrateVersion85To86);
FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, MigrateVersion86To87);
+ FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, MigrateVersion87To88);
FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, DetectInvalidPosition);
FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, ModelTypeIds);
FRIEND_TEST_ALL_PREFIXES(DirectoryBackingStoreTest, Corruption);