diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-25 22:49:02 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-25 22:49:02 +0000 |
commit | ca318f968ab42e5ac1f83912973b1a857ee8f9e9 (patch) | |
tree | 49187e58562cd8a68714b3cc1350bdff1ca47817 /chrome | |
parent | cd91aff2f0ced8ac9027e35f5ee82400d7fa5298 (diff) | |
download | chromium_src-ca318f968ab42e5ac1f83912973b1a857ee8f9e9.zip chromium_src-ca318f968ab42e5ac1f83912973b1a857ee8f9e9.tar.gz chromium_src-ca318f968ab42e5ac1f83912973b1a857ee8f9e9.tar.bz2 |
[Sync] Remove now-obsolete FastDump class
Fix uses of bare 'string' to be 'std::string'.
BUG=55816
TEST=None
Review URL: http://codereview.chromium.org/6304021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72559 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/sync/engine/process_commit_response_command.h | 3 | ||||
-rw-r--r-- | chrome/browser/sync/engine/syncer_proto_util_unittest.cc | 8 | ||||
-rw-r--r-- | chrome/browser/sync/profile_sync_service_autofill_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/sync/syncable/directory_backing_store.h | 4 | ||||
-rw-r--r-- | chrome/browser/sync/syncable/syncable.cc | 65 | ||||
-rw-r--r-- | chrome/browser/sync/syncable/syncable.h | 3 | ||||
-rw-r--r-- | chrome/browser/sync/syncable/syncable_id.cc | 6 | ||||
-rw-r--r-- | chrome/browser/sync/syncable/syncable_id.h | 4 | ||||
-rw-r--r-- | chrome/browser/sync/util/fast_dump.h | 58 | ||||
-rw-r--r-- | chrome/browser/sync/util/user_settings_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/chrome.gyp | 1 | ||||
-rw-r--r-- | chrome/test/sync/engine/mock_connection_manager.h | 48 |
12 files changed, 54 insertions, 156 deletions
diff --git a/chrome/browser/sync/engine/process_commit_response_command.h b/chrome/browser/sync/engine/process_commit_response_command.h index bbc85bf..dbba580 100644 --- a/chrome/browser/sync/engine/process_commit_response_command.h +++ b/chrome/browser/sync/engine/process_commit_response_command.h @@ -7,6 +7,7 @@ #pragma once #include <set> +#include <string> #include "base/basictypes.h" #include "chrome/browser/sync/engine/model_changing_syncer_command.h" @@ -82,7 +83,7 @@ class ProcessCommitResponseCommand : public ModelChangingSyncerCommand { syncable::MutableEntry* local_entry); // Helper to extract the final name from the protobufs. - const string& GetResultingPostCommitName( + const std::string& GetResultingPostCommitName( const sync_pb::SyncEntity& committed_entry, const CommitResponse_EntryResponse& entry_response); diff --git a/chrome/browser/sync/engine/syncer_proto_util_unittest.cc b/chrome/browser/sync/engine/syncer_proto_util_unittest.cc index 57cae0a..3e8b9c62 100644 --- a/chrome/browser/sync/engine/syncer_proto_util_unittest.cc +++ b/chrome/browser/sync/engine/syncer_proto_util_unittest.cc @@ -4,6 +4,8 @@ #include "chrome/browser/sync/engine/syncer_proto_util.h" +#include <string> + #include "base/basictypes.h" #include "chrome/browser/sync/engine/syncproto.h" #include "chrome/browser/sync/syncable/blob.h" @@ -33,11 +35,11 @@ TEST(SyncerProtoUtil, TestBlobToProtocolBufferBytesUtilityFunctions) { for (size_t i = 0; i < arraysize(test_data3); ++i) test_blob3.push_back(test_data3[i]); - string test_message1(reinterpret_cast<char*>(test_data1), + std::string test_message1(reinterpret_cast<char*>(test_data1), arraysize(test_data1)); - string test_message2(reinterpret_cast<char*>(test_data2), + std::string test_message2(reinterpret_cast<char*>(test_data2), arraysize(test_data2)); - string test_message3(reinterpret_cast<char*>(test_data3), + std::string test_message3(reinterpret_cast<char*>(test_data3), arraysize(test_data3)); EXPECT_TRUE(SyncerProtoUtil::ProtoBytesEqualsBlob(test_message1, diff --git a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc index 6f64059..808a744 100644 --- a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc @@ -112,7 +112,7 @@ class WebDatabaseMock : public WebDatabase { MOCK_METHOD1(AddAutoFillProfile, bool(const AutoFillProfile&)); // NOLINT MOCK_METHOD1(RemoveAutoFillProfile, - bool(const string&)); // NOLINT + bool(const std::string&)); // NOLINT }; class ProfileSyncServiceAutofillTest; @@ -809,7 +809,7 @@ TEST_F(ProfileSyncServiceAutofillTest, MergeProfileWithDifferentGuid) { "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); - string native_guid = "{EDC609ED-7EEE-4f27-B00C-423242A9C44B}"; + std::string native_guid = "{EDC609ED-7EEE-4f27-B00C-423242A9C44B}"; AutoFillProfile* native_profile = new AutoFillProfile; autofill_test::SetProfileInfoWithGuid(native_profile, native_guid.c_str(), "Billing", diff --git a/chrome/browser/sync/syncable/directory_backing_store.h b/chrome/browser/sync/syncable/directory_backing_store.h index 7851e66..7c4efdf 100644 --- a/chrome/browser/sync/syncable/directory_backing_store.h +++ b/chrome/browser/sync/syncable/directory_backing_store.h @@ -150,12 +150,12 @@ class DirectoryBackingStore { // a model. We persist a default instance of the specifics protobuf as the // ID, rather than the enum value. static ModelType ModelIdToModelTypeEnum(const void* data, int length); - static string ModelTypeEnumToModelId(ModelType model_type); + static std::string ModelTypeEnumToModelId(ModelType model_type); // Runs an integrity check on the current database. If the // integrity check fails, false is returned and error is populated // with an error message. - bool CheckIntegrity(sqlite3* handle, string* error) const; + bool CheckIntegrity(sqlite3* handle, std::string* error) const; // Migration utilities. bool AddColumn(const ColumnSpec* column); diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc index 83053fa..ac66083 100644 --- a/chrome/browser/sync/syncable/syncable.cc +++ b/chrome/browser/sync/syncable/syncable.cc @@ -51,7 +51,6 @@ #include "chrome/browser/sync/syncable/syncable_changes_version.h" #include "chrome/browser/sync/syncable/syncable_columns.h" #include "chrome/browser/sync/util/crypto_helpers.h" -#include "chrome/browser/sync/util/fast_dump.h" #include "chrome/common/deprecated/event_sys-inl.h" #include "net/base/escape.h" @@ -68,7 +67,6 @@ static const InvariantCheckLevel kInvariantCheckLevel = VERIFY_IN_MEMORY; static const int kInvariantCheckMaxMs = 50; } // namespace -using browser_sync::FastDump; using browser_sync::SyncerUtil; using std::string; @@ -1674,63 +1672,38 @@ void MarkForSyncing(syncable::MutableEntry* e) { e->Put(SYNCING, false); } -} // namespace syncable - -namespace { - class DumpSeparator { - } separator; - class DumpColon { - } colon; - -inline FastDump& operator<<(FastDump& dump, const DumpSeparator&) { - dump.out_->sputn(", ", 2); - return dump; -} - -inline FastDump& operator<<(FastDump& dump, const DumpColon&) { - dump.out_->sputn(": ", 2); - return dump; -} -} // namespace - -namespace syncable { - -std::ostream& operator<<(std::ostream& stream, const Entry& entry) { - // Using ostreams directly here is dreadfully slow, because a mutex is - // acquired for every <<. Users noticed it spiking CPU. - +std::ostream& operator<<(std::ostream& os, const Entry& entry) { int i; - FastDump s(&stream); EntryKernel* const kernel = entry.kernel_; for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) { - s << g_metas_columns[i].name << colon - << kernel->ref(static_cast<Int64Field>(i)) << separator; + os << g_metas_columns[i].name << ": " + << kernel->ref(static_cast<Int64Field>(i)) << ", "; } for ( ; i < ID_FIELDS_END; ++i) { - s << g_metas_columns[i].name << colon - << kernel->ref(static_cast<IdField>(i)) << separator; + os << g_metas_columns[i].name << ": " + << kernel->ref(static_cast<IdField>(i)) << ", "; } - s << "Flags: "; + os << "Flags: "; for ( ; i < BIT_FIELDS_END; ++i) { if (kernel->ref(static_cast<BitField>(i))) - s << g_metas_columns[i].name << separator; + os << g_metas_columns[i].name << ", "; } for ( ; i < STRING_FIELDS_END; ++i) { const string& field = kernel->ref(static_cast<StringField>(i)); - s << g_metas_columns[i].name << colon << field << separator; + os << g_metas_columns[i].name << ": " << field << ", "; } for ( ; i < PROTO_FIELDS_END; ++i) { - s << g_metas_columns[i].name << colon - << EscapePath( - kernel->ref(static_cast<ProtoField>(i)).SerializeAsString()) - << separator; + os << g_metas_columns[i].name << ": " + << EscapePath( + kernel->ref(static_cast<ProtoField>(i)).SerializeAsString()) + << ", "; } - s << "TempFlags: "; + os << "TempFlags: "; for ( ; i < BIT_TEMPS_END; ++i) { if (kernel->ref(static_cast<BitTemp>(i))) - s << "#" << i - BIT_TEMPS_BEGIN << separator; + os << "#" << i - BIT_TEMPS_BEGIN << ", "; } - return stream; + return os; } std::ostream& operator<<(std::ostream& s, const Blob& blob) { @@ -1740,12 +1713,4 @@ std::ostream& operator<<(std::ostream& s, const Blob& blob) { return s << std::dec; } -FastDump& operator<<(FastDump& dump, const Blob& blob) { - if (blob.empty()) - return dump; - string buffer(base::HexEncode(&blob[0], blob.size())); - dump.out_->sputn(buffer.c_str(), buffer.size()); - return dump; -} - } // namespace syncable diff --git a/chrome/browser/sync/syncable/syncable.h b/chrome/browser/sync/syncable/syncable.h index 4e1b0b9..ba46115 100644 --- a/chrome/browser/sync/syncable/syncable.h +++ b/chrome/browser/sync/syncable/syncable.h @@ -1136,7 +1136,4 @@ void ZeroFields(EntryKernel* entry, int first_field); std::ostream& operator <<(std::ostream&, const syncable::Blob&); -browser_sync::FastDump& operator << - (browser_sync::FastDump&, const syncable::Blob&); - #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ diff --git a/chrome/browser/sync/syncable/syncable_id.cc b/chrome/browser/sync/syncable/syncable_id.cc index 60cf8c9..766289b 100644 --- a/chrome/browser/sync/syncable/syncable_id.cc +++ b/chrome/browser/sync/syncable/syncable_id.cc @@ -19,12 +19,6 @@ ostream& operator<<(ostream& out, const Id& id) { return out; } -using browser_sync::FastDump; -FastDump& operator<<(FastDump& dump, const Id& id) { - dump.out_->sputn(id.s_.data(), id.s_.size()); - return dump; -} - string Id::GetServerId() const { // Currently root is the string "0". We need to decide on a true value. // "" would be convenient here, as the IsRoot call would not be needed. diff --git a/chrome/browser/sync/syncable/syncable_id.h b/chrome/browser/sync/syncable/syncable_id.h index 148fe21..f606867 100644 --- a/chrome/browser/sync/syncable/syncable_id.h +++ b/chrome/browser/sync/syncable/syncable_id.h @@ -12,7 +12,6 @@ #include <string> #include "base/hash_tables.h" -#include "chrome/browser/sync/util/fast_dump.h" extern "C" { struct sqlite3; @@ -31,7 +30,6 @@ class SQLStatement; namespace syncable { std::ostream& operator<<(std::ostream& out, const Id& id); -browser_sync::FastDump& operator<<(browser_sync::FastDump& out, const Id& id); // For historical reasons, 3 concepts got everloaded into the Id: // 1. A unique, opaque identifier for the object. @@ -49,8 +47,6 @@ class Id { friend struct syncable::IdRowTraits; friend int BindFields(const EntryKernel& entry, SQLStatement* statement); friend std::ostream& operator<<(std::ostream& out, const Id& id); - friend browser_sync::FastDump& operator<< - (browser_sync::FastDump& out, const Id& id); friend class MockConnectionManager; friend class SyncableIdTest; public: diff --git a/chrome/browser/sync/util/fast_dump.h b/chrome/browser/sync/util/fast_dump.h deleted file mode 100644 index 44e48c1..0000000 --- a/chrome/browser/sync/util/fast_dump.h +++ /dev/null @@ -1,58 +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. - -#ifndef CHROME_BROWSER_SYNC_UTIL_FAST_DUMP_H_ -#define CHROME_BROWSER_SYNC_UTIL_FAST_DUMP_H_ -#pragma once - -#include <ostream> -#include <streambuf> -#include <string> - -#include "base/string_number_conversions.h" - -using std::ostream; -using std::streambuf; -using std::string; - -// This seems totally gratuitous, and it would be if std::ostream was fast, but -// std::ostream is slow. It's slow because it creates a ostream::sentry (mutex) -// for every little << operator. When you want to dump a whole lot of stuff -// under a single mutex lock, use this FastDump class. -namespace browser_sync { -class FastDump { - public: - explicit FastDump(ostream* outs) : sentry_(*outs), out_(outs->rdbuf()) { - } - ostream::sentry sentry_; - streambuf* const out_; -}; - -inline FastDump& operator << (FastDump& dump, int64 n) { - string numbuf(base::Int64ToString(n)); - const char* number = numbuf.c_str(); - dump.out_->sputn(number, numbuf.length()); - return dump; -} - -inline FastDump& operator << (FastDump& dump, int32 n) { - string numbuf(base::IntToString(n)); - const char* number = numbuf.c_str(); - dump.out_->sputn(number, numbuf.length()); - return dump; -} - -inline FastDump& operator << (FastDump& dump, const char* s) { - dump.out_->sputn(s, strlen(s)); - return dump; -} - -inline FastDump& operator << (FastDump& dump, const string& s) { - dump.out_->sputn(s.data(), s.size()); - return dump; -} - -} // namespace browser_sync - -#endif // CHROME_BROWSER_SYNC_UTIL_FAST_DUMP_H_ diff --git a/chrome/browser/sync/util/user_settings_unittest.cc b/chrome/browser/sync/util/user_settings_unittest.cc index 036dcd3..0545b94 100644 --- a/chrome/browser/sync/util/user_settings_unittest.cc +++ b/chrome/browser/sync/util/user_settings_unittest.cc @@ -225,13 +225,13 @@ TEST_F(UserSettingsTest, MigrateFromV11ToV12) { } TEST_F(UserSettingsTest, APEncode) { - string test; + std::string test; char i; for (i = numeric_limits<char>::min(); i < numeric_limits<char>::max(); ++i) test.push_back(i); test.push_back(i); - const string encoded = APEncode(test); - const string decoded = APDecode(encoded); + const std::string encoded = APEncode(test); + const std::string decoded = APDecode(encoded); ASSERT_EQ(test, decoded); } diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index bafb26d..b27b214 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -986,7 +986,6 @@ 'browser/sync/util/dbgq.h', 'browser/sync/util/extensions_activity_monitor.cc', 'browser/sync/util/extensions_activity_monitor.h', - 'browser/sync/util/fast_dump.h', 'browser/sync/util/nigori.cc', 'browser/sync/util/nigori.h', 'browser/sync/util/user_settings.cc', diff --git a/chrome/test/sync/engine/mock_connection_manager.h b/chrome/test/sync/engine/mock_connection_manager.h index a764eaaae..072f795 100644 --- a/chrome/test/sync/engine/mock_connection_manager.h +++ b/chrome/test/sync/engine/mock_connection_manager.h @@ -43,9 +43,10 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager { virtual ~MockConnectionManager(); // Overridden ServerConnectionManager functions. - virtual bool PostBufferToPath(const PostBufferParams*, - const string& path, - const string& auth_token, + virtual bool PostBufferToPath( + const PostBufferParams*, + const std::string& path, + const std::string& auth_token, browser_sync::ScopedServerStatusWatcher* watcher); virtual bool IsServerReachable(); @@ -57,7 +58,7 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager { // Set this if you want commit to perform commit time rename. Will request // that the client renames all commited entries, prepending this string. - void SetCommitTimeRename(string prepend); + void SetCommitTimeRename(std::string prepend); // Generic versions of AddUpdate functions. Tests using these function should // compile for both the int64 and string id based versions of the server. @@ -66,34 +67,34 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager { // sync, using SetLastXXX() methods and/or GetMutableLastUpdate(). sync_pb::SyncEntity* AddUpdateDirectory(syncable::Id id, syncable::Id parent_id, - string name, + std::string name, int64 version, int64 sync_ts); sync_pb::SyncEntity* AddUpdateBookmark(syncable::Id id, syncable::Id parent_id, - string name, + std::string name, int64 version, int64 sync_ts); // Versions of the AddUpdate functions that accept integer IDs. sync_pb::SyncEntity* AddUpdateDirectory(int id, int parent_id, - string name, + std::string name, int64 version, int64 sync_ts); sync_pb::SyncEntity* AddUpdateBookmark(int id, int parent_id, - string name, + std::string name, int64 version, int64 sync_ts); // New protocol versions of the AddUpdate functions. - sync_pb::SyncEntity* AddUpdateDirectory(string id, - string parent_id, - string name, + sync_pb::SyncEntity* AddUpdateDirectory(std::string id, + std::string parent_id, + std::string name, int64 version, int64 sync_ts); - sync_pb::SyncEntity* AddUpdateBookmark(string id, - string parent_id, - string name, + sync_pb::SyncEntity* AddUpdateBookmark(std::string id, + std::string parent_id, + std::string name, int64 version, int64 sync_ts); @@ -108,10 +109,10 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager { void AddUpdateTombstone(const syncable::Id& id); void SetLastUpdateDeleted(); - void SetLastUpdateServerTag(const string& tag); - void SetLastUpdateClientTag(const string& tag); - void SetLastUpdateOriginatorFields(const string& client_id, - const string& entry_id); + void SetLastUpdateServerTag(const std::string& tag); + void SetLastUpdateClientTag(const std::string& tag); + void SetLastUpdateOriginatorFields(const std::string& client_id, + const std::string& entry_id); void SetLastUpdatePosition(int64 position_in_parent); void SetNewTimestamp(int ts); void SetChangesRemaining(int64 count); @@ -188,7 +189,7 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager { use_legacy_bookmarks_protocol_ = value; } - void set_store_birthday(string new_birthday) { + void set_store_birthday(std::string new_birthday) { // Multiple threads can set store_birthday_ in our tests, need to lock it to // ensure atomic read/writes and avoid race conditions. base::AutoLock lock(store_birthday_lock_); @@ -228,10 +229,11 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager { private: sync_pb::SyncEntity* AddUpdateFull(syncable::Id id, syncable::Id parentid, - string name, int64 version, + std::string name, int64 version, int64 sync_ts, bool is_dir); - sync_pb::SyncEntity* AddUpdateFull(string id, string parentid, string name, + sync_pb::SyncEntity* AddUpdateFull(std::string id, + std::string parentid, std::string name, int64 version, int64 sync_ts, bool is_dir); // Functions to handle the various types of server request. @@ -284,11 +286,11 @@ class MockConnectionManager : public browser_sync::ServerConnectionManager { int next_new_id_; // The store birthday we send to the client. - string store_birthday_; + std::string store_birthday_; base::Lock store_birthday_lock_; bool store_birthday_sent_; bool client_stuck_; - string commit_time_rename_prepended_string_; + std::string commit_time_rename_prepended_string_; // Fail on the next call to PostBufferToPath(). bool fail_next_postbuffer_; |