summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/syncable
diff options
context:
space:
mode:
authormunjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-24 01:10:35 +0000
committermunjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-24 01:10:35 +0000
commit43c6dae7c9d9dc3cf639a4ada168d880b800e34b (patch)
tree3a59983e36763bee8846cd3d1209812587ef0836 /chrome/browser/sync/syncable
parent64f9baa2bb3cc42f4fed901f2171409f9a890f71 (diff)
downloadchromium_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
Diffstat (limited to 'chrome/browser/sync/syncable')
-rwxr-xr-xchrome/browser/sync/syncable/directory_backing_store.cc8
-rw-r--r--chrome/browser/sync/syncable/directory_backing_store.h5
-rwxr-xr-xchrome/browser/sync/syncable/syncable.cc68
-rwxr-xr-xchrome/browser/sync/syncable/syncable.h48
-rwxr-xr-xchrome/browser/sync/syncable/syncable_unittest.cc124
5 files changed, 125 insertions, 128 deletions
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";