diff options
author | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-24 01:10:35 +0000 |
---|---|---|
committer | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-24 01:10:35 +0000 |
commit | 43c6dae7c9d9dc3cf639a4ada168d880b800e34b (patch) | |
tree | 3a59983e36763bee8846cd3d1209812587ef0836 | |
parent | 64f9baa2bb3cc42f4fed901f2171409f9a890f71 (diff) | |
download | chromium_src-43c6dae7c9d9dc3cf639a4ada168d880b800e34b.zip chromium_src-43c6dae7c9d9dc3cf639a4ada168d880b800e34b.tar.gz chromium_src-43c6dae7c9d9dc3cf639a4ada168d880b800e34b.tar.bz2 |
Final part of PathString cleanup.
BUG=26342
TEST+exist
Review URL: http://codereview.chromium.org/429003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32894 0039d316-1c4b-4281-b951-d872f2087c98
23 files changed, 295 insertions, 392 deletions
diff --git a/chrome/browser/sync/engine/build_commit_command.cc b/chrome/browser/sync/engine/build_commit_command.cc index 3e4e01a..2381436 100644 --- a/chrome/browser/sync/engine/build_commit_command.cc +++ b/chrome/browser/sync/engine/build_commit_command.cc @@ -66,7 +66,7 @@ void BuildCommitCommand::ExecuteImpl(SyncSession* session) { // This is the only change we make to the entry in this function. meta_entry.Put(syncable::SYNCING, true); - PathString name = meta_entry.Get(syncable::NON_UNIQUE_NAME); + string name = meta_entry.Get(syncable::NON_UNIQUE_NAME); CHECK(!name.empty()); // Make sure this isn't an update. sync_entry->set_name(name); diff --git a/chrome/browser/sync/engine/process_commit_response_command.cc b/chrome/browser/sync/engine/process_commit_response_command.cc index 4cc9912..46fc136 100755 --- a/chrome/browser/sync/engine/process_commit_response_command.cc +++ b/chrome/browser/sync/engine/process_commit_response_command.cc @@ -5,6 +5,7 @@ #include "chrome/browser/sync/engine/process_commit_response_command.h" #include <set> +#include <string> #include <vector> #include "base/basictypes.h" @@ -21,6 +22,7 @@ using syncable::MutableEntry; using syncable::Entry; using std::set; +using std::string; using std::vector; using syncable::BASE_VERSION; @@ -343,7 +345,7 @@ void ProcessCommitResponseCommand::PerformCommitTimeNameAside( syncable::WriteTransaction* trans, const CommitResponse_EntryResponse& server_entry, syncable::MutableEntry* local_entry) { - PathString old_name = local_entry->Get(syncable::NON_UNIQUE_NAME); + string old_name = local_entry->Get(syncable::NON_UNIQUE_NAME); const string server_name = SyncerProtoUtil::NameFromCommitEntryResponse(server_entry); diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc index 1cfd8d2..6e62942 100755 --- a/chrome/browser/sync/engine/syncapi.cc +++ b/chrome/browser/sync/engine/syncapi.cc @@ -135,7 +135,7 @@ class ModelSafeWorkerBridge; static const FilePath::CharType kBookmarkSyncUserSettingsDatabase[] = FILE_PATH_LITERAL("BookmarkSyncSettings.sqlite3"); -static const PSTR_CHAR kDefaultNameForNewNodes[] = PSTR(" "); +static const char kDefaultNameForNewNodes[] = " "; // The list of names which are reserved for use by the server. static const char* kForbiddenServerNames[] = { "", ".", ".." }; @@ -314,7 +314,7 @@ void WriteNode::SetTitle(const std::wstring& title) { std::string server_legal_name; SyncAPINameToServerName(title, &server_legal_name); - PathString old_name = entry_->Get(syncable::NON_UNIQUE_NAME); + string old_name = entry_->Get(syncable::NON_UNIQUE_NAME); if (server_legal_name == old_name) return; // Skip redundant changes. @@ -371,7 +371,7 @@ bool WriteNode::InitByCreation(const BaseNode& parent, // Start out with a dummy name. We expect // the caller to set a meaningful name after creation. - PathString dummy(kDefaultNameForNewNodes); + string dummy(kDefaultNameForNewNodes); entry_ = new syncable::MutableEntry(transaction_->GetWrappedWriteTrans(), syncable::CREATE, parent_id, dummy); diff --git a/chrome/browser/sync/engine/syncer.cc b/chrome/browser/sync/engine/syncer.cc index 2f082e3..2ef15bc 100755 --- a/chrome/browser/sync/engine/syncer.cc +++ b/chrome/browser/sync/engine/syncer.cc @@ -302,7 +302,7 @@ void CopyServerFields(syncable::Entry* src, syncable::MutableEntry* dest) { } void ClearServerData(syncable::MutableEntry* entry) { - entry->Put(SERVER_NON_UNIQUE_NAME, PSTR("")); + entry->Put(SERVER_NON_UNIQUE_NAME, ""); entry->Put(SERVER_PARENT_ID, syncable::kNullId); entry->Put(SERVER_MTIME, 0); entry->Put(SERVER_CTIME, 0); @@ -311,7 +311,7 @@ void ClearServerData(syncable::MutableEntry* entry) { entry->Put(SERVER_IS_DEL, false); entry->Put(SERVER_IS_BOOKMARK_OBJECT, false); entry->Put(IS_UNAPPLIED_UPDATE, false); - entry->Put(SERVER_BOOKMARK_URL, PSTR("")); + entry->Put(SERVER_BOOKMARK_URL, ""); entry->Put(SERVER_BOOKMARK_FAVICON, Blob()); entry->Put(SERVER_POSITION_IN_PARENT, 0); } diff --git a/chrome/browser/sync/engine/syncer_proto_util.cc b/chrome/browser/sync/engine/syncer_proto_util.cc index 7f94896..89d3908 100755 --- a/chrome/browser/sync/engine/syncer_proto_util.cc +++ b/chrome/browser/sync/engine/syncer_proto_util.cc @@ -188,7 +188,7 @@ bool SyncerProtoUtil::Compare(const syncable::Entry& local_entry, // These checks are somewhat prolix, but they're easier to debug than a big // boolean statement. - PathString client_name = local_entry.Get(syncable::NON_UNIQUE_NAME); + string client_name = local_entry.Get(syncable::NON_UNIQUE_NAME); if (client_name != name) { LOG(WARNING) << "Client name mismatch"; return false; diff --git a/chrome/browser/sync/engine/syncer_unittest.cc b/chrome/browser/sync/engine/syncer_unittest.cc index a0babad..838172c 100755 --- a/chrome/browser/sync/engine/syncer_unittest.cc +++ b/chrome/browser/sync/engine/syncer_unittest.cc @@ -8,6 +8,7 @@ #include <list> #include <map> #include <set> +#include <string> #include "base/at_exit.h" @@ -188,7 +189,7 @@ class SyncerTest : public testing::Test, public SyncSession::Delegate { EXPECT_FALSE(entry->Get(IS_DIR)); EXPECT_FALSE(entry->Get(IS_DEL)); Blob test_value(kTestData, kTestData + kTestDataLen); - ExtendedAttributeKey key(entry->Get(META_HANDLE), PSTR("DATA")); + ExtendedAttributeKey key(entry->Get(META_HANDLE), "DATA"); MutableExtendedAttribute attr(trans, CREATE, key); attr.mutable_value()->swap(test_value); entry->Put(syncable::IS_UNSYNCED, true); @@ -197,7 +198,7 @@ class SyncerTest : public testing::Test, public SyncSession::Delegate { EXPECT_FALSE(entry->Get(IS_DIR)); EXPECT_FALSE(entry->Get(IS_DEL)); Blob test_value(kTestData, kTestData + kTestDataLen); - ExtendedAttributeKey key(entry->Get(META_HANDLE), PSTR("DATA")); + ExtendedAttributeKey key(entry->Get(META_HANDLE), "DATA"); ExtendedAttribute attr(trans, GET_BY_HANDLE, key); EXPECT_FALSE(attr.is_deleted()); EXPECT_TRUE(test_value == attr.value()); @@ -248,7 +249,7 @@ class SyncerTest : public testing::Test, public SyncSession::Delegate { ASSERT_FALSE(double_position) << "Two id's expected at one position"; } string utf8_name = test->id.GetServerId(); - PathString name(utf8_name.begin(), utf8_name.end()); + string name(utf8_name.begin(), utf8_name.end()); MutableEntry entry(&trans, CREATE, test->parent_id, name); entry.Put(syncable::ID, test->id); if (test->id.ServerKnows()) { @@ -321,13 +322,13 @@ class SyncerTest : public testing::Test, public SyncSession::Delegate { } } - int64 CreateUnsyncedDirectory(const PathString& entry_name, + int64 CreateUnsyncedDirectory(const string& entry_name, const string& idstring) { return CreateUnsyncedDirectory(entry_name, syncable::Id::CreateFromServerId(idstring)); } - int64 CreateUnsyncedDirectory(const PathString& entry_name, + int64 CreateUnsyncedDirectory(const string& entry_name, const syncable::Id& id) { ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); EXPECT_TRUE(dir.good()); @@ -386,11 +387,11 @@ TEST_F(SyncerTest, TestCallGatherUnsyncedEntries) { TEST_F(SyncerTest, GetCommitIdsCommandTruncates) { ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); ASSERT_TRUE(dir.good()); - int64 handle_c = CreateUnsyncedDirectory(PSTR("C"), ids_.MakeLocal("c")); - int64 handle_x = CreateUnsyncedDirectory(PSTR("X"), ids_.MakeLocal("x")); - int64 handle_b = CreateUnsyncedDirectory(PSTR("B"), ids_.MakeLocal("b")); - int64 handle_d = CreateUnsyncedDirectory(PSTR("D"), ids_.MakeLocal("d")); - int64 handle_e = CreateUnsyncedDirectory(PSTR("E"), ids_.MakeLocal("e")); + int64 handle_c = CreateUnsyncedDirectory("C", ids_.MakeLocal("c")); + int64 handle_x = CreateUnsyncedDirectory("X", ids_.MakeLocal("x")); + int64 handle_b = CreateUnsyncedDirectory("B", ids_.MakeLocal("b")); + int64 handle_d = CreateUnsyncedDirectory("D", ids_.MakeLocal("d")); + int64 handle_e = CreateUnsyncedDirectory("E", ids_.MakeLocal("e")); { WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); MutableEntry entry_x(&wtrans, GET_BY_HANDLE, handle_x); @@ -442,12 +443,9 @@ TEST_F(SyncerTest, TestCommitMetahandleIterator) { { vector<int64> session_metahandles; - session_metahandles.push_back( - CreateUnsyncedDirectory(PSTR("test1"), "testid1")); - session_metahandles.push_back( - CreateUnsyncedDirectory(PSTR("test2"), "testid2")); - session_metahandles.push_back( - CreateUnsyncedDirectory(PSTR("test3"), "testid3")); + session_metahandles.push_back(CreateUnsyncedDirectory("test1", "testid1")); + session_metahandles.push_back(CreateUnsyncedDirectory("test2", "testid2")); + session_metahandles.push_back(CreateUnsyncedDirectory("test3", "testid3")); status->set_unsynced_handles(session_metahandles); WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); @@ -475,17 +473,17 @@ TEST_F(SyncerTest, TestCommitMetahandleIterator) { TEST_F(SyncerTest, TestGetUnsyncedAndSimpleCommit) { ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); ASSERT_TRUE(dir.good()); - PathString xattr_key = PSTR("key"); + string xattr_key = "key"; { WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), - PSTR("Pete")); + "Pete"); ASSERT_TRUE(parent.good()); parent.Put(syncable::IS_UNSYNCED, true); parent.Put(syncable::IS_DIR, true); parent.Put(syncable::BASE_VERSION, 1); parent.Put(syncable::ID, parent_id_); - MutableEntry child(&wtrans, syncable::CREATE, parent_id_, PSTR("Pete")); + MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "Pete"); ASSERT_TRUE(child.good()); child.Put(syncable::ID, child_id_); child.Put(syncable::BASE_VERSION, 1); @@ -645,21 +643,21 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNesting) { WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); { MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), - PSTR("Bob")); + "Bob"); ASSERT_TRUE(parent.good()); parent.Put(syncable::IS_UNSYNCED, true); parent.Put(syncable::IS_DIR, true); parent.Put(syncable::ID, ids_.FromNumber(100)); parent.Put(syncable::BASE_VERSION, 1); MutableEntry child(&wtrans, syncable::CREATE, ids_.FromNumber(100), - PSTR("Bob")); + "Bob"); ASSERT_TRUE(child.good()); child.Put(syncable::IS_UNSYNCED, true); child.Put(syncable::IS_DIR, true); child.Put(syncable::ID, ids_.FromNumber(101)); child.Put(syncable::BASE_VERSION, 1); MutableEntry grandchild(&wtrans, syncable::CREATE, ids_.FromNumber(101), - PSTR("Bob")); + "Bob"); ASSERT_TRUE(grandchild.good()); grandchild.Put(syncable::ID, ids_.FromNumber(102)); grandchild.Put(syncable::IS_UNSYNCED, true); @@ -669,7 +667,7 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNesting) { // Create three deleted items which deletions we expect to be sent to the // server. MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), - PSTR("Pete")); + "Pete"); ASSERT_TRUE(parent.good()); parent.Put(syncable::IS_UNSYNCED, true); parent.Put(syncable::IS_DIR, true); @@ -678,7 +676,7 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNesting) { parent.Put(syncable::BASE_VERSION, 1); parent.Put(syncable::MTIME, now_minus_2h); MutableEntry child(&wtrans, syncable::CREATE, ids_.FromNumber(103), - PSTR("Pete")); + "Pete"); ASSERT_TRUE(child.good()); child.Put(syncable::IS_UNSYNCED, true); child.Put(syncable::IS_DIR, true); @@ -687,7 +685,7 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNesting) { child.Put(syncable::BASE_VERSION, 1); child.Put(syncable::MTIME, now_minus_2h); MutableEntry grandchild(&wtrans, syncable::CREATE, ids_.FromNumber(104), - PSTR("Pete")); + "Pete"); ASSERT_TRUE(grandchild.good()); grandchild.Put(syncable::IS_UNSYNCED, true); grandchild.Put(syncable::ID, ids_.FromNumber(105)); @@ -720,12 +718,12 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNewItems) { ASSERT_TRUE(dir.good()); { WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), PSTR("1")); + MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), "1"); ASSERT_TRUE(parent.good()); parent.Put(syncable::IS_UNSYNCED, true); parent.Put(syncable::IS_DIR, true); parent.Put(syncable::ID, parent_id_); - MutableEntry child(&wtrans, syncable::CREATE, wtrans.root_id(), PSTR("2")); + MutableEntry child(&wtrans, syncable::CREATE, wtrans.root_id(), "2"); ASSERT_TRUE(child.good()); child.Put(syncable::IS_UNSYNCED, true); child.Put(syncable::IS_DIR, true); @@ -735,12 +733,12 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNewItems) { } { WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry parent(&wtrans, syncable::CREATE, parent_id_, PSTR("A")); + MutableEntry parent(&wtrans, syncable::CREATE, parent_id_, "A"); ASSERT_TRUE(parent.good()); parent.Put(syncable::IS_UNSYNCED, true); parent.Put(syncable::IS_DIR, true); parent.Put(syncable::ID, ids_.FromNumber(102)); - MutableEntry child(&wtrans, syncable::CREATE, parent_id_, PSTR("B")); + MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "B"); ASSERT_TRUE(child.good()); child.Put(syncable::IS_UNSYNCED, true); child.Put(syncable::IS_DIR, true); @@ -749,12 +747,12 @@ TEST_F(SyncerTest, TestCommitListOrderingWithNewItems) { } { WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry parent(&wtrans, syncable::CREATE, child_id_, PSTR("A")); + MutableEntry parent(&wtrans, syncable::CREATE, child_id_, "A"); ASSERT_TRUE(parent.good()); parent.Put(syncable::IS_UNSYNCED, true); parent.Put(syncable::IS_DIR, true); parent.Put(syncable::ID, ids_.FromNumber(-104)); - MutableEntry child(&wtrans, syncable::CREATE, child_id_, PSTR("B")); + MutableEntry child(&wtrans, syncable::CREATE, child_id_, "B"); ASSERT_TRUE(child.good()); child.Put(syncable::IS_UNSYNCED, true); child.Put(syncable::IS_DIR, true); @@ -782,16 +780,16 @@ TEST_F(SyncerTest, TestCommitListOrderingCounterexample) { { WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), PSTR("P")); + MutableEntry parent(&wtrans, syncable::CREATE, wtrans.root_id(), "P"); ASSERT_TRUE(parent.good()); parent.Put(syncable::IS_UNSYNCED, true); parent.Put(syncable::IS_DIR, true); parent.Put(syncable::ID, parent_id_); - MutableEntry child1(&wtrans, syncable::CREATE, parent_id_, PSTR("1")); + MutableEntry child1(&wtrans, syncable::CREATE, parent_id_, "1"); ASSERT_TRUE(child1.good()); child1.Put(syncable::IS_UNSYNCED, true); child1.Put(syncable::ID, child_id_); - MutableEntry child2(&wtrans, syncable::CREATE, parent_id_, PSTR("2")); + MutableEntry child2(&wtrans, syncable::CREATE, parent_id_, "2"); ASSERT_TRUE(child2.good()); child2.Put(syncable::IS_UNSYNCED, true); child2.Put(syncable::ID, child2_id); @@ -813,9 +811,9 @@ TEST_F(SyncerTest, TestCommitListOrderingAndNewParent) { ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); ASSERT_TRUE(dir.good()); - PathString parent1_name = PSTR("1"); - PathString parent2_name = PSTR("A"); - PathString child_name = PSTR("B"); + string parent1_name = "1"; + string parent2_name = "A"; + string child_name = "B"; { WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); @@ -880,9 +878,9 @@ TEST_F(SyncerTest, TestCommitListOrderingAndNewParentAndChild) { ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); ASSERT_TRUE(dir.good()); - PathString parent_name = PSTR("1"); - PathString parent2_name = PSTR("A"); - PathString child_name = PSTR("B"); + string parent_name = "1"; + string parent2_name = "A"; + string child_name = "B"; { WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); @@ -980,7 +978,7 @@ TEST_F(SyncerTest, ExtendedAttributeWithNullCharacter) { ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); ASSERT_TRUE(dir.good()); size_t xattr_count = 2; - PathString xattr_keys[] = { PSTR("key"), PSTR("key2") }; + string xattr_keys[] = { "key", "key2" }; syncable::Blob xattr_values[2]; const char* value[] = { "value", "val\0ue" }; int value_length[] = { 5, 6 }; @@ -1132,7 +1130,7 @@ TEST_F(SyncerTest, IllegalAndLegalUpdates) { Entry rename(&trans, GET_BY_ID, ids_.FromNumber(1)); ASSERT_TRUE(rename.good()); EXPECT_EQ(root, rename.Get(PARENT_ID)); - EXPECT_EQ(PSTR("new_name"), rename.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("new_name", rename.Get(NON_UNIQUE_NAME)); EXPECT_FALSE(rename.Get(IS_UNAPPLIED_UPDATE)); EXPECT_TRUE(ids_.FromNumber(1) == rename.Get(ID)); EXPECT_TRUE(20 == rename.Get(BASE_VERSION)); @@ -1142,12 +1140,12 @@ TEST_F(SyncerTest, IllegalAndLegalUpdates) { EXPECT_EQ(root, name_clash.Get(PARENT_ID)); EXPECT_TRUE(ids_.FromNumber(2) == name_clash.Get(ID)); EXPECT_TRUE(10 == name_clash.Get(BASE_VERSION)); - EXPECT_EQ(PSTR("in_root"), name_clash.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("in_root", name_clash.Get(NON_UNIQUE_NAME)); Entry ignored_old_version(&trans, GET_BY_ID, ids_.FromNumber(4)); ASSERT_TRUE(ignored_old_version.good()); EXPECT_TRUE( - ignored_old_version.Get(NON_UNIQUE_NAME) == PSTR("newer_version")); + ignored_old_version.Get(NON_UNIQUE_NAME) == "newer_version"); EXPECT_FALSE(ignored_old_version.Get(IS_UNAPPLIED_UPDATE)); EXPECT_TRUE(20 == ignored_old_version.Get(BASE_VERSION)); @@ -1181,13 +1179,13 @@ TEST_F(SyncerTest, CommitTimeRename) { // Create a folder and an entry. { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry parent(&trans, CREATE, root_id_, PSTR("Folder")); + MutableEntry parent(&trans, CREATE, root_id_, "Folder"); ASSERT_TRUE(parent.good()); parent.Put(IS_DIR, true); parent.Put(IS_UNSYNCED, true); metahandle_folder = parent.Get(META_HANDLE); - MutableEntry entry(&trans, CREATE, parent.Get(ID), PSTR("new_entry")); + MutableEntry entry(&trans, CREATE, parent.Get(ID), "new_entry"); ASSERT_TRUE(entry.good()); metahandle_new_entry = entry.Get(META_HANDLE); WriteTestDataToEntry(&trans, &entry); @@ -1203,17 +1201,17 @@ TEST_F(SyncerTest, CommitTimeRename) { ReadTransaction trans(dir, __FILE__, __LINE__); Entry entry_folder(&trans, GET_BY_HANDLE, metahandle_folder); ASSERT_TRUE(entry_folder.good()); - EXPECT_EQ(PSTR("renamed_Folder"), entry_folder.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("renamed_Folder", entry_folder.Get(NON_UNIQUE_NAME)); Entry entry_new(&trans, GET_BY_HANDLE, metahandle_new_entry); ASSERT_TRUE(entry_new.good()); EXPECT_EQ(entry_folder.Get(ID), entry_new.Get(PARENT_ID)); - EXPECT_EQ(PSTR("renamed_new_entry"), entry_new.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("renamed_new_entry", entry_new.Get(NON_UNIQUE_NAME)); // And that the unrelated directory creation worked without a rename. Entry new_dir(&trans, GET_BY_ID, ids_.FromNumber(2)); EXPECT_TRUE(new_dir.good()); - EXPECT_EQ(PSTR("dir_in_root"), new_dir.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("dir_in_root", new_dir.Get(NON_UNIQUE_NAME)); } } @@ -1230,7 +1228,7 @@ TEST_F(SyncerTest, CommitTimeRenameI18N) { // Create a folder, expect a commit time rename. { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry parent(&trans, CREATE, root_id_, PSTR("Folder")); + MutableEntry parent(&trans, CREATE, root_id_, "Folder"); ASSERT_TRUE(parent.good()); parent.Put(IS_DIR, true); parent.Put(IS_UNSYNCED, true); @@ -1243,7 +1241,7 @@ TEST_F(SyncerTest, CommitTimeRenameI18N) { // Verify it was correctly renamed. { ReadTransaction trans(dir, __FILE__, __LINE__); - PathString expected_folder_name(i18nString); + string expected_folder_name(i18nString); expected_folder_name.append("Folder"); @@ -1263,7 +1261,7 @@ TEST_F(SyncerTest, CommitReuniteUpdateAdjustsChildren) { int64 metahandle_folder; { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("new_folder")); + MutableEntry entry(&trans, CREATE, trans.root_id(), "new_folder"); ASSERT_TRUE(entry.good()); entry.Put(IS_DIR, true); entry.Put(IS_UNSYNCED, true); @@ -1284,7 +1282,7 @@ TEST_F(SyncerTest, CommitReuniteUpdateAdjustsChildren) { // Create an entry in the newly created folder. { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry entry(&trans, CREATE, folder_id, PSTR("new_entry")); + MutableEntry entry(&trans, CREATE, folder_id, "new_entry"); ASSERT_TRUE(entry.good()); metahandle_entry = entry.Get(META_HANDLE); WriteTestDataToEntry(&trans, &entry); @@ -1297,7 +1295,7 @@ TEST_F(SyncerTest, CommitReuniteUpdateAdjustsChildren) { Entry entry(&trans, syncable::GET_BY_HANDLE, metahandle_entry); ASSERT_TRUE(entry.good()); EXPECT_EQ(folder_id, entry.Get(PARENT_ID)); - EXPECT_EQ(PSTR("new_entry"), entry.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("new_entry", entry.Get(NON_UNIQUE_NAME)); entry_id = entry.Get(ID); EXPECT_TRUE(!entry_id.ServerKnows()); VerifyTestDataInEntry(&trans, &entry); @@ -1326,7 +1324,7 @@ TEST_F(SyncerTest, CommitReuniteUpdateAdjustsChildren) { ReadTransaction trans(dir, __FILE__, __LINE__); Entry folder(&trans, GET_BY_HANDLE, metahandle_folder); ASSERT_TRUE(folder.good()); - EXPECT_EQ(PSTR("new_folder"), folder.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("new_folder", folder.Get(NON_UNIQUE_NAME)); EXPECT_TRUE(new_version == folder.Get(BASE_VERSION)); EXPECT_TRUE(new_folder_id == folder.Get(ID)); EXPECT_TRUE(folder.Get(ID).ServerKnows()); @@ -1339,7 +1337,7 @@ TEST_F(SyncerTest, CommitReuniteUpdateAdjustsChildren) { // The child's parent should have changed. Entry entry(&trans, syncable::GET_BY_HANDLE, metahandle_entry); ASSERT_TRUE(entry.good()); - EXPECT_EQ(PSTR("new_entry"), entry.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("new_entry", entry.Get(NON_UNIQUE_NAME)); EXPECT_EQ(new_folder_id, entry.Get(PARENT_ID)); EXPECT_TRUE(!entry.Get(ID).ServerKnows()); VerifyTestDataInEntry(&trans, &entry); @@ -1356,7 +1354,7 @@ TEST_F(SyncerTest, CommitReuniteUpdate) { int64 entry_metahandle; { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("new_entry")); + MutableEntry entry(&trans, CREATE, trans.root_id(), "new_entry"); ASSERT_TRUE(entry.good()); entry_metahandle = entry.Get(META_HANDLE); WriteTestDataToEntry(&trans, &entry); @@ -1396,7 +1394,7 @@ TEST_F(SyncerTest, CommitReuniteUpdate) { ASSERT_TRUE(entry.good()); EXPECT_TRUE(new_version == entry.Get(BASE_VERSION)); EXPECT_TRUE(new_entry_id == entry.Get(ID)); - EXPECT_EQ(PSTR("new_entry"), entry.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("new_entry", entry.Get(NON_UNIQUE_NAME)); } } @@ -1413,7 +1411,7 @@ TEST_F(SyncerTest, CommitReuniteUpdateDoesNotChokeOnDeletedLocalEntry) { int64 entry_metahandle; { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("new_entry")); + MutableEntry entry(&trans, CREATE, trans.root_id(), "new_entry"); ASSERT_TRUE(entry.good()); entry_metahandle = entry.Get(META_HANDLE); WriteTestDataToEntry(&trans, &entry); @@ -1448,7 +1446,7 @@ TEST_F(SyncerTest, CommitReuniteUpdateDoesNotChokeOnDeletedLocalEntry) { { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); Id new_entry_id = GetOnlyEntryWithName( - &trans, trans.root_id(), PSTR("new_entry")); + &trans, trans.root_id(), "new_entry"); MutableEntry entry(&trans, GET_BY_ID, new_entry_id); ASSERT_TRUE(entry.good()); entry.Put(syncable::IS_DEL, true); @@ -1459,7 +1457,7 @@ TEST_F(SyncerTest, CommitReuniteUpdateDoesNotChokeOnDeletedLocalEntry) { { ReadTransaction trans(dir, __FILE__, __LINE__); Id new_entry_id = GetOnlyEntryWithName( - &trans, trans.root_id(), PSTR("new_entry")); + &trans, trans.root_id(), "new_entry"); Entry entry(&trans, GET_BY_ID, new_entry_id); ASSERT_TRUE(entry.good()); EXPECT_FALSE(entry.Get(IS_DEL)); @@ -1567,7 +1565,7 @@ TEST_F(SyncerTest, ReverseFolderOrderingTest) { ReadTransaction trans(dir, __FILE__, __LINE__); Id child_id = GetOnlyEntryWithName( - &trans, ids_.FromNumber(4), PSTR("gggchild")); + &trans, ids_.FromNumber(4), "gggchild"); Entry child(&trans, GET_BY_ID, child_id); ASSERT_TRUE(child.good()); } @@ -1578,20 +1576,20 @@ class EntryCreatedInNewFolderTest : public SyncerTest { ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); CHECK(dir.good()); - WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); + WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); MutableEntry bob(&trans, syncable::GET_BY_ID, GetOnlyEntryWithName(&trans, TestIdFactory::root(), - PSTR("bob"))); + "bob")); CHECK(bob.good()); - MutableEntry entry2(&trans, syncable::CREATE, bob.Get(syncable::ID), - PSTR("bob")); - CHECK(entry2.good()); - entry2.Put(syncable::IS_DIR, true); - entry2.Put(syncable::IS_UNSYNCED, true); -} + MutableEntry entry2(&trans, syncable::CREATE, bob.Get(syncable::ID), + "bob"); + CHECK(entry2.good()); + entry2.Put(syncable::IS_DIR, true); + entry2.Put(syncable::IS_UNSYNCED, true); + } }; TEST_F(EntryCreatedInNewFolderTest, EntryCreatedInNewFolderMidSync) { @@ -1600,7 +1598,7 @@ TEST_F(EntryCreatedInNewFolderTest, EntryCreatedInNewFolderMidSync) { { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); MutableEntry entry(&trans, syncable::CREATE, trans.root_id(), - PSTR("bob")); + "bob"); ASSERT_TRUE(entry.good()); entry.Put(syncable::IS_DIR, true); entry.Put(syncable::IS_UNSYNCED, true); @@ -1614,11 +1612,11 @@ TEST_F(EntryCreatedInNewFolderTest, EntryCreatedInNewFolderMidSync) { { ReadTransaction trans(dir, __FILE__, __LINE__); Entry parent_entry(&trans, syncable::GET_BY_ID, - GetOnlyEntryWithName(&trans, TestIdFactory::root(), PSTR("bob"))); + GetOnlyEntryWithName(&trans, TestIdFactory::root(), "bob")); ASSERT_TRUE(parent_entry.good()); Id child_id = - GetOnlyEntryWithName(&trans, parent_entry.Get(ID), PSTR("bob")); + GetOnlyEntryWithName(&trans, parent_entry.Get(ID), "bob"); Entry child(&trans, syncable::GET_BY_ID, child_id); ASSERT_TRUE(child.good()); EXPECT_EQ(parent_entry.Get(ID), child.Get(PARENT_ID)); @@ -1642,7 +1640,7 @@ TEST_F(SyncerTest, UnappliedUpdateOnCreatedItemItemDoesNotCrash) { // Create an item. WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); MutableEntry fred_match(&trans, CREATE, trans.root_id(), - PSTR("fred_match")); + "fred_match"); ASSERT_TRUE(fred_match.good()); metahandle_fred = fred_match.Get(META_HANDLE); WriteTestDataToEntry(&trans, &fred_match); @@ -1679,12 +1677,12 @@ TEST_F(SyncerTest, DoublyChangedWithResolver) { CHECK(dir.good()); { WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry parent(&wtrans, syncable::CREATE, root_id_, PSTR("Folder")); + MutableEntry parent(&wtrans, syncable::CREATE, root_id_, "Folder"); ASSERT_TRUE(parent.good()); parent.Put(syncable::IS_DIR, true); parent.Put(syncable::ID, parent_id_); parent.Put(syncable::BASE_VERSION, 5); - MutableEntry child(&wtrans, syncable::CREATE, parent_id_, PSTR("Pete.htm")); + MutableEntry child(&wtrans, syncable::CREATE, parent_id_, "Pete.htm"); ASSERT_TRUE(child.good()); child.Put(syncable::ID, child_id_); child.Put(syncable::BASE_VERSION, 10); @@ -1718,7 +1716,7 @@ TEST_F(SyncerTest, CommitsUpdateDoesntAlterEntry) { int64 entry_metahandle; { WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry entry(&wtrans, syncable::CREATE, root_id_, PSTR("Pete")); + MutableEntry entry(&wtrans, syncable::CREATE, root_id_, "Pete"); ASSERT_TRUE(entry.good()); EXPECT_FALSE(entry.Get(ID).ServerKnows()); entry.Put(syncable::IS_DIR, true); @@ -1758,7 +1756,7 @@ TEST_F(SyncerTest, ParentAndChildBothMatch) { { WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry parent(&wtrans, CREATE, root_id_, PSTR("Folder")); + MutableEntry parent(&wtrans, CREATE, root_id_, "Folder"); ASSERT_TRUE(parent.good()); parent.Put(IS_DIR, true); parent.Put(IS_UNSYNCED, true); @@ -1766,7 +1764,7 @@ TEST_F(SyncerTest, ParentAndChildBothMatch) { parent.Put(BASE_VERSION, 1); parent.Put(IS_BOOKMARK_OBJECT, true); - MutableEntry child(&wtrans, CREATE, parent.Get(ID), PSTR("test.htm")); + MutableEntry child(&wtrans, CREATE, parent.Get(ID), "test.htm"); ASSERT_TRUE(child.good()); child.Put(ID, child_id); child.Put(BASE_VERSION, 1); @@ -1801,7 +1799,7 @@ TEST_F(SyncerTest, CommittingNewDeleted) { CHECK(dir.good()); { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("bob")); + MutableEntry entry(&trans, CREATE, trans.root_id(), "bob"); entry.Put(IS_UNSYNCED, true); entry.Put(IS_DEL, true); } @@ -1824,7 +1822,7 @@ TEST_F(SyncerTest, UnappliedUpdateDuringCommit) { CHECK(dir.good()); { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("bob")); + MutableEntry entry(&trans, CREATE, trans.root_id(), "bob"); entry.Put(ID, ids_.FromNumber(20)); entry.Put(BASE_VERSION, 1); entry.Put(SERVER_VERSION, 1); @@ -1859,7 +1857,7 @@ TEST_F(SyncerTest, DeletingEntryInFolder) { int64 existing_metahandle; { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("existing")); + MutableEntry entry(&trans, CREATE, trans.root_id(), "existing"); ASSERT_TRUE(entry.good()); entry.Put(IS_DIR, true); entry.Put(IS_UNSYNCED, true); @@ -1868,7 +1866,7 @@ TEST_F(SyncerTest, DeletingEntryInFolder) { syncer_->SyncShare(session_.get()); { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry newfolder(&trans, CREATE, trans.root_id(), PSTR("new")); + MutableEntry newfolder(&trans, CREATE, trans.root_id(), "new"); ASSERT_TRUE(newfolder.good()); newfolder.Put(IS_DIR, true); newfolder.Put(IS_UNSYNCED, true); @@ -1896,7 +1894,7 @@ TEST_F(SyncerTest, DeletingEntryWithLocalEdits) { syncer_->SyncShare(this); { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry newfolder(&trans, CREATE, ids_.FromNumber(1), PSTR("local")); + MutableEntry newfolder(&trans, CREATE, ids_.FromNumber(1), "local"); ASSERT_TRUE(newfolder.good()); newfolder.Put(IS_UNSYNCED, true); newfolder_metahandle = newfolder.Get(META_HANDLE); @@ -1924,11 +1922,11 @@ TEST_F(SyncerTest, FolderSwapUpdate) { ReadTransaction trans(dir, __FILE__, __LINE__); Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); ASSERT_TRUE(id1.good()); - EXPECT_TRUE(PSTR("fred") == id1.Get(NON_UNIQUE_NAME)); + EXPECT_TRUE("fred" == id1.Get(NON_UNIQUE_NAME)); EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); ASSERT_TRUE(id2.good()); - EXPECT_TRUE(PSTR("bob") == id2.Get(NON_UNIQUE_NAME)); + EXPECT_TRUE("bob" == id2.Get(NON_UNIQUE_NAME)); EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); } syncer_events_.clear(); @@ -1945,15 +1943,15 @@ TEST_F(SyncerTest, NameCollidingFolderSwapWorksFine) { ReadTransaction trans(dir, __FILE__, __LINE__); Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); ASSERT_TRUE(id1.good()); - EXPECT_TRUE(PSTR("bob") == id1.Get(NON_UNIQUE_NAME)); + EXPECT_TRUE("bob" == id1.Get(NON_UNIQUE_NAME)); EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); ASSERT_TRUE(id2.good()); - EXPECT_TRUE(PSTR("fred") == id2.Get(NON_UNIQUE_NAME)); + EXPECT_TRUE("fred" == id2.Get(NON_UNIQUE_NAME)); EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); Entry id3(&trans, GET_BY_ID, ids_.FromNumber(4096)); ASSERT_TRUE(id3.good()); - EXPECT_TRUE(PSTR("alice") == id3.Get(NON_UNIQUE_NAME)); + EXPECT_TRUE("alice" == id3.Get(NON_UNIQUE_NAME)); EXPECT_TRUE(root_id_ == id3.Get(PARENT_ID)); } mock_server_->AddUpdateDirectory(1024, 0, "bob", 2, 20); @@ -1964,15 +1962,15 @@ TEST_F(SyncerTest, NameCollidingFolderSwapWorksFine) { ReadTransaction trans(dir, __FILE__, __LINE__); Entry id1(&trans, GET_BY_ID, ids_.FromNumber(7801)); ASSERT_TRUE(id1.good()); - EXPECT_TRUE(PSTR("fred") == id1.Get(NON_UNIQUE_NAME)); + EXPECT_TRUE("fred" == id1.Get(NON_UNIQUE_NAME)); EXPECT_TRUE(root_id_ == id1.Get(PARENT_ID)); Entry id2(&trans, GET_BY_ID, ids_.FromNumber(1024)); ASSERT_TRUE(id2.good()); - EXPECT_TRUE(PSTR("bob") == id2.Get(NON_UNIQUE_NAME)); + EXPECT_TRUE("bob" == id2.Get(NON_UNIQUE_NAME)); EXPECT_TRUE(root_id_ == id2.Get(PARENT_ID)); Entry id3(&trans, GET_BY_ID, ids_.FromNumber(4096)); ASSERT_TRUE(id3.good()); - EXPECT_TRUE(PSTR("bob") == id3.Get(NON_UNIQUE_NAME)); + EXPECT_TRUE("bob" == id3.Get(NON_UNIQUE_NAME)); EXPECT_TRUE(root_id_ == id3.Get(PARENT_ID)); } syncer_events_.clear(); @@ -1987,7 +1985,7 @@ TEST_F(SyncerTest, CommitManyItemsInOneGo) { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); for (uint32 i = 0; i < items_to_commit; i++) { string nameutf8 = StringPrintf("%d", i); - PathString name(nameutf8.begin(), nameutf8.end()); + string name(nameutf8.begin(), nameutf8.end()); MutableEntry e(&trans, CREATE, trans.root_id(), name); e.Put(IS_UNSYNCED, true); e.Put(IS_DIR, true); @@ -2089,7 +2087,7 @@ TEST_F(SyncerTest, NewEntryAndAlteredServerEntrySharePath) { syncable::Id local_folder_id; { WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry new_entry(&wtrans, CREATE, wtrans.root_id(), PSTR("Bar.htm")); + MutableEntry new_entry(&wtrans, CREATE, wtrans.root_id(), "Bar.htm"); ASSERT_TRUE(new_entry.good()); local_folder_id = new_entry.Get(ID); local_folder_handle = new_entry.Get(META_HANDLE); @@ -2118,7 +2116,7 @@ TEST_F(SyncerTest, SiblingDirectoriesBecomeCircular) { ASSERT_TRUE(A.good()); A.Put(IS_UNSYNCED, true); ASSERT_TRUE(A.Put(PARENT_ID, ids_.FromNumber(2))); - ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, PSTR("B"))); + ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, "B")); } mock_server_->AddUpdateDirectory(2, 1, "A", 20, 20); mock_server_->set_conflict_all_commits(true); @@ -2130,8 +2128,8 @@ TEST_F(SyncerTest, SiblingDirectoriesBecomeCircular) { ASSERT_TRUE(A.good()); MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); ASSERT_TRUE(B.good()); - EXPECT_TRUE(A.Get(NON_UNIQUE_NAME) == PSTR("B")); - EXPECT_TRUE(B.Get(NON_UNIQUE_NAME) == PSTR("B")); + EXPECT_TRUE(A.Get(NON_UNIQUE_NAME) == "B"); + EXPECT_TRUE(B.Get(NON_UNIQUE_NAME) == "B"); } } @@ -2150,11 +2148,11 @@ TEST_F(SyncerTest, ConflictSetClassificationError) { ASSERT_TRUE(A.good()); A.Put(IS_UNSYNCED, true); A.Put(IS_UNAPPLIED_UPDATE, true); - A.Put(SERVER_NON_UNIQUE_NAME, PSTR("B")); + A.Put(SERVER_NON_UNIQUE_NAME, "B"); MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); ASSERT_TRUE(B.good()); B.Put(IS_UNAPPLIED_UPDATE, true); - B.Put(SERVER_NON_UNIQUE_NAME, PSTR("A")); + B.Put(SERVER_NON_UNIQUE_NAME, "A"); } syncer_->SyncShare(this); syncer_events_.clear(); @@ -2176,9 +2174,9 @@ TEST_F(SyncerTest, SwapEntryNames) { MutableEntry B(&wtrans, GET_BY_ID, ids_.FromNumber(2)); ASSERT_TRUE(B.good()); B.Put(IS_UNSYNCED, true); - ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, PSTR("C"))); - ASSERT_TRUE(B.Put(NON_UNIQUE_NAME, PSTR("A"))); - ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, PSTR("B"))); + ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, "C")); + ASSERT_TRUE(B.Put(NON_UNIQUE_NAME, "A")); + ASSERT_TRUE(A.Put(NON_UNIQUE_NAME, "B")); } syncer_->SyncShare(this); syncer_events_.clear(); @@ -2306,7 +2304,7 @@ TEST_F(SyncerTest, ServerDeletingFolderWeHaveMovedSomethingInto) { ASSERT_TRUE(bob.good()); EXPECT_TRUE(bob.Get(IS_UNSYNCED)); EXPECT_FALSE(bob.Get(IS_UNAPPLIED_UPDATE)); - EXPECT_TRUE(bob.Get(NON_UNIQUE_NAME) == PSTR("bob")); + EXPECT_TRUE(bob.Get(NON_UNIQUE_NAME) == "bob"); EXPECT_NE(bob.Get(PARENT_ID), fred_id); // Entry was deleted and reborn. @@ -2317,7 +2315,7 @@ TEST_F(SyncerTest, ServerDeletingFolderWeHaveMovedSomethingInto) { Entry fred(&trans, GET_BY_ID, bob.Get(PARENT_ID)); ASSERT_TRUE(fred.good()); EXPECT_TRUE(fred.Get(PARENT_ID) == trans.root_id()); - EXPECT_EQ(PSTR("fred"), fred.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("fred", fred.Get(NON_UNIQUE_NAME)); EXPECT_TRUE(fred.Get(IS_UNSYNCED)); EXPECT_FALSE(fred.Get(IS_UNAPPLIED_UPDATE)); } @@ -2369,7 +2367,7 @@ TEST_F(SyncerTest, DISABLED_ServerDeletingFolderWeHaveAnOpenEntryIn) { Entry bob(&trans, GET_BY_ID, ids_.FromNumber(1)); ASSERT_TRUE(bob.good()); Id fred_id = - GetOnlyEntryWithName(&trans, TestIdFactory::root(), PSTR("fred")); + GetOnlyEntryWithName(&trans, TestIdFactory::root(), "fred"); Entry fred(&trans, GET_BY_ID, fred_id); ASSERT_TRUE(fred.good()); EXPECT_FALSE(fred.Get(IS_UNSYNCED)); @@ -2420,7 +2418,7 @@ TEST_F(SyncerTest, WeMovedSomethingIntoAFolderServerHasDeleted) { // Fred is reborn with a local ID. Entry fred(&trans, GET_BY_ID, bob.Get(PARENT_ID)); - EXPECT_EQ(PSTR("fred"), fred.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("fred", fred.Get(NON_UNIQUE_NAME)); EXPECT_EQ(TestIdFactory::root(), fred.Get(PARENT_ID)); EXPECT_TRUE(fred.Get(IS_UNSYNCED)); EXPECT_FALSE(fred.Get(ID).ServerKnows()); @@ -2497,7 +2495,7 @@ TEST_F(FolderMoveDeleteRenameTest, MutableEntry fred(&trans, GET_BY_ID, fred_id); ASSERT_TRUE(fred.good()); fred.Put(IS_UNSYNCED, true); - fred.Put(NON_UNIQUE_NAME, PSTR("Alice")); + fred.Put(NON_UNIQUE_NAME, "Alice"); } mock_server_->AddUpdateDirectory(fred_id, TestIdFactory::root(), "fred", 2, 20); @@ -2525,7 +2523,7 @@ TEST_F(FolderMoveDeleteRenameTest, // New ID is created to fill parent folder, named correctly Entry alice(&trans, GET_BY_ID, bob.Get(PARENT_ID)); ASSERT_TRUE(alice.good()); - EXPECT_EQ(PSTR("Alice"), alice.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("Alice", alice.Get(NON_UNIQUE_NAME)); EXPECT_TRUE(alice.Get(IS_UNSYNCED)); EXPECT_FALSE(alice.Get(ID).ServerKnows()); EXPECT_TRUE(bob.Get(IS_UNSYNCED)); @@ -2558,7 +2556,7 @@ TEST_F(SyncerTest, ASSERT_TRUE(bob.good()); bob.Put(IS_UNSYNCED, true); bob.Put(PARENT_ID, fred_id); - MutableEntry new_item(&trans, CREATE, fred_id, PSTR("new_item")); + MutableEntry new_item(&trans, CREATE, fred_id, "new_item"); WriteTestDataToEntry(&trans, &new_item); new_item_id = new_item.Get(ID); } @@ -2585,7 +2583,7 @@ TEST_F(SyncerTest, ASSERT_TRUE(fred.good()); EXPECT_TRUE(fred.Get(IS_UNSYNCED)); EXPECT_FALSE(fred.Get(ID).ServerKnows()); - EXPECT_EQ(PSTR("fred"), fred.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("fred", fred.Get(NON_UNIQUE_NAME)); EXPECT_FALSE(fred.Get(IS_UNAPPLIED_UPDATE)); EXPECT_TRUE(fred.Get(PARENT_ID) == root_id_); @@ -2953,7 +2951,7 @@ TEST_F(SyncerTest, WeMovedSomethingIntoAFolderHierarchyServerHasDeleted) { EXPECT_FALSE(alice.Get(IS_UNAPPLIED_UPDATE)); EXPECT_TRUE(alice.Get(IS_UNSYNCED)); EXPECT_FALSE(alice.Get(ID).ServerKnows()); - EXPECT_TRUE(alice.Get(NON_UNIQUE_NAME) == PSTR("alice")); + EXPECT_TRUE(alice.Get(NON_UNIQUE_NAME) == "alice"); // Alice needs a parent as well. Old parent should have been erased. Entry dead_fred(&trans, GET_BY_ID, fred_id); @@ -2966,7 +2964,7 @@ TEST_F(SyncerTest, WeMovedSomethingIntoAFolderHierarchyServerHasDeleted) { EXPECT_TRUE(fred.Get(IS_UNSYNCED)); EXPECT_FALSE(fred.Get(ID).ServerKnows()); EXPECT_FALSE(fred.Get(IS_UNAPPLIED_UPDATE)); - EXPECT_TRUE(fred.Get(NON_UNIQUE_NAME) == PSTR("fred")); + EXPECT_TRUE(fred.Get(NON_UNIQUE_NAME) == "fred"); } syncer_events_.clear(); } @@ -3058,11 +3056,11 @@ TEST_F(SyncerTest, DuplicateIDReturn) { ASSERT_TRUE(dir.good()); { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry folder(&trans, CREATE, trans.root_id(), PSTR("bob")); + MutableEntry folder(&trans, CREATE, trans.root_id(), "bob"); ASSERT_TRUE(folder.good()); folder.Put(IS_UNSYNCED, true); folder.Put(IS_DIR, true); - MutableEntry folder2(&trans, CREATE, trans.root_id(), PSTR("fred")); + MutableEntry folder2(&trans, CREATE, trans.root_id(), "fred"); ASSERT_TRUE(folder2.good()); folder2.Put(IS_UNSYNCED, false); folder2.Put(IS_DIR, true); @@ -3107,19 +3105,19 @@ TEST_F(SyncerTest, ConflictResolverMergeOverwritesLocalEntry) { { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry local_deleted(&trans, CREATE, trans.root_id(), PSTR("name")); + MutableEntry local_deleted(&trans, CREATE, trans.root_id(), "name"); local_deleted.Put(ID, ids_.FromNumber(1)); local_deleted.Put(BASE_VERSION, 1); local_deleted.Put(IS_DEL, true); local_deleted.Put(IS_UNSYNCED, true); - MutableEntry in_the_way(&trans, CREATE, trans.root_id(), PSTR("name")); + MutableEntry in_the_way(&trans, CREATE, trans.root_id(), "name"); in_the_way.Put(ID, ids_.FromNumber(2)); in_the_way.Put(BASE_VERSION, 1); MutableEntry update(&trans, CREATE_NEW_UPDATE_ITEM, ids_.FromNumber(3)); update.Put(BASE_VERSION, 1); - update.Put(SERVER_NON_UNIQUE_NAME, PSTR("name")); + update.Put(SERVER_NON_UNIQUE_NAME, "name"); update.Put(PARENT_ID, ids_.FromNumber(0)); update.Put(IS_UNAPPLIED_UPDATE, true); @@ -3139,7 +3137,7 @@ TEST_F(SyncerTest, ConflictResolverMergesLocalDeleteAndServerUpdate) { { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry local_deleted(&trans, CREATE, trans.root_id(), PSTR("name")); + MutableEntry local_deleted(&trans, CREATE, trans.root_id(), "name"); local_deleted.Put(ID, ids_.FromNumber(1)); local_deleted.Put(BASE_VERSION, 1); local_deleted.Put(IS_DEL, true); @@ -3175,7 +3173,7 @@ TEST_F(SyncerTest, UpdateFlipsTheFolderBit) { { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry local_deleted(&trans, CREATE, trans.root_id(), PSTR("name")); + MutableEntry local_deleted(&trans, CREATE, trans.root_id(), "name"); local_deleted.Put(ID, ids_.FromNumber(1)); local_deleted.Put(BASE_VERSION, 1); local_deleted.Put(IS_DEL, true); @@ -3244,7 +3242,7 @@ TEST_F(SyncerTest, MergingExistingItems) { syncer_->SyncShare(this); { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("Copy of base")); + MutableEntry entry(&trans, CREATE, trans.root_id(), "Copy of base"); WriteTestDataToEntry(&trans, &entry); } mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50); @@ -3297,7 +3295,7 @@ TEST_F(SyncerTest, LongChangelistWithApplicationConflict) { ASSERT_TRUE(entry.good()); Entry child(&trans, GET_BY_ID, stuck_entry_id); EXPECT_EQ(entry.Get(ID), child.Get(PARENT_ID)); - EXPECT_EQ(PSTR("stuck"), child.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("stuck", child.Get(NON_UNIQUE_NAME)); EXPECT_TRUE(child.good()); } } @@ -3313,7 +3311,7 @@ TEST_F(SyncerTest, DontMergeTwoExistingItems) { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); MutableEntry entry(&trans, GET_BY_ID, ids_.FromNumber(2)); ASSERT_TRUE(entry.good()); - EXPECT_TRUE(entry.Put(NON_UNIQUE_NAME, PSTR("Copy of base"))); + EXPECT_TRUE(entry.Put(NON_UNIQUE_NAME, "Copy of base")); entry.Put(IS_UNSYNCED, true); } mock_server_->AddUpdateBookmark(1, 0, "Copy of base", 50, 50); @@ -3439,12 +3437,12 @@ TEST_F(SyncerTest, DirectoryUpdateTest) { ReadTransaction trans(dir, __FILE__, __LINE__); Entry in_root(&trans, GET_BY_ID, in_root_id); ASSERT_TRUE(in_root.good()); - EXPECT_EQ(PSTR("in_root_name"), in_root.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("in_root_name", in_root.Get(NON_UNIQUE_NAME)); EXPECT_EQ(TestIdFactory::root(), in_root.Get(PARENT_ID)); Entry in_in_root(&trans, GET_BY_ID, in_in_root_id); ASSERT_TRUE(in_in_root.good()); - EXPECT_EQ(PSTR("in_in_root_name"), in_in_root.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("in_in_root_name", in_in_root.Get(NON_UNIQUE_NAME)); EXPECT_EQ(in_root_id, in_in_root.Get(PARENT_ID)); } } @@ -3459,14 +3457,14 @@ TEST_F(SyncerTest, DirectoryCommitTest) { { WriteTransaction wtrans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry parent(&wtrans, syncable::CREATE, root_id_, PSTR("foo")); + MutableEntry parent(&wtrans, syncable::CREATE, root_id_, "foo"); ASSERT_TRUE(parent.good()); parent.Put(syncable::IS_UNSYNCED, true); parent.Put(syncable::IS_DIR, true); in_root_id = parent.Get(syncable::ID); foo_metahandle = parent.Get(META_HANDLE); - MutableEntry child(&wtrans, syncable::CREATE, parent.Get(ID), PSTR("bar")); + MutableEntry child(&wtrans, syncable::CREATE, parent.Get(ID), "bar"); ASSERT_TRUE(child.good()); child.Put(syncable::IS_UNSYNCED, true); child.Put(syncable::IS_DIR, true); @@ -3481,12 +3479,12 @@ TEST_F(SyncerTest, DirectoryCommitTest) { Entry foo_entry(&trans, GET_BY_HANDLE, foo_metahandle); ASSERT_TRUE(foo_entry.good()); - EXPECT_EQ(PSTR("foo"), foo_entry.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("foo", foo_entry.Get(NON_UNIQUE_NAME)); EXPECT_NE(foo_entry.Get(syncable::ID), in_root_id); Entry bar_entry(&trans, GET_BY_HANDLE, bar_metahandle); ASSERT_TRUE(bar_entry.good()); - EXPECT_EQ(PSTR("bar"), bar_entry.Get(NON_UNIQUE_NAME)); + EXPECT_EQ("bar", bar_entry.Get(NON_UNIQUE_NAME)); EXPECT_NE(bar_entry.Get(syncable::ID), in_dir_id); EXPECT_EQ(foo_entry.Get(syncable::ID), bar_entry.Get(PARENT_ID)); } @@ -3505,9 +3503,9 @@ TEST_F(SyncerTest, ConflictSetSizeReducedToOne) { WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); MutableEntry oentry(&trans, GET_BY_ID, in_root_id); ASSERT_TRUE(oentry.good()); - oentry.Put(NON_UNIQUE_NAME, PSTR("old_in_root")); + oentry.Put(NON_UNIQUE_NAME, "old_in_root"); WriteTestDataToEntry(&trans, &oentry); - MutableEntry entry(&trans, CREATE, trans.root_id(), PSTR("in_root")); + MutableEntry entry(&trans, CREATE, trans.root_id(), "in_root"); ASSERT_TRUE(entry.good()); WriteTestDataToEntry(&trans, &entry); } @@ -3565,7 +3563,7 @@ TEST_F(SyncerTest, EnsureWeSendUpOldParent) { entry.Put(PARENT_ID, folder_two_id); entry.Put(IS_UNSYNCED, true); // A new entry should send no parent. - MutableEntry create(&trans, CREATE, trans.root_id(), PSTR("new_folder")); + MutableEntry create(&trans, CREATE, trans.root_id(), "new_folder"); create.Put(IS_UNSYNCED, true); } syncer_->SyncShare(this); @@ -3580,7 +3578,7 @@ TEST_F(SyncerTest, Test64BitVersionSupport) { ScopedDirLookup dir(syncdb_.manager(), syncdb_.name()); CHECK(dir.good()); int64 really_big_int = std::numeric_limits<int64>::max() - 12; - const PathString name(PSTR("ringo's dang orang ran rings around my o-ring")); + const string name("ringo's dang orang ran rings around my o-ring"); int64 item_metahandle; // Try writing max int64 to the version fields of a meta entry. @@ -3726,19 +3724,19 @@ TEST_F(SyncerTest, SingletonTagUpdates) { EXPECT_TRUE(dir.good()); // As a hurdle, introduce an item whose name is the same as the tag value // we'll use later. - int64 hurdle_handle = CreateUnsyncedDirectory(PSTR("bob"), "id_bob"); + int64 hurdle_handle = CreateUnsyncedDirectory("bob", "id_bob"); { ReadTransaction trans(dir, __FILE__, __LINE__); Entry hurdle(&trans, GET_BY_HANDLE, hurdle_handle); ASSERT_TRUE(hurdle.good()); ASSERT_TRUE(!hurdle.Get(IS_DEL)); ASSERT_TRUE(hurdle.Get(SINGLETON_TAG).empty()); - ASSERT_TRUE(hurdle.Get(NON_UNIQUE_NAME) == PSTR("bob")); + ASSERT_TRUE(hurdle.Get(NON_UNIQUE_NAME) == "bob"); // Try to lookup by the tagname. These should fail. - Entry tag_alpha(&trans, GET_BY_TAG, PSTR("alpha")); + Entry tag_alpha(&trans, GET_BY_TAG, "alpha"); EXPECT_FALSE(tag_alpha.good()); - Entry tag_bob(&trans, GET_BY_TAG, PSTR("bob")); + Entry tag_bob(&trans, GET_BY_TAG, "bob"); EXPECT_FALSE(tag_bob.good()); } @@ -3754,22 +3752,22 @@ TEST_F(SyncerTest, SingletonTagUpdates) { // The new items should be applied as new entries, and we should be able // to look them up by their tag values. - Entry tag_alpha(&trans, GET_BY_TAG, PSTR("alpha")); + Entry tag_alpha(&trans, GET_BY_TAG, "alpha"); ASSERT_TRUE(tag_alpha.good()); ASSERT_TRUE(!tag_alpha.Get(IS_DEL)); - ASSERT_TRUE(tag_alpha.Get(SINGLETON_TAG) == PSTR("alpha")); - ASSERT_TRUE(tag_alpha.Get(NON_UNIQUE_NAME) == PSTR("update1")); - Entry tag_bob(&trans, GET_BY_TAG, PSTR("bob")); + ASSERT_TRUE(tag_alpha.Get(SINGLETON_TAG) == "alpha"); + ASSERT_TRUE(tag_alpha.Get(NON_UNIQUE_NAME) == "update1"); + Entry tag_bob(&trans, GET_BY_TAG, "bob"); ASSERT_TRUE(tag_bob.good()); ASSERT_TRUE(!tag_bob.Get(IS_DEL)); - ASSERT_TRUE(tag_bob.Get(SINGLETON_TAG) == PSTR("bob")); - ASSERT_TRUE(tag_bob.Get(NON_UNIQUE_NAME) == PSTR("update2")); + ASSERT_TRUE(tag_bob.Get(SINGLETON_TAG) == "bob"); + ASSERT_TRUE(tag_bob.Get(NON_UNIQUE_NAME) == "update2"); // The old item should be unchanged. Entry hurdle(&trans, GET_BY_HANDLE, hurdle_handle); ASSERT_TRUE(hurdle.good()); ASSERT_TRUE(!hurdle.Get(IS_DEL)); ASSERT_TRUE(hurdle.Get(SINGLETON_TAG).empty()); - ASSERT_TRUE(hurdle.Get(NON_UNIQUE_NAME) == PSTR("bob")); + ASSERT_TRUE(hurdle.Get(NON_UNIQUE_NAME) == "bob"); } } diff --git a/chrome/browser/sync/engine/syncer_util.cc b/chrome/browser/sync/engine/syncer_util.cc index 130a351..e3ac42e 100755 --- a/chrome/browser/sync/engine/syncer_util.cc +++ b/chrome/browser/sync/engine/syncer_util.cc @@ -241,7 +241,7 @@ UpdateAttemptResponse SyncerUtil::AttemptToUpdateEntry( void SyncerUtil::UpdateServerFieldsFromUpdate( MutableEntry* local_entry, const SyncEntity& server_entry, - const PathString& name) { + const string& name) { if (server_entry.deleted()) { // The server returns very lightweight replies for deletions, so we don't // clobber a bunch of fields on delete. @@ -265,13 +265,13 @@ void SyncerUtil::UpdateServerFieldsFromUpdate( local_entry->Put(SERVER_IS_BOOKMARK_OBJECT, server_entry.has_bookmarkdata()); local_entry->Put(SERVER_IS_DIR, server_entry.IsFolder()); if (server_entry.has_singleton_tag()) { - const PathString& tag = server_entry.singleton_tag(); + const string& tag = server_entry.singleton_tag(); local_entry->Put(SINGLETON_TAG, tag); } if (server_entry.has_bookmarkdata() && !server_entry.deleted()) { const SyncEntity::BookmarkData& bookmark = server_entry.bookmarkdata(); if (bookmark.has_bookmark_url()) { - const PathString& url = bookmark.bookmark_url(); + const string& url = bookmark.bookmark_url(); local_entry->Put(SERVER_BOOKMARK_URL, url); } if (bookmark.has_bookmark_favicon()) { @@ -305,9 +305,9 @@ void SyncerUtil::ApplyExtendedAttributes( const sync_pb::ExtendedAttributes & extended_attributes = server_entry.extended_attributes(); for (int i = 0; i < extended_attributes.extendedattribute_size(); i++) { - const PathString& pathstring_key = + const string& string_key = extended_attributes.extendedattribute(i).key(); - ExtendedAttributeKey key(local_entry->Get(META_HANDLE), pathstring_key); + ExtendedAttributeKey key(local_entry->Get(META_HANDLE), string_key); MutableExtendedAttribute local_attribute(local_entry->write_transaction(), CREATE, key); SyncerProtoUtil::CopyProtoBytesIntoBlob( diff --git a/chrome/browser/sync/engine/syncer_util.h b/chrome/browser/sync/engine/syncer_util.h index 9f38873..de0222a 100755 --- a/chrome/browser/sync/engine/syncer_util.h +++ b/chrome/browser/sync/engine/syncer_util.h @@ -55,7 +55,7 @@ class SyncerUtil { static void UpdateServerFieldsFromUpdate( syncable::MutableEntry* local_entry, const SyncEntity& server_entry, - const PathString& name); + const std::string& name); static void ApplyExtendedAttributes( syncable::MutableEntry* local_entry, diff --git a/chrome/browser/sync/protocol/service_constants.h b/chrome/browser/sync/protocol/service_constants.h index 0d6c4b1..2aed89d 100644 --- a/chrome/browser/sync/protocol/service_constants.h +++ b/chrome/browser/sync/protocol/service_constants.h @@ -18,7 +18,7 @@ #define PRODUCT_NAME_STRING_NARROW "Chromium Browser Sync" -#define PRODUCT_NAME_STRING PSTR(PRODUCT_NAME_STRING_NARROW) +#define PRODUCT_NAME_STRING PRODUCT_NAME_STRING_NARROW #define PRODUCT_NAME_STRING_WIDE L##PRODUCT_NAME_STRING #endif // CHROME_BROWSER_SYNC_PROTOCOL_SERVICE_CONSTANTS_H_ diff --git a/chrome/browser/sync/syncable/directory_backing_store.cc b/chrome/browser/sync/syncable/directory_backing_store.cc index 45b72cb..a223e84 100755 --- a/chrome/browser/sync/syncable/directory_backing_store.cc +++ b/chrome/browser/sync/syncable/directory_backing_store.cc @@ -10,8 +10,6 @@ #include <CoreFoundation/CoreFoundation.h> #endif -#include <string> - #include "base/hash_tables.h" #include "base/logging.h" #include "chrome/browser/sync/protocol/service_constants.h" @@ -193,7 +191,7 @@ static string ComposeCreateTableColumnSpecs(const ColumnSpec* begin, /////////////////////////////////////////////////////////////////////////////// // DirectoryBackingStore implementation. -DirectoryBackingStore::DirectoryBackingStore(const PathString& dir_name, +DirectoryBackingStore::DirectoryBackingStore(const string& dir_name, const FilePath& backing_filepath) : load_dbhandle_(NULL), save_dbhandle_(NULL), @@ -335,7 +333,7 @@ DirOpenResult DirectoryBackingStore::InitializeTables() { ScopedStatement statement(PrepareQuery(load_dbhandle_, "SELECT db_create_version, db_create_time FROM share_info")); CHECK(SQLITE_ROW == sqlite3_step(statement.get())); - PathString db_create_version; + string db_create_version; int db_create_time; GetColumn(statement.get(), 0, &db_create_version); GetColumn(statement.get(), 1, &db_create_time); @@ -379,7 +377,7 @@ void DirectoryBackingStore::LoadExtendedAttributes( int step_result = sqlite3_step(statement.get()); while (SQLITE_ROW == step_result) { int64 metahandle; - PathString path_string_key; + string path_string_key; ExtendedAttributeValue val; val.is_deleted = false; GetColumn(statement.get(), 0, &metahandle); diff --git a/chrome/browser/sync/syncable/directory_backing_store.h b/chrome/browser/sync/syncable/directory_backing_store.h index d12bde7..a3fa5093 100644 --- a/chrome/browser/sync/syncable/directory_backing_store.h +++ b/chrome/browser/sync/syncable/directory_backing_store.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_SYNC_SYNCABLE_DIRECTORY_BACKING_STORE_H_ #include <set> +#include <string> #include "base/file_path.h" #include "chrome/browser/sync/syncable/dir_open_result.h" @@ -45,7 +46,7 @@ typedef Directory::MetahandlesIndex MetahandlesIndex; // thread that "uses" the DBS is the thread that destroys it. class DirectoryBackingStore { public: - DirectoryBackingStore(const PathString& dir_name, + DirectoryBackingStore(const std::string& dir_name, const FilePath& backing_filepath); virtual ~DirectoryBackingStore(); @@ -113,7 +114,7 @@ class DirectoryBackingStore { sqlite3* load_dbhandle_; sqlite3* save_dbhandle_; - PathString dir_name_; + std::string dir_name_; FilePath backing_filepath_; DISALLOW_COPY_AND_ASSIGN(DirectoryBackingStore); diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc index 97dd525..960f0fa 100755 --- a/chrome/browser/sync/syncable/syncable.cc +++ b/chrome/browser/sync/syncable/syncable.cc @@ -121,8 +121,8 @@ class HashField { }; // TODO(chron): Remove this function. -int ComparePathNames(const PathString& a, const PathString& b) { - const size_t val_size = sizeof(PathString::value_type); +int ComparePathNames(const string& a, const string& b) { + const size_t val_size = sizeof(string::value_type); return ComparePathNames16(NULL, a.size() * val_size, a.data(), b.size() * val_size, b.data()); } @@ -141,8 +141,7 @@ class LessParentIdAndHandle { }; // TODO(chron): Remove this function. -bool LessPathNames::operator() (const PathString& a, - const PathString& b) const { +bool LessPathNames::operator() (const string& a, const string& b) const { return ComparePathNames(a, b) < 0; } @@ -153,25 +152,25 @@ static const DirectoryChangeEvent kShutdownChangesEvent = { DirectoryChangeEvent::SHUTDOWN, 0, 0 }; Directory::Kernel::Kernel(const FilePath& db_path, - const PathString& name, + const string& name, const KernelLoadInfo& info) -: db_path(db_path), - refcount(1), - name_(name), - metahandles_index(new Directory::MetahandlesIndex), - ids_index(new Directory::IdsIndex), - parent_id_child_index(new Directory::ParentIdChildIndex), - extended_attributes(new ExtendedAttributes), - unapplied_update_metahandles(new MetahandleSet), - unsynced_metahandles(new MetahandleSet), - channel(new Directory::Channel(syncable::DIRECTORY_DESTROYED)), - changes_channel(new Directory::ChangesChannel(kShutdownChangesEvent)), - last_sync_timestamp_(info.kernel_info.last_sync_timestamp), - initial_sync_ended_(info.kernel_info.initial_sync_ended), - store_birthday_(info.kernel_info.store_birthday), - cache_guid_(info.cache_guid), - next_metahandle(info.max_metahandle + 1), - next_id(info.kernel_info.next_id) { + : db_path(db_path), + refcount(1), + name_(name), + metahandles_index(new Directory::MetahandlesIndex), + ids_index(new Directory::IdsIndex), + parent_id_child_index(new Directory::ParentIdChildIndex), + extended_attributes(new ExtendedAttributes), + unapplied_update_metahandles(new MetahandleSet), + unsynced_metahandles(new MetahandleSet), + channel(new Directory::Channel(syncable::DIRECTORY_DESTROYED)), + changes_channel(new Directory::ChangesChannel(kShutdownChangesEvent)), + last_sync_timestamp_(info.kernel_info.last_sync_timestamp), + initial_sync_ended_(info.kernel_info.initial_sync_ended), + store_birthday_(info.kernel_info.store_birthday), + cache_guid_(info.cache_guid), + next_metahandle(info.max_metahandle + 1), + next_id(info.kernel_info.next_id) { info_status_ = Directory::KERNEL_SHARE_INFO_VALID; } @@ -208,8 +207,7 @@ Directory::~Directory() { Close(); } -DirOpenResult Directory::Open(const FilePath& file_path, - const PathString& name) { +DirOpenResult Directory::Open(const FilePath& file_path, const string& name) { const DirOpenResult result = OpenImpl(file_path, name); if (OPENED != result) Close(); @@ -231,12 +229,12 @@ void Directory::InitializeIndices() { } DirectoryBackingStore* Directory::CreateBackingStore( - const PathString& dir_name, const FilePath& backing_filepath) { + const string& dir_name, const FilePath& backing_filepath) { return new DirectoryBackingStore(dir_name, backing_filepath); } DirOpenResult Directory::OpenImpl(const FilePath& file_path, - const PathString& name) { + const string& name) { DCHECK_EQ(static_cast<DirectoryBackingStore*>(NULL), store_); FilePath db_path(file_path); file_util::AbsolutePath(&db_path); @@ -289,7 +287,7 @@ EntryKernel* Directory::GetEntryById(const Id& id, return NULL; } -EntryKernel* Directory::GetEntryByTag(const PathString& tag) { +EntryKernel* Directory::GetEntryByTag(const string& tag) { ScopedKernelLock lock(this); DCHECK(kernel_); // We don't currently keep a separate index for the tags. Since tags @@ -987,7 +985,7 @@ Entry::Entry(BaseTransaction* trans, GetById, const Id& id) kernel_ = trans->directory()->GetEntryById(id); } -Entry::Entry(BaseTransaction* trans, GetByTag, const PathString& tag) +Entry::Entry(BaseTransaction* trans, GetByTag, const string& tag) : basetrans_(trans) { kernel_ = trans->directory()->GetEntryByTag(tag); } @@ -1001,7 +999,7 @@ Directory* Entry::dir() const { return basetrans_->directory(); } -PathString Entry::Get(StringField field) const { +const string& Entry::Get(StringField field) const { DCHECK(kernel_); return kernel_->ref(field); } @@ -1024,7 +1022,7 @@ void Entry::DeleteAllExtendedAttributes(WriteTransaction *trans) { // MutableEntry MutableEntry::MutableEntry(WriteTransaction* trans, Create, - const Id& parent_id, const PathString& name) + const Id& parent_id, const string& name) : Entry(trans), write_transaction_(trans) { Init(trans, parent_id, name); @@ -1032,7 +1030,7 @@ MutableEntry::MutableEntry(WriteTransaction* trans, Create, void MutableEntry::Init(WriteTransaction* trans, const Id& parent_id, - const PathString& name) { + const string& name) { kernel_ = new EntryKernel; ZeroFields(kernel_, BEGIN_FIELDS); kernel_->ref(ID) = trans->directory_->NextId(); @@ -1143,11 +1141,11 @@ bool MutableEntry::Put(BaseVersion field, int64 value) { return true; } -bool MutableEntry::Put(StringField field, const PathString& value) { +bool MutableEntry::Put(StringField field, const string& value) { return PutImpl(field, value); } -bool MutableEntry::PutImpl(StringField field, const PathString& value) { +bool MutableEntry::PutImpl(StringField field, const string& value) { DCHECK(kernel_); if (kernel_->ref(field) != value) { kernel_->ref(field) = value; @@ -1349,7 +1347,7 @@ bool IsLegalNewParent(BaseTransaction* trans, const Id& entry_id, } const Blob* GetExtendedAttributeValue(const Entry& e, - const PathString& attribute_name) { + const string& attribute_name) { ExtendedAttributeKey key(e.Get(META_HANDLE), attribute_name); ExtendedAttribute extended_attribute(e.trans(), GET_BY_HANDLE, key); if (extended_attribute.good() && !extended_attribute.is_deleted()) @@ -1421,7 +1419,7 @@ std::ostream& operator<<(std::ostream& stream, const syncable::Entry& entry) { s << g_metas_columns[i].name << separator; } for ( ; i < STRING_FIELDS_END; ++i) { - const PathString& field = kernel->ref(static_cast<StringField>(i)); + const string& field = kernel->ref(static_cast<StringField>(i)); s << g_metas_columns[i].name << colon << field << separator; } for ( ; i < BLOB_FIELDS_END; ++i) { diff --git a/chrome/browser/sync/syncable/syncable.h b/chrome/browser/sync/syncable/syncable.h index 1b541ed..db3f62c 100755 --- a/chrome/browser/sync/syncable/syncable.h +++ b/chrome/browser/sync/syncable/syncable.h @@ -217,7 +217,7 @@ enum CreateNewUpdateItem { CREATE_NEW_UPDATE_ITEM }; -typedef std::set<PathString> AttributeKeySet; +typedef std::set<std::string> AttributeKeySet; // Why the singular enums? So the code compile-time dispatches instead of // runtime dispatches as it would with a single enum and an if() statement. @@ -227,7 +227,7 @@ typedef std::set<PathString> AttributeKeySet; // declarations would bloat the code. struct EntryKernel { protected: - PathString string_fields[STRING_FIELDS_COUNT]; + std::string string_fields[STRING_FIELDS_COUNT]; Blob blob_fields[BLOB_FIELDS_COUNT]; int64 int64_fields[INT64_FIELDS_COUNT]; Id id_fields[ID_FIELDS_COUNT]; @@ -259,7 +259,7 @@ struct EntryKernel { inline std::bitset<BIT_FIELDS_COUNT>::reference ref(BitField field) { return bit_fields[field - BIT_FIELDS_BEGIN]; } - inline PathString& ref(StringField field) { + inline std::string& ref(StringField field) { return string_fields[field - STRING_FIELDS_BEGIN]; } inline Blob& ref(BlobField field) { @@ -290,7 +290,7 @@ struct EntryKernel { inline bool ref(BitField field) const { return bit_fields[field - BIT_FIELDS_BEGIN]; } - inline PathString ref(StringField field) const { + inline const std::string& ref(StringField field) const { return string_fields[field - STRING_FIELDS_BEGIN]; } inline Blob ref(BlobField field) const { @@ -311,7 +311,7 @@ class Entry { // succeeded. Entry(BaseTransaction* trans, GetByHandle, int64 handle); Entry(BaseTransaction* trans, GetById, const Id& id); - Entry(BaseTransaction* trans, GetByTag, const PathString& tag); + Entry(BaseTransaction* trans, GetByTag, const std::string& tag); bool good() const { return 0 != kernel_; } @@ -346,7 +346,7 @@ class Entry { DCHECK(kernel_); return kernel_->ref(field); } - PathString Get(StringField field) const; + const std::string& Get(StringField field) const; inline Blob Get(BlobField field) const { DCHECK(kernel_); return kernel_->ref(field); @@ -401,10 +401,10 @@ class MutableEntry : public Entry { friend class WriteTransaction; friend class Directory; void Init(WriteTransaction* trans, const Id& parent_id, - const PathString& name); + const std::string& name); public: MutableEntry(WriteTransaction* trans, Create, const Id& parent_id, - const PathString& name); + const std::string& name); MutableEntry(WriteTransaction* trans, CreateNewUpdateItem, const Id& id); MutableEntry(WriteTransaction* trans, GetByHandle, int64); MutableEntry(WriteTransaction* trans, GetById, const Id&); @@ -419,7 +419,7 @@ class MutableEntry : public Entry { // TODO(chron): Remove some of these unecessary return values. bool Put(Int64Field field, const int64& value); bool Put(IdField field, const Id& value); - bool Put(StringField field, const PathString& value); + bool Put(StringField field, const std::string& value); bool Put(BaseVersion field, int64 value); inline bool Put(BlobField field, const Blob& value) { @@ -468,7 +468,7 @@ class MutableEntry : public Entry { friend class sync_api::WriteNode; void* operator new(size_t size) { return (::operator new)(size); } - bool PutImpl(StringField field, const PathString& value); + bool PutImpl(StringField field, const std::string& value); // Adjusts the successor and predecessor entries so that they no longer // refer to this entry. @@ -536,14 +536,14 @@ struct DirectoryChangeEvent { struct ExtendedAttributeKey { int64 metahandle; - PathString key; + std::string key; inline bool operator < (const ExtendedAttributeKey& x) const { if (metahandle != x.metahandle) return metahandle < x.metahandle; return key.compare(x.key) < 0; } - ExtendedAttributeKey(int64 metahandle, PathString key) : - metahandle(metahandle), key(key) { } + ExtendedAttributeKey(int64 metahandle, const std::string& key) + : metahandle(metahandle), key(key) { } }; struct ExtendedAttributeValue { @@ -646,7 +646,7 @@ class Directory { Directory(); virtual ~Directory(); - DirOpenResult Open(const FilePath& file_path, const PathString& name); + DirOpenResult Open(const FilePath& file_path, const std::string& name); void Close(); @@ -667,7 +667,7 @@ class Directory { bool initial_sync_ended() const; void set_initial_sync_ended(bool value); - PathString name() const { return kernel_->name_; } + const std::string& name() const { return kernel_->name_; } // (Account) Store birthday is opaque to the client, // so we keep it in the format it is in the proto buffer @@ -682,7 +682,7 @@ class Directory { EntryKernel* GetEntryByHandle(const int64 handle); EntryKernel* GetEntryByHandle(const int64 metahandle, ScopedKernelLock* lock); EntryKernel* GetEntryById(const Id& id); - EntryKernel* GetEntryByTag(const PathString& tag); + EntryKernel* GetEntryByTag(const std::string& tag); EntryKernel* GetRootEntry(); bool ReindexId(EntryKernel* const entry, const Id& new_id); void ReindexParentId(EntryKernel* const entry, const Id& new_parent_id); @@ -694,7 +694,7 @@ class Directory { // Overridden by tests. virtual DirectoryBackingStore* CreateBackingStore( - const PathString& dir_name, + const std::string& dir_name, const FilePath& backing_filepath); private: @@ -702,7 +702,7 @@ class Directory { // before calling. EntryKernel* GetEntryById(const Id& id, ScopedKernelLock* const lock); - DirOpenResult OpenImpl(const FilePath& file_path, const PathString& name); + DirOpenResult OpenImpl(const FilePath& file_path, const std::string& name); struct DirectoryEventTraits { typedef DirectoryEvent EventType; @@ -717,7 +717,7 @@ class Directory { // Returns the child meta handles for given parent id. void GetChildHandles(BaseTransaction*, const Id& parent_id, - const PathString& path_spec, ChildHandles* result); + const std::string& path_spec, ChildHandles* result); void GetChildHandles(BaseTransaction*, const Id& parent_id, ChildHandles* result); void GetChildHandlesImpl(BaseTransaction* trans, const Id& parent_id, @@ -838,7 +838,7 @@ class Directory { private: struct Kernel { - Kernel(const FilePath& db_path, const PathString& name, + Kernel(const FilePath& db_path, const std::string& name, const KernelLoadInfo& info); ~Kernel(); @@ -853,7 +853,7 @@ class Directory { Lock transaction_mutex; // The name of this directory, used as a key into open_files_; - PathString const name_; + std::string const name_; // Protects all members below. // The mutex effectively protects all the indices, but not the @@ -995,7 +995,7 @@ class WriteTransaction : public BaseTransaction { }; bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid); -int ComparePathNames(const PathString& a, const PathString& b); +int ComparePathNames(const std::string& a, const std::string& b); // Exposed in header as this is used as a sqlite3 callback. int ComparePathNames16(void*, int a_bytes, const void* a, int b_bytes, @@ -1008,7 +1008,7 @@ class ExtendedAttribute { ExtendedAttribute(BaseTransaction* trans, GetByHandle, const ExtendedAttributeKey& key); int64 metahandle() const { return i_->first.metahandle; } - const PathString& key() const { return i_->first.key; } + const std::string& key() const { return i_->first.key; } const Blob& value() const { return i_->second.value; } bool is_deleted() const { return i_->second.is_deleted; } bool good() const { return good_; } @@ -1049,7 +1049,7 @@ class MutableExtendedAttribute : public ExtendedAttribute { // no attribute with the given name. The pointer is valid for the // duration of the Entry's transaction. const Blob* GetExtendedAttributeValue(const Entry& e, - const PathString& attribute_name); + const std::string& attribute_name); // This function sets only the flags needed to get this entry to sync. void MarkForSyncing(syncable::MutableEntry* e); diff --git a/chrome/browser/sync/syncable/syncable_unittest.cc b/chrome/browser/sync/syncable/syncable_unittest.cc index 2911a46..e5fe998 100755 --- a/chrome/browser/sync/syncable/syncable_unittest.cc +++ b/chrome/browser/sync/syncable/syncable_unittest.cc @@ -60,7 +60,7 @@ void PutDataAsExtendedAttribute(WriteTransaction* wtrans, MutableEntry* e, const char* bytes, size_t bytes_length) { - ExtendedAttributeKey key(e->Get(META_HANDLE), PSTR("DATA")); + ExtendedAttributeKey key(e->Get(META_HANDLE), "DATA"); MutableExtendedAttribute attr(wtrans, CREATE, key); Blob bytes_blob(bytes, bytes + bytes_length); attr.mutable_value()->swap(bytes_blob); @@ -72,7 +72,7 @@ void ExpectDataFromExtendedAttributeEquals(BaseTransaction* trans, size_t bytes_length) { ASSERT_TRUE(e->good()); Blob expected_value(bytes, bytes + bytes_length); - ExtendedAttributeKey key(e->Get(META_HANDLE), PSTR("DATA")); + ExtendedAttributeKey key(e->Get(META_HANDLE), "DATA"); ExtendedAttribute attr(trans, GET_BY_HANDLE, key); EXPECT_FALSE(attr.is_deleted()); EXPECT_EQ(expected_value, attr.value()); @@ -83,11 +83,11 @@ TEST(Syncable, General) { remove("SimpleTest.sqlite3"); Directory dir; FilePath test_db(FILE_PATH_LITERAL("SimpleTest.sqlite3")); - dir.Open(test_db, PSTR("SimpleTest")); + dir.Open(test_db, "SimpleTest"); int64 written_metahandle; const Id id = TestIdFactory::FromNumber(99); - PathString name = PSTR("Jeff"); + string name = "Jeff"; // Test simple read operations on an empty DB. { ReadTransaction rtrans(&dir, __FILE__, __LINE__); @@ -169,7 +169,7 @@ class TestUnsaveableDirectory : public Directory { public: class UnsaveableBackingStore : public DirectoryBackingStore { public: - UnsaveableBackingStore(const PathString& dir_name, + UnsaveableBackingStore(const string& dir_name, const FilePath& backing_filepath) : DirectoryBackingStore(dir_name, backing_filepath) { } virtual bool SaveChanges(const Directory::SaveChangesSnapshot& snapshot) { @@ -177,7 +177,7 @@ class TestUnsaveableDirectory : public Directory { } }; virtual DirectoryBackingStore* CreateBackingStore( - const PathString& dir_name, const FilePath& backing_filepath) { + const string& dir_name, const FilePath& backing_filepath) { return new UnsaveableBackingStore(dir_name, backing_filepath); } }; @@ -186,7 +186,7 @@ class TestUnsaveableDirectory : public Directory { class SyncableDirectoryTest : public testing::Test { protected: static const FilePath::CharType kFilePath[]; - static const PathString kName; + static const string kName; static const Id kId; // SetUp() is called before each test case is run. @@ -211,15 +211,15 @@ class SyncableDirectoryTest : public testing::Test { FilePath file_path_; // Creates an empty entry and sets the ID field to the default kId. - void CreateEntry(const PathString &entryname) { + void CreateEntry(const string& entryname) { CreateEntry(entryname, kId); } // Creates an empty entry and sets the ID field to id. - void CreateEntry(const PathString &entryname, const int id) { + void CreateEntry(const string& entryname, const int id) { CreateEntry(entryname, TestIdFactory::FromNumber(id)); } - void CreateEntry(const PathString &entryname, Id id) { + void CreateEntry(const string& entryname, Id id) { WriteTransaction wtrans(dir_.get(), UNITTEST, __FILE__, __LINE__); MutableEntry me(&wtrans, CREATE, wtrans.root_id(), entryname); ASSERT_TRUE(me.good()); @@ -228,15 +228,15 @@ class SyncableDirectoryTest : public testing::Test { } void ValidateEntry(BaseTransaction* trans, int64 id, bool check_name, - PathString name, int64 base_version, int64 server_version, bool is_del); + string name, int64 base_version, int64 server_version, bool is_del); void CreateAndCheck(WriteTransaction* trans, int64 parent_id, int64 id, - PathString name, PathString server_name, int64 version, + string name, string server_name, int64 version, bool set_server_fields, bool is_dir, bool add_to_lru, int64 *meta_handle); }; const FilePath::CharType SyncableDirectoryTest::kFilePath[] = FILE_PATH_LITERAL("Test.sqlite3"); -const PathString SyncableDirectoryTest::kName(PSTR("Foo")); +const string SyncableDirectoryTest::kName("Foo"); const Id SyncableDirectoryTest::kId(TestIdFactory::FromNumber(-99)); TEST_F(SyncableDirectoryTest, TestBasicLookupNonExistantID) { @@ -246,14 +246,14 @@ TEST_F(SyncableDirectoryTest, TestBasicLookupNonExistantID) { } TEST_F(SyncableDirectoryTest, TestBasicLookupValidID) { - CreateEntry(PSTR("rtc")); + CreateEntry("rtc"); ReadTransaction rtrans(dir_.get(), __FILE__, __LINE__); Entry e(&rtrans, GET_BY_ID, kId); ASSERT_TRUE(e.good()); } TEST_F(SyncableDirectoryTest, TestDelete) { - PathString name = PSTR("peanut butter jelly time"); + string name = "peanut butter jelly time"; WriteTransaction trans(dir_.get(), UNITTEST, __FILE__, __LINE__); MutableEntry e1(&trans, CREATE, trans.root_id(), name); ASSERT_TRUE(e1.good()); @@ -283,14 +283,14 @@ TEST_F(SyncableDirectoryTest, TestGetUnsynced) { dir_->GetUnsyncedMetaHandles(&trans, &handles); ASSERT_TRUE(0 == handles.size()); - MutableEntry e1(&trans, CREATE, trans.root_id(), PSTR("abba")); + MutableEntry e1(&trans, CREATE, trans.root_id(), "abba"); ASSERT_TRUE(e1.good()); handle1 = e1.Get(META_HANDLE); e1.Put(BASE_VERSION, 1); e1.Put(IS_DIR, true); e1.Put(ID, TestIdFactory::FromNumber(101)); - MutableEntry e2(&trans, CREATE, e1.Get(ID), PSTR("bread")); + MutableEntry e2(&trans, CREATE, e1.Get(ID), "bread"); ASSERT_TRUE(e2.good()); handle2 = e2.Get(META_HANDLE); e2.Put(BASE_VERSION, 1); @@ -354,7 +354,7 @@ TEST_F(SyncableDirectoryTest, TestGetUnappliedUpdates) { dir_->GetUnappliedUpdateMetaHandles(&trans, &handles); ASSERT_TRUE(0 == handles.size()); - MutableEntry e1(&trans, CREATE, trans.root_id(), PSTR("abba")); + MutableEntry e1(&trans, CREATE, trans.root_id(), "abba"); ASSERT_TRUE(e1.good()); handle1 = e1.Get(META_HANDLE); e1.Put(IS_UNAPPLIED_UPDATE, false); @@ -362,7 +362,7 @@ TEST_F(SyncableDirectoryTest, TestGetUnappliedUpdates) { e1.Put(ID, TestIdFactory::FromNumber(101)); e1.Put(IS_DIR, true); - MutableEntry e2(&trans, CREATE, e1.Get(ID), PSTR("bread")); + MutableEntry e2(&trans, CREATE, e1.Get(ID), "bread"); ASSERT_TRUE(e2.good()); handle2 = e2.Get(META_HANDLE); e2.Put(IS_UNAPPLIED_UPDATE, false); @@ -423,22 +423,22 @@ TEST_F(SyncableDirectoryTest, DeleteBug_531383) { int64 grandchild_handle, twin_handle; { WriteTransaction wtrans(dir_.get(), UNITTEST, __FILE__, __LINE__); - MutableEntry parent(&wtrans, CREATE, id_factory.root(), PSTR("Bob")); + MutableEntry parent(&wtrans, CREATE, id_factory.root(), "Bob"); ASSERT_TRUE(parent.good()); parent.Put(IS_DIR, true); parent.Put(ID, id_factory.NewServerId()); parent.Put(BASE_VERSION, 1); - MutableEntry child(&wtrans, CREATE, parent.Get(ID), PSTR("Bob")); + MutableEntry child(&wtrans, CREATE, parent.Get(ID), "Bob"); ASSERT_TRUE(child.good()); child.Put(IS_DIR, true); child.Put(ID, id_factory.NewServerId()); child.Put(BASE_VERSION, 1); - MutableEntry grandchild(&wtrans, CREATE, child.Get(ID), PSTR("Bob")); + MutableEntry grandchild(&wtrans, CREATE, child.Get(ID), "Bob"); ASSERT_TRUE(grandchild.good()); grandchild.Put(ID, id_factory.NewServerId()); grandchild.Put(BASE_VERSION, 1); ASSERT_TRUE(grandchild.Put(IS_DEL, true)); - MutableEntry twin(&wtrans, CREATE, child.Get(ID), PSTR("Bob")); + MutableEntry twin(&wtrans, CREATE, child.Get(ID), "Bob"); ASSERT_TRUE(twin.good()); ASSERT_TRUE(twin.Put(IS_DEL, true)); ASSERT_TRUE(grandchild.Put(IS_DEL, false)); @@ -463,32 +463,32 @@ TEST_F(SyncableDirectoryTest, TestIsLegalNewParent) { WriteTransaction wtrans(dir_.get(), UNITTEST, __FILE__, __LINE__); Entry root(&wtrans, GET_BY_ID, id_factory.root()); ASSERT_TRUE(root.good()); - MutableEntry parent(&wtrans, CREATE, root.Get(ID), PSTR("Bob")); + MutableEntry parent(&wtrans, CREATE, root.Get(ID), "Bob"); ASSERT_TRUE(parent.good()); parent.Put(IS_DIR, true); parent.Put(ID, id_factory.NewServerId()); parent.Put(BASE_VERSION, 1); - MutableEntry child(&wtrans, CREATE, parent.Get(ID), PSTR("Bob")); + MutableEntry child(&wtrans, CREATE, parent.Get(ID), "Bob"); ASSERT_TRUE(child.good()); child.Put(IS_DIR, true); child.Put(ID, id_factory.NewServerId()); child.Put(BASE_VERSION, 1); - MutableEntry grandchild(&wtrans, CREATE, child.Get(ID), PSTR("Bob")); + MutableEntry grandchild(&wtrans, CREATE, child.Get(ID), "Bob"); ASSERT_TRUE(grandchild.good()); grandchild.Put(ID, id_factory.NewServerId()); grandchild.Put(BASE_VERSION, 1); - MutableEntry parent2(&wtrans, CREATE, root.Get(ID), PSTR("Pete")); + MutableEntry parent2(&wtrans, CREATE, root.Get(ID), "Pete"); ASSERT_TRUE(parent2.good()); parent2.Put(IS_DIR, true); parent2.Put(ID, id_factory.NewServerId()); parent2.Put(BASE_VERSION, 1); - MutableEntry child2(&wtrans, CREATE, parent2.Get(ID), PSTR("Pete")); + MutableEntry child2(&wtrans, CREATE, parent2.Get(ID), "Pete"); ASSERT_TRUE(child2.good()); child2.Put(IS_DIR, true); child2.Put(ID, id_factory.NewServerId()); child2.Put(BASE_VERSION, 1); - MutableEntry grandchild2(&wtrans, CREATE, child2.Get(ID), PSTR("Pete")); + MutableEntry grandchild2(&wtrans, CREATE, child2.Get(ID), "Pete"); ASSERT_TRUE(grandchild2.good()); grandchild2.Put(ID, id_factory.NewServerId()); grandchild2.Put(BASE_VERSION, 1); @@ -516,11 +516,11 @@ TEST_F(SyncableDirectoryTest, TestEntryIsInFolder) { int64 entry_handle; syncable::Id folder_id; syncable::Id entry_id; - PathString entry_name = PSTR("entry"); + string entry_name = "entry"; { WriteTransaction trans(dir_.get(), UNITTEST, __FILE__, __LINE__); - MutableEntry folder(&trans, CREATE, trans.root_id(), PSTR("folder")); + MutableEntry folder(&trans, CREATE, trans.root_id(), "folder"); ASSERT_TRUE(folder.good()); EXPECT_TRUE(folder.Put(IS_DIR, true)); EXPECT_TRUE(folder.Put(IS_UNSYNCED, true)); @@ -548,14 +548,14 @@ TEST_F(SyncableDirectoryTest, TestEntryIsInFolder) { } TEST_F(SyncableDirectoryTest, TestParentIdIndexUpdate) { - PathString child_name = PSTR("child"); + string child_name = "child"; WriteTransaction wt(dir_.get(), UNITTEST, __FILE__, __LINE__); - MutableEntry parent_folder(&wt, CREATE, wt.root_id(), PSTR("folder1")); + MutableEntry parent_folder(&wt, CREATE, wt.root_id(), "folder1"); parent_folder.Put(IS_UNSYNCED, true); EXPECT_TRUE(parent_folder.Put(IS_DIR, true)); - MutableEntry parent_folder2(&wt, CREATE, wt.root_id(), PSTR("folder2")); + MutableEntry parent_folder2(&wt, CREATE, wt.root_id(), "folder2"); parent_folder2.Put(IS_UNSYNCED, true); EXPECT_TRUE(parent_folder2.Put(IS_DIR, true)); @@ -577,8 +577,8 @@ TEST_F(SyncableDirectoryTest, TestParentIdIndexUpdate) { } TEST_F(SyncableDirectoryTest, TestNoReindexDeletedItems) { - PathString folder_name = PSTR("folder"); - PathString new_name = PSTR("new_name"); + string folder_name = "folder"; + string new_name = "new_name"; WriteTransaction trans(dir_.get(), UNITTEST, __FILE__, __LINE__); MutableEntry folder(&trans, CREATE, trans.root_id(), folder_name); @@ -599,10 +599,10 @@ TEST_F(SyncableDirectoryTest, TestNoReindexDeletedItems) { TEST_F(SyncableDirectoryTest, TestCaseChangeRename) { WriteTransaction trans(dir_.get(), UNITTEST, __FILE__, __LINE__); - MutableEntry folder(&trans, CREATE, trans.root_id(), PSTR("CaseChange")); + MutableEntry folder(&trans, CREATE, trans.root_id(), "CaseChange"); ASSERT_TRUE(folder.good()); EXPECT_TRUE(folder.Put(PARENT_ID, trans.root_id())); - EXPECT_TRUE(folder.Put(NON_UNIQUE_NAME, PSTR("CASECHANGE"))); + EXPECT_TRUE(folder.Put(NON_UNIQUE_NAME, "CASECHANGE")); EXPECT_TRUE(folder.Put(IS_DEL, true)); } @@ -629,7 +629,7 @@ TEST_F(SyncableDirectoryTest, TestSimpleFieldsPreservedDuringSaveChanges) { Id create_id; EntryKernel create_pre_save, update_pre_save; EntryKernel create_post_save, update_post_save; - PathString create_name = PSTR("Create"); + string create_name = "Create"; { WriteTransaction trans(dir_.get(), UNITTEST, __FILE__, __LINE__); @@ -691,7 +691,7 @@ TEST_F(SyncableDirectoryTest, TestSaveChangesFailure) { { WriteTransaction trans(dir_.get(), UNITTEST, __FILE__, __LINE__); - MutableEntry e1(&trans, CREATE, trans.root_id(), PSTR("aguilera")); + MutableEntry e1(&trans, CREATE, trans.root_id(), "aguilera"); ASSERT_TRUE(e1.good()); handle1 = e1.Get(META_HANDLE); e1.Put(BASE_VERSION, 1); @@ -710,10 +710,10 @@ TEST_F(SyncableDirectoryTest, TestSaveChangesFailure) { MutableEntry aguilera(&trans, GET_BY_HANDLE, handle1); ASSERT_TRUE(aguilera.good()); - aguilera.Put(NON_UNIQUE_NAME, PSTR("christina")); + aguilera.Put(NON_UNIQUE_NAME, "christina"); ASSERT_TRUE(aguilera.GetKernelCopy().dirty[NON_UNIQUE_NAME]); - MutableEntry kids_on_block(&trans, CREATE, trans.root_id(), PSTR("kids")); + MutableEntry kids_on_block(&trans, CREATE, trans.root_id(), "kids"); ASSERT_TRUE(kids_on_block.good()); handle2 = kids_on_block.Get(META_HANDLE); kids_on_block.Put(BASE_VERSION, 1); @@ -742,7 +742,7 @@ TEST_F(SyncableDirectoryTest, TestSaveChangesFailure) { void SyncableDirectoryTest::ValidateEntry(BaseTransaction* trans, int64 id, - bool check_name, PathString name, int64 base_version, int64 server_version, + bool check_name, string name, int64 base_version, int64 server_version, bool is_del) { Entry e(trans, GET_BY_ID, TestIdFactory::FromNumber(id)); ASSERT_TRUE(e.good()); @@ -756,11 +756,11 @@ void SyncableDirectoryTest::ValidateEntry(BaseTransaction* trans, int64 id, TEST(SyncableDirectoryManager, TestFileRelease) { DirectoryManager dm(FilePath(FILE_PATH_LITERAL("."))); - ASSERT_TRUE(dm.Open(PSTR("ScopeTest"))); + ASSERT_TRUE(dm.Open("ScopeTest")); { - ScopedDirLookup(&dm, PSTR("ScopeTest")); + ScopedDirLookup(&dm, "ScopeTest"); } - dm.Close(PSTR("ScopeTest")); + dm.Close("ScopeTest"); ASSERT_TRUE(file_util::Delete(dm.GetSyncDataDatabasePath(), true)); } @@ -773,7 +773,7 @@ class ThreadOpenTestDelegate : public PlatformThread::Delegate { private: // PlatformThread::Delegate methods: virtual void ThreadMain() { - CHECK(directory_manager_->Open(PSTR("Open"))); + CHECK(directory_manager_->Open("Open")); } DISALLOW_COPY_AND_ASSIGN(ThreadOpenTestDelegate); @@ -786,11 +786,11 @@ TEST(SyncableDirectoryManager, ThreadOpenTest) { ASSERT_TRUE(PlatformThread::Create(0, &test_delegate, &thread_handle)); PlatformThread::Join(thread_handle); { - ScopedDirLookup dir(&dm, PSTR("Open")); + ScopedDirLookup dir(&dm, "Open"); ASSERT_TRUE(dir.good()); } - dm.Close(PSTR("Open")); - ScopedDirLookup dir(&dm, PSTR("Open")); + dm.Close("Open"); + ScopedDirLookup dir(&dm, "Open"); ASSERT_FALSE(dir.good()); } @@ -816,7 +816,7 @@ class ThreadBugDelegate : public PlatformThread::Delegate { // PlatformThread::Delegate methods: virtual void ThreadMain() { - const PathString dirname = PSTR("ThreadBug1"); + const string dirname = "ThreadBug1"; AutoLock scoped_lock(step_->mutex); while (step_->number < 3) { @@ -834,7 +834,7 @@ class ThreadBugDelegate : public PlatformThread::Delegate { ScopedDirLookup dir(directory_manager_, dirname); CHECK(dir.good()); WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry me(&trans, CREATE, trans.root_id(), PSTR("Jeff")); + MutableEntry me(&trans, CREATE, trans.root_id(), "Jeff"); step_->metahandle = me.Get(META_HANDLE); me.Put(IS_UNSYNCED, true); } @@ -887,7 +887,7 @@ class DirectoryKernelStalenessBugDelegate : public ThreadBugDelegate { virtual void ThreadMain() { const char test_bytes[] = "test data"; - const PathString dirname = PSTR("DirectoryKernelStalenessBug"); + const string dirname = "DirectoryKernelStalenessBug"; AutoLock scoped_lock(step_->mutex); const Id jeff_id = TestIdFactory::FromNumber(100); @@ -906,7 +906,7 @@ class DirectoryKernelStalenessBugDelegate : public ThreadBugDelegate { ScopedDirLookup dir(directory_manager_, dirname); CHECK(dir.good()); WriteTransaction trans(dir, UNITTEST, __FILE__, __LINE__); - MutableEntry me(&trans, CREATE, trans.root_id(), PSTR("Jeff")); + MutableEntry me(&trans, CREATE, trans.root_id(), "Jeff"); me.Put(BASE_VERSION, 1); me.Put(ID, jeff_id); PutDataAsExtendedAttribute(&trans, &me, test_bytes, @@ -972,14 +972,14 @@ TEST(SyncableDirectoryManager, DirectoryKernelStalenessBug) { class StressTransactionsDelegate : public PlatformThread::Delegate { public: - StressTransactionsDelegate(DirectoryManager* dm, PathString dirname, + StressTransactionsDelegate(DirectoryManager* dm, string dirname, int thread_number) : directory_manager_(dm), dirname_(dirname), thread_number_(thread_number) {} private: DirectoryManager* const directory_manager_; - PathString dirname_; + string dirname_; const int thread_number_; // PlatformThread::Delegate methods: @@ -987,7 +987,7 @@ class StressTransactionsDelegate : public PlatformThread::Delegate { ScopedDirLookup dir(directory_manager_, dirname_); CHECK(dir.good()); int entry_count = 0; - PathString path_name; + string path_name; for (int i = 0; i < 20; ++i) { const int rand_action = rand() % 10; @@ -1016,7 +1016,7 @@ class StressTransactionsDelegate : public PlatformThread::Delegate { TEST(SyncableDirectory, StressTransactions) { DirectoryManager dirman(FilePath(FILE_PATH_LITERAL("."))); - PathString dirname = PSTR("stress"); + string dirname = "stress"; file_util::Delete(dirman.GetSyncDataDatabasePath(), true); dirman.Open(dirname); @@ -1058,8 +1058,8 @@ TEST(Syncable, ComparePathNames) { { 'b', 'A', 1 }, { 'b', 'a', 1 } }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - PathString a(1, tests[i].a); - PathString b(1, tests[i].b); + string a(1, tests[i].a); + string b(1, tests[i].b); const int result = ComparePathNames(a, b); if (result != tests[i].expected_result) { ADD_FAILURE() << "ComparePathNames(" << tests[i].a << ", " << tests[i].b @@ -1076,14 +1076,14 @@ void FakeSync(MutableEntry* e, const char* fake_id) { } TEST_F(SyncableDirectoryTest, Bug1509232) { - const PathString a = PSTR("alpha"); + const string a = "alpha"; const Id entry_id = dir_.get()->NextId(); CreateEntry(a, entry_id); { WriteTransaction trans(dir_.get(), UNITTEST, __FILE__, __LINE__); MutableEntry e(&trans, GET_BY_ID, entry_id); ASSERT_TRUE(e.good()); - ExtendedAttributeKey key(e.Get(META_HANDLE), PSTR("resourcefork")); + ExtendedAttributeKey key(e.Get(META_HANDLE), "resourcefork"); MutableExtendedAttribute ext(&trans, CREATE, key); ASSERT_TRUE(ext.good()); const char value[] = "stuff"; diff --git a/chrome/browser/sync/util/character_set_converters.cc b/chrome/browser/sync/util/character_set_converters.cc deleted file mode 100644 index 551ca2b..0000000 --- a/chrome/browser/sync/util/character_set_converters.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/sync/util/character_set_converters.h" - -namespace browser_sync { - -void TrimPathStringToValidCharacter(std::string* string) { - // Constants from http://en.wikipedia.org/wiki/UTF-8 - CHECK(string); - if (string->empty()) - return; - if (0 == (string->at(string->length() - 1) & 0x080)) - return; - size_t partial_enc_bytes = 0; - for (partial_enc_bytes = 0 ; true ; ++partial_enc_bytes) { - if (4 == partial_enc_bytes || partial_enc_bytes == string->length()) { - // original string was broken, garbage in, garbage out. - return; - } - PathChar c = string->at(string->length() - 1 - partial_enc_bytes); - if ((c & 0x0c0) == 0x080) // utf continuation char; - continue; - if ((c & 0x0e0) == 0x0e0) { // 2-byte encoded char. - if (1 == partial_enc_bytes) - return; - else - break; - } - if ((c & 0x0f0) == 0xc0) { // 3-byte encoded char. - if (2 == partial_enc_bytes) - return; - else - break; - } - if ((c & 0x0f8) == 0x0f0) { // 4-byte encoded char. - if (3 == partial_enc_bytes) - return; - else - break; - } - } - string->resize(string->length() - 1 - partial_enc_bytes); -} - -} // namespace browser_sync diff --git a/chrome/browser/sync/util/character_set_converters.h b/chrome/browser/sync/util/character_set_converters.h index b486f04..cbb44d6 100644 --- a/chrome/browser/sync/util/character_set_converters.h +++ b/chrome/browser/sync/util/character_set_converters.h @@ -23,8 +23,6 @@ std::string FilePathToUTF8(const FilePath& file_path); // Returns FilePath from the given UTF8 string. FilePath UTF8ToFilePath(const std::string& utf8); -void TrimPathStringToValidCharacter(std::string* string); - } // namespace browser_sync #endif // CHROME_BROWSER_SYNC_UTIL_CHARACTER_SET_CONVERTERS_H_ diff --git a/chrome/browser/sync/util/character_set_converters_unittest.cc b/chrome/browser/sync/util/character_set_converters_unittest.cc deleted file mode 100644 index aa8fa89..0000000 --- a/chrome/browser/sync/util/character_set_converters_unittest.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/sync/util/character_set_converters.h" - -#include <string> - -#include "testing/gtest/include/gtest/gtest.h" - -using std::string; - -class CharacterSetConverterTest : public testing::Test { -}; - -TEST(NameTruncation, WindowsNameTruncation) { - using browser_sync::TrimPathStringToValidCharacter; - char array[] = {'1', '2', '\xc0', '\xe0', '3', '4', '\0'}; - std::string message(array); - ASSERT_EQ(message.length(), arraysize(array) - 1); - string::size_type old_length = message.length(); - while (old_length != 0) { - TrimPathStringToValidCharacter(&message); - if (old_length == 4) - EXPECT_EQ(3u, message.length()); - else - EXPECT_EQ(old_length, message.length()); - message.resize(message.length() - 1); - old_length = message.length(); - } - TrimPathStringToValidCharacter(&message); -} diff --git a/chrome/browser/sync/util/query_helpers.h b/chrome/browser/sync/util/query_helpers.h index 66b1d81..c44e635 100644 --- a/chrome/browser/sync/util/query_helpers.h +++ b/chrome/browser/sync/util/query_helpers.h @@ -49,7 +49,7 @@ bool DoesTableExist(sqlite3* dbhandle, const std::string& tablename); // passed inside of the Vector. // Example: // -// vector<PathString> v; +// vector<std::string> v; // v.push_back("abc"); // v.push_back("123"); // PrepareQuery(dbhandle, "SELECT * FROM table", "column_name", v.begin(), diff --git a/chrome/browser/sync/util/sync_types.h b/chrome/browser/sync/util/sync_types.h index 429033b..14addd0 100644 --- a/chrome/browser/sync/util/sync_types.h +++ b/chrome/browser/sync/util/sync_types.h @@ -12,10 +12,6 @@ #include "base/string_util.h" #include "build/build_config.h" -#define PSTR(s) s -#define PSTR_CHAR char -typedef std::string PathString; - #if !defined(OS_WIN) // Mac OS X typedef's BOOL to signed char, so we do that on Linux too. typedef signed char BOOL; @@ -33,21 +29,10 @@ const BOOL FALSE = 0; #endif #endif -typedef PathString::value_type PathChar; - -inline size_t CountBytes(const std::wstring& s) { - return s.size() * sizeof(std::wstring::value_type); -} - inline size_t CountBytes(const std::string &s) { return s.size() * sizeof(std::string::value_type); } -inline PathString IntToPathString(int digit) { - std::string tmp = StringPrintf("%d", digit); - return PathString(tmp.begin(), tmp.end()); -} - const size_t kSyncProtocolMaxNameLengthBytes = 255; #endif // CHROME_BROWSER_SYNC_UTIL_SYNC_TYPES_H_ diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index aaf0bf6..4cc29cb 100755 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -5503,7 +5503,6 @@ 'browser/sync/sessions/sync_session_unittest.cc', 'browser/sync/syncable/syncable_id_unittest.cc', 'browser/sync/syncable/syncable_unittest.cc', - 'browser/sync/util/character_set_converters_unittest.cc', 'browser/sync/util/crypto_helpers_unittest.cc', 'browser/sync/util/event_sys_unittest.cc', 'browser/sync/util/extensions_activity_monitor_unittest.cc', @@ -5656,7 +5655,6 @@ 'browser/sync/syncable/syncable_columns.h', 'browser/sync/syncable/syncable_id.cc', 'browser/sync/syncable/syncable_id.h', - 'browser/sync/util/character_set_converters.cc', 'browser/sync/util/character_set_converters.h', 'browser/sync/util/character_set_converters_posix.cc', 'browser/sync/util/character_set_converters_win.cc', diff --git a/chrome/test/sync/engine/test_directory_setter_upper.cc b/chrome/test/sync/engine/test_directory_setter_upper.cc index 999ddc2..e934f47 100644 --- a/chrome/test/sync/engine/test_directory_setter_upper.cc +++ b/chrome/test/sync/engine/test_directory_setter_upper.cc @@ -17,7 +17,7 @@ using syncable::ScopedDirLookup; namespace browser_sync { -TestDirectorySetterUpper::TestDirectorySetterUpper() : name_(PSTR("Test")) {} +TestDirectorySetterUpper::TestDirectorySetterUpper() : name_("Test") {} TestDirectorySetterUpper::TestDirectorySetterUpper(const std::string& name) : name_(name) {} diff --git a/chrome/test/sync/engine/test_syncable_utils.cc b/chrome/test/sync/engine/test_syncable_utils.cc index e01d3f0..12e5b05 100755 --- a/chrome/test/sync/engine/test_syncable_utils.cc +++ b/chrome/test/sync/engine/test_syncable_utils.cc @@ -8,11 +8,13 @@ #include "chrome/browser/sync/syncable/syncable.h" +using std::string; + namespace syncable { int CountEntriesWithName(BaseTransaction* rtrans, const syncable::Id& parent_id, - const PathString& name) { + const string& name) { Directory::ChildHandles child_handles; rtrans->directory()->GetChildHandles(rtrans, parent_id, &child_handles); if (child_handles.size() <= 0) { @@ -33,7 +35,7 @@ int CountEntriesWithName(BaseTransaction* rtrans, Id GetFirstEntryWithName(BaseTransaction* rtrans, const syncable::Id& parent_id, - const PathString& name) { + const string& name) { Directory::ChildHandles child_handles; rtrans->directory()->GetChildHandles(rtrans, parent_id, &child_handles); @@ -52,7 +54,7 @@ Id GetFirstEntryWithName(BaseTransaction* rtrans, Id GetOnlyEntryWithName(BaseTransaction* rtrans, const syncable::Id& parent_id, - const PathString& name) { + const string& name) { CHECK(1 == CountEntriesWithName(rtrans, parent_id, name)); return GetFirstEntryWithName(rtrans, parent_id, name); } diff --git a/chrome/test/sync/engine/test_syncable_utils.h b/chrome/test/sync/engine/test_syncable_utils.h index 4d6ce9c..05cecb6 100755 --- a/chrome/test/sync/engine/test_syncable_utils.h +++ b/chrome/test/sync/engine/test_syncable_utils.h @@ -8,6 +8,8 @@ #ifndef CHROME_TEST_SYNC_ENGINE_TEST_SYNCABLE_UTILS_H_ #define CHROME_TEST_SYNC_ENGINE_TEST_SYNCABLE_UTILS_H_ +#include <string> + #include "chrome/browser/sync/syncable/syncable.h" namespace syncable { @@ -20,18 +22,18 @@ class Id; // rely on uniqueness inside of folders. int CountEntriesWithName(BaseTransaction* rtrans, const syncable::Id& parent_id, - const PathString& name); + const std::string& name); // Get the first entry ID with name in a parent. The entry *must* exist. Id GetFirstEntryWithName(BaseTransaction* rtrans, const syncable::Id& parent_id, - const PathString& name); + const std::string& name); // Assert that there's only one entry by this name in this parent. // Return the Id. Id GetOnlyEntryWithName(BaseTransaction* rtrans, const syncable::Id& parent_id, - const PathString& name); + const std::string& name); } // namespace syncable |