summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/engine
diff options
context:
space:
mode:
authormunjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-04 18:33:53 +0000
committermunjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-04 18:33:53 +0000
commit055aedeb2134e49c10c3b3a3593cb8df768d737c (patch)
tree4961da84e3e38e7c6a3edb68bb96e031f8856604 /chrome/browser/sync/engine
parent46e9f9d97ec029189618f8ff2089948b950e67e7 (diff)
downloadchromium_src-055aedeb2134e49c10c3b3a3593cb8df768d737c.zip
chromium_src-055aedeb2134e49c10c3b3a3593cb8df768d737c.tar.gz
chromium_src-055aedeb2134e49c10c3b3a3593cb8df768d737c.tar.bz2
Clean up the strings for sync code:
- Use FilePath for real file paths. - Use std::string for PathString on Windows as well TODO in a separate CL: - Get rid of PathString typedef completely and directly use std::string everywhere. - Use wchar_t in syncapi.h/.cc and get rid of sync_char16. TEST=Existing tests are sufficient since this CL does a lot of code refactoring. BUG=26342 Review URL: http://codereview.chromium.org/340055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30970 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/engine')
-rw-r--r--chrome/browser/sync/engine/apply_updates_command_unittest.cc7
-rw-r--r--chrome/browser/sync/engine/auth_watcher.cc7
-rw-r--r--chrome/browser/sync/engine/auth_watcher_unittest.cc2
-rw-r--r--chrome/browser/sync/engine/build_commit_command.cc12
-rw-r--r--chrome/browser/sync/engine/download_updates_command.cc4
-rw-r--r--chrome/browser/sync/engine/net/server_connection_manager.cc3
-rw-r--r--chrome/browser/sync/engine/net/url_translator.cc1
-rw-r--r--chrome/browser/sync/engine/process_commit_response_command.cc1
-rw-r--r--chrome/browser/sync/engine/process_updates_command.cc1
-rw-r--r--chrome/browser/sync/engine/syncapi.cc76
-rw-r--r--chrome/browser/sync/engine/syncapi.h3
-rw-r--r--chrome/browser/sync/engine/syncer.cc1
-rw-r--r--chrome/browser/sync/engine/syncer_proto_util.cc19
-rw-r--r--chrome/browser/sync/engine/syncer_unittest.cc11
-rw-r--r--chrome/browser/sync/engine/syncer_util.cc12
-rw-r--r--chrome/browser/sync/engine/verify_updates_command.cc1
16 files changed, 46 insertions, 115 deletions
diff --git a/chrome/browser/sync/engine/apply_updates_command_unittest.cc b/chrome/browser/sync/engine/apply_updates_command_unittest.cc
index afa0969..aff2c63 100644
--- a/chrome/browser/sync/engine/apply_updates_command_unittest.cc
+++ b/chrome/browser/sync/engine/apply_updates_command_unittest.cc
@@ -9,7 +9,6 @@
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable.h"
#include "chrome/browser/sync/syncable/syncable_id.h"
-#include "chrome/browser/sync/util/character_set_converters.h"
#include "chrome/test/sync/engine/test_directory_setter_upper.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -46,12 +45,10 @@ class ApplyUpdatesCommandTest : public testing::Test {
MutableEntry entry(&trans, syncable::CREATE_NEW_UPDATE_ITEM,
Id::CreateFromServerId(item_id));
ASSERT_TRUE(entry.good());
- PathString name;
- AppendUTF8ToPathString(item_id, &name);
entry.Put(syncable::SERVER_VERSION, next_revision_++);
entry.Put(syncable::IS_UNAPPLIED_UPDATE, true);
- entry.Put(syncable::SERVER_NAME, name);
- entry.Put(syncable::SERVER_NON_UNIQUE_NAME, name);
+ entry.Put(syncable::SERVER_NAME, item_id);
+ entry.Put(syncable::SERVER_NON_UNIQUE_NAME, item_id);
entry.Put(syncable::SERVER_PARENT_ID, Id::CreateFromServerId(parent_id));
entry.Put(syncable::SERVER_IS_DIR, true);
}
diff --git a/chrome/browser/sync/engine/auth_watcher.cc b/chrome/browser/sync/engine/auth_watcher.cc
index c722a8d..9d81d28 100644
--- a/chrome/browser/sync/engine/auth_watcher.cc
+++ b/chrome/browser/sync/engine/auth_watcher.cc
@@ -13,7 +13,6 @@
#include "chrome/browser/sync/notifier/listener/talk_mediator.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable.h"
-#include "chrome/browser/sync/util/character_set_converters.h"
#include "chrome/browser/sync/util/event_sys-inl.h"
#include "chrome/browser/sync/util/user_settings.h"
@@ -122,8 +121,7 @@ void AuthWatcher::DoAuthenticateWithToken(const std::string& gaia_email,
case Authenticator::SUCCESS:
{
status_ = GAIA_AUTHENTICATED;
- PathString share_name;
- CHECK(AppendUTF8ToPathString(email.data(), email.size(), &share_name));
+ const PathString& share_name = email;
user_settings_->SwitchUser(email);
// Set the authentication token for notifications
@@ -165,8 +163,7 @@ bool AuthWatcher::AuthenticateLocally(string email) {
gaia_->SetUsername(email);
status_ = LOCALLY_AUTHENTICATED;
user_settings_->SwitchUser(email);
- PathString share_name;
- CHECK(AppendUTF8ToPathString(email.data(), email.size(), &share_name));
+ const PathString& share_name = email;
LoadDirectoryListAndOpen(share_name);
NotifyAuthSucceeded(email);
return true;
diff --git a/chrome/browser/sync/engine/auth_watcher_unittest.cc b/chrome/browser/sync/engine/auth_watcher_unittest.cc
index ede4023..c2561630 100644
--- a/chrome/browser/sync/engine/auth_watcher_unittest.cc
+++ b/chrome/browser/sync/engine/auth_watcher_unittest.cc
@@ -86,7 +86,7 @@ class AuthWatcherTest : public testing::Test {
allstatus_.reset(new AllStatus());
user_settings_.reset(new UserSettings());
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- PathString user_settings_path = temp_dir_.path().value() + kUserSettingsDB;
+ FilePath user_settings_path = temp_dir_.path().Append(kUserSettingsDB);
user_settings_->Init(user_settings_path);
gaia_auth_ = new GaiaAuthMockForAuthWatcher();
talk_mediator_.reset(new TalkMediatorImpl());
diff --git a/chrome/browser/sync/engine/build_commit_command.cc b/chrome/browser/sync/engine/build_commit_command.cc
index 5058bba..07ae99a 100644
--- a/chrome/browser/sync/engine/build_commit_command.cc
+++ b/chrome/browser/sync/engine/build_commit_command.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/sync/engine/syncproto.h"
#include "chrome/browser/sync/syncable/syncable.h"
#include "chrome/browser/sync/syncable/syncable_changes_version.h"
-#include "chrome/browser/sync/util/character_set_converters.h"
#include "chrome/browser/sync/util/sync_types.h"
using std::set;
@@ -46,7 +45,7 @@ void BuildCommitCommand::AddExtensionsActivityToMessage(
void BuildCommitCommand::ExecuteImpl(SyncerSession* session) {
ClientToServerMessage message;
- message.set_share(ToUTF8(session->account_name()).get_string());
+ message.set_share(session->account_name());
message.set_message_contents(ClientToServerMessage::COMMIT);
CommitMessage* commit_message = message.mutable_commit();
@@ -69,15 +68,14 @@ void BuildCommitCommand::ExecuteImpl(SyncerSession* session) {
Name name = meta_entry.GetName();
CHECK(!name.value().empty()); // Make sure this isn't an update.
- sync_entry->set_name(ToUTF8(name.value()).get_string());
+ sync_entry->set_name(name.value());
// Set the non_unique_name if we have one. If we do, the server ignores
// the |name| value (using |non_unique_name| instead), and will return
// in the CommitResponse a unique name if one is generated. Even though
// we could get away with only sending |name|, we send both because it
// may aid in logging.
if (name.value() != name.non_unique_value()) {
- sync_entry->set_non_unique_name(
- ToUTF8(name.non_unique_value()).get_string());
+ sync_entry->set_non_unique_name(name.non_unique_value());
}
// Deleted items with negative parent ids can be a problem so we set the
// parent to 0. (TODO(sync): Still true in protocol?).
@@ -126,7 +124,7 @@ void BuildCommitCommand::ExecuteImpl(SyncerSession* session) {
++iter) {
sync_pb::ExtendedAttributes_ExtendedAttribute *extended_attribute =
mutable_extended_attributes->add_extendedattribute();
- extended_attribute->set_key(ToUTF8(iter->key()).get_string());
+ extended_attribute->set_key(iter->key());
SyncerProtoUtil::CopyBlobIntoProtoBytes(iter->value(),
extended_attribute->mutable_value());
}
@@ -143,7 +141,7 @@ void BuildCommitCommand::ExecuteImpl(SyncerSession* session) {
sync_entry->set_insert_after_item_id(prev_string);
if (!meta_entry.Get(syncable::IS_DIR)) {
- string bookmark_url = ToUTF8(meta_entry.Get(syncable::BOOKMARK_URL));
+ string bookmark_url = meta_entry.Get(syncable::BOOKMARK_URL);
bookmark->set_bookmark_url(bookmark_url);
SyncerProtoUtil::CopyBlobIntoProtoBytes(
meta_entry.Get(syncable::BOOKMARK_FAVICON),
diff --git a/chrome/browser/sync/engine/download_updates_command.cc b/chrome/browser/sync/engine/download_updates_command.cc
index 889567e..1883e31 100644
--- a/chrome/browser/sync/engine/download_updates_command.cc
+++ b/chrome/browser/sync/engine/download_updates_command.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/sync/engine/syncer_proto_util.h"
#include "chrome/browser/sync/engine/syncproto.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
-#include "chrome/browser/sync/util/character_set_converters.h"
#include "chrome/browser/sync/util/sync_types.h"
using syncable::ScopedDirLookup;
@@ -26,8 +25,7 @@ void DownloadUpdatesCommand::ExecuteImpl(SyncerSession* session) {
ClientToServerMessage client_to_server_message;
ClientToServerResponse update_response;
- client_to_server_message.set_share(
- static_cast<const string&>(ToUTF8(session->account_name())));
+ client_to_server_message.set_share(session->account_name());
client_to_server_message.set_message_contents(
ClientToServerMessage::GET_UPDATES);
GetUpdatesMessage* get_updates =
diff --git a/chrome/browser/sync/engine/net/server_connection_manager.cc b/chrome/browser/sync/engine/net/server_connection_manager.cc
index c8165a9..38d140f 100644
--- a/chrome/browser/sync/engine/net/server_connection_manager.cc
+++ b/chrome/browser/sync/engine/net/server_connection_manager.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/sync/engine/syncproto.h"
#include "chrome/browser/sync/protocol/sync.pb.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
-#include "chrome/browser/sync/util/character_set_converters.h"
#include "chrome/browser/sync/util/event_sys-inl.h"
namespace browser_sync {
@@ -355,7 +354,7 @@ bool FillMessageWithShareDetails(sync_pb::ClientToServerMessage* csm,
string birthday = dir->store_birthday();
if (!birthday.empty())
csm->set_store_birthday(birthday);
- csm->set_share(ToUTF8(share).get_string());
+ csm->set_share(share);
return true;
}
diff --git a/chrome/browser/sync/engine/net/url_translator.cc b/chrome/browser/sync/engine/net/url_translator.cc
index 8a1c0a3..6dc2754 100644
--- a/chrome/browser/sync/engine/net/url_translator.cc
+++ b/chrome/browser/sync/engine/net/url_translator.cc
@@ -10,7 +10,6 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/port.h"
-#include "chrome/browser/sync/util/character_set_converters.h"
#include "net/base/escape.h"
using std::string;
diff --git a/chrome/browser/sync/engine/process_commit_response_command.cc b/chrome/browser/sync/engine/process_commit_response_command.cc
index 72fd0e6..de993fb 100644
--- a/chrome/browser/sync/engine/process_commit_response_command.cc
+++ b/chrome/browser/sync/engine/process_commit_response_command.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/sync/engine/syncproto.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable.h"
-#include "chrome/browser/sync/util/character_set_converters.h"
using syncable::ScopedDirLookup;
using syncable::WriteTransaction;
diff --git a/chrome/browser/sync/engine/process_updates_command.cc b/chrome/browser/sync/engine/process_updates_command.cc
index 31d267d..fefa234 100644
--- a/chrome/browser/sync/engine/process_updates_command.cc
+++ b/chrome/browser/sync/engine/process_updates_command.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/sync/engine/syncproto.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable.h"
-#include "chrome/browser/sync/util/character_set_converters.h"
using std::vector;
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc
index 7d953d0..7cf18bc 100644
--- a/chrome/browser/sync/engine/syncapi.cc
+++ b/chrome/browser/sync/engine/syncapi.cc
@@ -133,8 +133,8 @@ class AddressWatchTask : public Task {
namespace sync_api {
class ModelSafeWorkerBridge;
-static const PSTR_CHAR kBookmarkSyncUserSettingsDatabase[] =
- PSTR("BookmarkSyncSettings.sqlite3");
+static const FilePath::CharType kBookmarkSyncUserSettingsDatabase[] =
+ FILE_PATH_LITERAL("BookmarkSyncSettings.sqlite3");
static const PSTR_CHAR kDefaultNameForNewNodes[] = PSTR(" ");
// The list of names which are reserved for use by the server.
@@ -171,29 +171,11 @@ static bool EndsWithSpace(const string16& string) {
return !string.empty() && *string.rbegin() == ' ';
}
-static inline void String16ToPathString(const sync_char16 *in,
- PathString *out) {
- string16 in_str(in);
-#if defined(OS_WIN)
- out->assign(in_str);
-#else
- UTF16ToUTF8(in_str.c_str(), in_str.length(), out);
-#endif
-}
-
-static inline void PathStringToString16(const PathString& in, string16* out) {
-#if defined(OS_WIN)
- out->assign(in);
-#else
- UTF8ToUTF16(in.c_str(), in.length(), out);
-#endif
-}
-
// When taking a name from the syncapi, append a space if it matches the
// pattern of a server-illegal name followed by zero or more spaces.
static void SyncAPINameToServerName(const sync_char16 *sync_api_name,
PathString* out) {
- String16ToPathString(sync_api_name, out);
+ *out = UTF16ToUTF8(sync_api_name);
string16 sync_api_name_str(sync_api_name);
if (IsNameServerIllegalAfterTrimming(sync_api_name_str))
out->append(PSTR(" "));
@@ -204,8 +186,7 @@ static void SyncAPINameToServerName(const sync_char16 *sync_api_name,
// space.
static void ServerNameToSyncAPIName(const PathString& server_name,
string16*out) {
- string16 server_name_str;
- PathStringToString16(server_name, &server_name_str);
+ string16 server_name_str(UTF8ToUTF16(server_name));
if (IsNameServerIllegalAfterTrimming(server_name_str) &&
EndsWithSpace(server_name_str))
out->assign(server_name_str, 0, server_name_str.size() - 1);
@@ -272,7 +253,7 @@ const sync_char16* BaseNode::GetTitle() const {
const sync_char16* BaseNode::GetURL() const {
// Store the string in data_ so that the returned pointer is valid.
- PathStringToString16(GetEntry()->Get(syncable::BOOKMARK_URL), &data_->url);
+ data_->url = UTF8ToUTF16(GetEntry()->Get(syncable::BOOKMARK_URL));
return data_->url.c_str();
}
@@ -357,8 +338,7 @@ void WriteNode::SetTitle(const sync_char16* title) {
}
void WriteNode::SetURL(const sync_char16* url) {
- PathString url_string;
- String16ToPathString(url, &url_string);
+ PathString url_string(UTF16ToUTF8(url));
if (url_string == entry_->Get(syncable::BOOKMARK_URL))
return; // Skip redundant changes.
@@ -543,8 +523,7 @@ const BaseTransaction* ReadNode::GetTransaction() const {
bool ReadNode::InitByTagLookup(const sync_char16* tag) {
DCHECK(!entry_) << "Init called twice";
- PathString tag_string;
- String16ToPathString(tag, &tag_string);
+ PathString tag_string(UTF16ToUTF8(tag));
if (tag_string.empty())
return false;
syncable::BaseTransaction* trans = transaction_->GetWrappedTrans();
@@ -702,7 +681,7 @@ class SyncManager::SyncInternal {
~SyncInternal() { }
- bool Init(const PathString& database_location,
+ bool Init(const FilePath& database_location,
const std::string& sync_server_and_path,
int port,
const char* gaia_service_id,
@@ -941,7 +920,7 @@ SyncManager::SyncManager() {
data_ = new SyncInternal(this);
}
-bool SyncManager::Init(const sync_char16* database_location,
+bool SyncManager::Init(const FilePath& database_location,
const char* sync_server_and_path,
int sync_server_port,
const char* gaia_service_id,
@@ -952,13 +931,10 @@ bool SyncManager::Init(const sync_char16* database_location,
ModelSafeWorkerInterface* model_safe_worker,
bool attempt_last_user_authentication,
const char* user_agent) {
- DCHECK(database_location);
DCHECK(post_factory);
- PathString db_path;
- String16ToPathString(database_location, &db_path);
string server_string(sync_server_and_path);
- return data_->Init(db_path,
+ return data_->Init(database_location,
server_string,
sync_server_port,
gaia_service_id,
@@ -982,13 +958,12 @@ const char* SyncManager::GetAuthenticatedUsername() {
}
const char* SyncManager::SyncInternal::GetAuthenticatedUsername() {
- cached_auth_watcher_email_ = browser_sync::ToUTF8(
- username_for_share()).get_string();
+ cached_auth_watcher_email_ = username_for_share();
return cached_auth_watcher_email_.c_str();
}
bool SyncManager::SyncInternal::Init(
- const PathString& database_location,
+ const FilePath& database_location,
const std::string& sync_server_and_path,
int port,
const char* gaia_service_id,
@@ -1001,8 +976,8 @@ bool SyncManager::SyncInternal::Init(
// Set up UserSettings, creating the db if necessary. We need this to
// instantiate a URLFactory to give to the Syncer.
- PathString settings_db_file = AppendSlash(database_location) +
- kBookmarkSyncUserSettingsDatabase;
+ FilePath settings_db_file =
+ database_location.Append(FilePath(kBookmarkSyncUserSettingsDatabase));
user_settings_.reset(new UserSettings());
if (!user_settings_->Init(settings_db_file))
return false;
@@ -1103,8 +1078,7 @@ void SyncManager::SyncInternal::MarkAndNotifyInitializationComplete() {
void SyncManager::SyncInternal::Authenticate(const std::string& username,
const std::string& password) {
- DCHECK(username_for_share().empty() ||
- (username == browser_sync::ToUTF8(username_for_share()).get_string()))
+ DCHECK(username_for_share().empty() || username == username_for_share())
<< "Username change from valid username detected";
if (allstatus()->status().authenticated)
return;
@@ -1127,13 +1101,7 @@ void SyncManager::SyncInternal::AuthenticateForLastKnownUser() {
return;
}
- browser_sync::ToPathString s(username);
- if (s.good()) {
- share_.authenticated_name = s.get_string16();
- } else {
- RaiseAuthNeededEvent();
- return;
- }
+ share_.authenticated_name = username;
// We optimize by opening the directory before the "fresh" authentication
// attempt completes so that we can immediately begin processing changes.
@@ -1449,16 +1417,12 @@ void SyncManager::SyncInternal::HandleAuthWatcherEvent(
// We now know the supplied username and password were valid. If this
// wasn't the first sync, authenticated_name should already be assigned.
if (username_for_share().empty()) {
- browser_sync::ToPathString s(event.user_email);
- if (s.good())
- share_.authenticated_name = s.get_string16();
+ share_.authenticated_name = event.user_email;
}
- DCHECK(LowerCaseEqualsASCII(browser_sync::ToUTF8(
- username_for_share()).get_string(),
+ DCHECK(LowerCaseEqualsASCII(username_for_share(),
StringToLowerASCII(event.user_email).c_str()))
- << "username_for_share= "
- << browser_sync::ToUTF8(username_for_share())
+ << "username_for_share= " << username_for_share()
<< ", event.user_email= " << event.user_email;
if (observer_)
@@ -1536,7 +1500,7 @@ void SyncManager::SetupForTestMode(const sync_char16* test_username) {
void SyncManager::SyncInternal::SetupForTestMode(
const sync_char16* test_username) {
- String16ToPathString(test_username, &share_.authenticated_name);
+ share_.authenticated_name = UTF16ToUTF8(test_username);
if (!dir_manager()->Open(username_for_share()))
DCHECK(false) << "Could not open directory when running in test mode";
diff --git a/chrome/browser/sync/engine/syncapi.h b/chrome/browser/sync/engine/syncapi.h
index 474a7a5..f85b25b 100644
--- a/chrome/browser/sync/engine/syncapi.h
+++ b/chrome/browser/sync/engine/syncapi.h
@@ -39,6 +39,7 @@
#define CHROME_BROWSER_SYNC_ENGINE_SYNCAPI_H_
#include "base/basictypes.h"
+#include "base/file_path.h"
#include "build/build_config.h"
#if defined(OS_WIN)
@@ -523,7 +524,7 @@ class SYNC_EXPORT SyncManager {
// |model_safe_worker| ownership is given to the SyncManager.
// |user_agent| is a 7-bit ASCII string suitable for use as the User-Agent
// HTTP header. Used internally when collecting stats to classify clients.
- bool Init(const sync_char16* database_location,
+ bool Init(const FilePath& database_location,
const char* sync_server_and_path,
int sync_server_port,
const char* gaia_service_id,
diff --git a/chrome/browser/sync/engine/syncer.cc b/chrome/browser/sync/engine/syncer.cc
index ee56bb9..ee92258 100644
--- a/chrome/browser/sync/engine/syncer.cc
+++ b/chrome/browser/sync/engine/syncer.cc
@@ -26,7 +26,6 @@
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable-inl.h"
#include "chrome/browser/sync/syncable/syncable.h"
-#include "chrome/browser/sync/util/character_set_converters.h"
using sync_pb::ClientCommand;
using syncable::Blob;
diff --git a/chrome/browser/sync/engine/syncer_proto_util.cc b/chrome/browser/sync/engine/syncer_proto_util.cc
index 4896c59..7eb0227 100644
--- a/chrome/browser/sync/engine/syncer_proto_util.cc
+++ b/chrome/browser/sync/engine/syncer_proto_util.cc
@@ -11,7 +11,6 @@
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable-inl.h"
#include "chrome/browser/sync/syncable/syncable.h"
-#include "chrome/browser/sync/util/character_set_converters.h"
using std::string;
using std::stringstream;
@@ -246,14 +245,9 @@ void SyncerProtoUtil::CopyBlobIntoProtoBytes(const syncable::Blob& blob,
// static
syncable::SyncName SyncerProtoUtil::NameFromSyncEntity(
const SyncEntity& entry) {
- SyncName result(PSTR(""));
-
- AppendUTF8ToPathString(entry.name(), &result.value());
+ SyncName result(entry.name());
if (entry.has_non_unique_name()) {
- AppendUTF8ToPathString(entry.non_unique_name(),
- &result.non_unique_value());
- } else {
- result.non_unique_value() = result.value();
+ result.set_non_unique_value(entry.non_unique_name());
}
return result;
}
@@ -261,14 +255,9 @@ syncable::SyncName SyncerProtoUtil::NameFromSyncEntity(
// static
syncable::SyncName SyncerProtoUtil::NameFromCommitEntryResponse(
const CommitResponse_EntryResponse& entry) {
- SyncName result(PSTR(""));
-
- AppendUTF8ToPathString(entry.name(), &result.value());
+ SyncName result(entry.name());
if (entry.has_non_unique_name()) {
- AppendUTF8ToPathString(entry.non_unique_name(),
- &result.non_unique_value());
- } else {
- result.non_unique_value() = result.value();
+ result.set_non_unique_value(entry.non_unique_name());
}
return result;
}
diff --git a/chrome/browser/sync/engine/syncer_unittest.cc b/chrome/browser/sync/engine/syncer_unittest.cc
index 288ed42..47a67bc 100644
--- a/chrome/browser/sync/engine/syncer_unittest.cc
+++ b/chrome/browser/sync/engine/syncer_unittest.cc
@@ -27,8 +27,6 @@
#include "chrome/browser/sync/protocol/sync.pb.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable.h"
-#include "chrome/browser/sync/util/character_set_converters.h"
-#include "chrome/browser/sync/util/compat_file.h"
#include "chrome/browser/sync/util/event_sys-inl.h"
#include "chrome/test/sync/engine/mock_server_connection.h"
#include "chrome/test/sync/engine/test_directory_setter_upper.h"
@@ -1392,14 +1390,13 @@ TEST_F(SyncerTest, CommitTimeRenameI18N) {
// Verify it was correctly renamed.
{
ReadTransaction trans(dir, __FILE__, __LINE__);
- PathString expectedFolder;
- AppendUTF8ToPathString(i18nString, &expectedFolder);
- AppendUTF8ToPathString("Folder", &expectedFolder);
+ PathString expectedFolder(i18nString);
+ expectedFolder.append("Folder");
Entry entry_folder(&trans, GET_BY_PATH, expectedFolder);
ASSERT_TRUE(entry_folder.good());
PathString expected = expectedFolder + PathString(kPathSeparator);
- AppendUTF8ToPathString(i18nString, &expected);
- AppendUTF8ToPathString("new_entry", &expected);
+ expected.append(i18nString);
+ expected.append("new_entry");
Entry entry_new(&trans, GET_BY_PATH, expected);
ASSERT_TRUE(entry_new.good());
diff --git a/chrome/browser/sync/engine/syncer_util.cc b/chrome/browser/sync/engine/syncer_util.cc
index 4074cd6..6828297 100644
--- a/chrome/browser/sync/engine/syncer_util.cc
+++ b/chrome/browser/sync/engine/syncer_util.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable.h"
#include "chrome/browser/sync/syncable/syncable_changes_version.h"
-#include "chrome/browser/sync/util/character_set_converters.h"
#include "chrome/browser/sync/util/path_helpers.h"
#include "chrome/browser/sync/util/sync_types.h"
@@ -329,15 +328,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()) {
- PathString tag;
- AppendUTF8ToPathString(server_entry.singleton_tag(), &tag);
+ const PathString& 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()) {
- PathString url;
- AppendUTF8ToPathString(bookmark.bookmark_url(), &url);
+ const PathString& url = bookmark.bookmark_url();
local_entry->Put(SERVER_BOOKMARK_URL, url);
}
if (bookmark.has_bookmark_favicon()) {
@@ -371,9 +368,8 @@ void SyncerUtil::ApplyExtendedAttributes(
const sync_pb::ExtendedAttributes & extended_attributes =
server_entry.extended_attributes();
for (int i = 0; i < extended_attributes.extendedattribute_size(); i++) {
- PathString pathstring_key;
- AppendUTF8ToPathString(
- extended_attributes.extendedattribute(i).key(), &pathstring_key);
+ const PathString& pathstring_key =
+ extended_attributes.extendedattribute(i).key();
ExtendedAttributeKey key(local_entry->Get(META_HANDLE), pathstring_key);
MutableExtendedAttribute local_attribute(local_entry->write_transaction(),
CREATE, key);
diff --git a/chrome/browser/sync/engine/verify_updates_command.cc b/chrome/browser/sync/engine/verify_updates_command.cc
index 7a23477..83d0257 100644
--- a/chrome/browser/sync/engine/verify_updates_command.cc
+++ b/chrome/browser/sync/engine/verify_updates_command.cc
@@ -12,7 +12,6 @@
#include "chrome/browser/sync/engine/syncproto.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable.h"
-#include "chrome/browser/sync/util/character_set_converters.h"
#include "chrome/browser/sync/util/sync_types.h"
namespace browser_sync {