diff options
author | hans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-20 07:59:14 +0000 |
---|---|---|
committer | hans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-20 07:59:14 +0000 |
commit | 16f5650cb24ad8f1d6a0ca56ecfad42b85633dfb (patch) | |
tree | f71ab306079998849392214e91807b4e20460754 | |
parent | 729ac5974a7bf4d6e5cfe2245c8497ffc9a92405 (diff) | |
download | chromium_src-16f5650cb24ad8f1d6a0ca56ecfad42b85633dfb.zip chromium_src-16f5650cb24ad8f1d6a0ca56ecfad42b85633dfb.tar.gz chromium_src-16f5650cb24ad8f1d6a0ca56ecfad42b85633dfb.tar.bz2 |
Fix sync_unit_tests two-phase lookup problems.
Clang fails to compile some files used by sync_unit_tests because it is more
strict on code following the Standard.
Type-dependent names are bound during template instantiation by looking at
declarations that are visible at the point of definition of the template
and declarations from namespaces associated with the types of the function
arguments both from the instantiation context and from the definition context.
For this reason, when declaring a function like
std::ostream& operator<<(std::ostream& s, const syncable::Entry& e);
it is important that the function is declared in the namespace of one of its
arguemnts, i.e. syncable in this case.
See http://clang.llvm.org/compatibility.html#dep_lookup for more info.
BUG=none
TEST=sync_unit_tests
Review URL: http://codereview.chromium.org/3401002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59913 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/sync/engine/net/server_connection_manager.cc | 7 | ||||
-rw-r--r-- | chrome/browser/sync/engine/net/server_connection_manager.h | 5 | ||||
-rw-r--r-- | chrome/browser/sync/syncable/directory_backing_store.cc | 1 | ||||
-rw-r--r-- | chrome/browser/sync/syncable/syncable.cc | 30 | ||||
-rw-r--r-- | chrome/browser/sync/syncable/syncable.h | 7 | ||||
-rw-r--r-- | chrome/browser/sync/syncable/syncable_id.cc | 7 | ||||
-rw-r--r-- | chrome/browser/sync/syncable/syncable_id.h | 14 | ||||
-rw-r--r-- | chrome/browser/sync/util/fast_dump.h | 15 |
8 files changed, 31 insertions, 55 deletions
diff --git a/chrome/browser/sync/engine/net/server_connection_manager.cc b/chrome/browser/sync/engine/net/server_connection_manager.cc index 6d35811..c1801c8 100644 --- a/chrome/browser/sync/engine/net/server_connection_manager.cc +++ b/chrome/browser/sync/engine/net/server_connection_manager.cc @@ -345,12 +345,11 @@ bool FillMessageWithShareDetails(sync_pb::ClientToServerMessage* csm, return true; } -} // namespace browser_sync - -std::ostream& operator << (std::ostream& s, - const struct browser_sync::HttpResponse& hr) { +std::ostream& operator << (std::ostream& s, const struct HttpResponse& hr) { s << " Response Code (bogus on error): " << hr.response_code; s << " Content-Length (bogus on error): " << hr.content_length; s << " Server Status: " << hr.server_status; return s; } + +} // namespace browser_sync diff --git a/chrome/browser/sync/engine/net/server_connection_manager.h b/chrome/browser/sync/engine/net/server_connection_manager.h index 35318ff..0363993 100644 --- a/chrome/browser/sync/engine/net/server_connection_manager.h +++ b/chrome/browser/sync/engine/net/server_connection_manager.h @@ -376,9 +376,8 @@ bool FillMessageWithShareDetails(sync_pb::ClientToServerMessage* csm, syncable::DirectoryManager* manager, const std::string& share); -} // namespace browser_sync +std::ostream& operator<<(std::ostream& s, const struct HttpResponse& hr); -std::ostream& operator<<(std::ostream& s, - const struct browser_sync::HttpResponse& hr); +} // namespace browser_sync #endif // CHROME_BROWSER_SYNC_ENGINE_NET_SERVER_CONNECTION_MANAGER_H_ diff --git a/chrome/browser/sync/syncable/directory_backing_store.cc b/chrome/browser/sync/syncable/directory_backing_store.cc index 048f016..62b8faa 100644 --- a/chrome/browser/sync/syncable/directory_backing_store.cc +++ b/chrome/browser/sync/syncable/directory_backing_store.cc @@ -286,6 +286,7 @@ bool DirectoryBackingStore::BeginLoad() { if (ret) return true; // Something's gone wrong. Nuke the database and try again. + using ::operator<<; // For string16. LOG(ERROR) << "Sync database " << backing_filepath_.value() << " corrupt. Deleting and recreating."; file_util::Delete(backing_filepath_, false); diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc index 63ddb98..a711f55 100644 --- a/chrome/browser/sync/syncable/syncable.cc +++ b/chrome/browser/sync/syncable/syncable.cc @@ -1506,7 +1506,6 @@ namespace { } separator; class DumpColon { } colon; -} // namespace inline FastDump& operator<<(FastDump& dump, const DumpSeparator&) { dump.out_->sputn(", ", 2); @@ -1517,26 +1516,13 @@ inline FastDump& operator<<(FastDump& dump, const DumpColon&) { dump.out_->sputn(": ", 2); return dump; } +} // namespace + +namespace syncable { -std::ostream& operator<<(std::ostream& stream, const syncable::Entry& entry) { +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. - using syncable::BEGIN_FIELDS; - using syncable::BIT_FIELDS_END; - using syncable::BIT_TEMPS_BEGIN; - using syncable::BIT_TEMPS_END; - using syncable::BitField; - using syncable::BitTemp; - using syncable::EntryKernel; - using syncable::ID_FIELDS_END; - using syncable::INT64_FIELDS_END; - using syncable::IdField; - using syncable::Int64Field; - using syncable::PROTO_FIELDS_END; - using syncable::ProtoField; - using syncable::STRING_FIELDS_END; - using syncable::StringField; - using syncable::g_metas_columns; int i; FastDump s(&stream); @@ -1572,17 +1558,19 @@ std::ostream& operator<<(std::ostream& stream, const syncable::Entry& entry) { return stream; } -std::ostream& operator<<(std::ostream& s, const syncable::Blob& blob) { - for (syncable::Blob::const_iterator i = blob.begin(); i != blob.end(); ++i) +std::ostream& operator<<(std::ostream& s, const Blob& blob) { + for (Blob::const_iterator i = blob.begin(); i != blob.end(); ++i) s << std::hex << std::setw(2) << std::setfill('0') << static_cast<unsigned int>(*i); return s << std::dec; } -FastDump& operator<<(FastDump& dump, const syncable::Blob& blob) { +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 d54368e..cbdd03a 100644 --- a/chrome/browser/sync/syncable/syncable.h +++ b/chrome/browser/sync/syncable/syncable.h @@ -41,11 +41,8 @@ class ReadNode; namespace syncable { class Entry; -} - -std::ostream& operator<<(std::ostream& s, const syncable::Entry& e); -namespace syncable { +std::ostream& operator<<(std::ostream& s, const Entry& e); class DirectoryBackingStore; @@ -342,7 +339,7 @@ struct EntryKernel { // A read-only meta entry. class Entry { friend class Directory; - friend std::ostream& ::operator << (std::ostream& s, const Entry& e); + friend std::ostream& operator << (std::ostream& s, const Entry& e); public: // After constructing, you must check good() to test whether the Get diff --git a/chrome/browser/sync/syncable/syncable_id.cc b/chrome/browser/sync/syncable/syncable_id.cc index 1aa2193..60cf8c9 100644 --- a/chrome/browser/sync/syncable/syncable_id.cc +++ b/chrome/browser/sync/syncable/syncable_id.cc @@ -13,21 +13,18 @@ using std::string; namespace syncable { const Id kNullId; // Currently == root. -} // namespace syncable -ostream& operator << (ostream& out, const syncable::Id& id) { +ostream& operator<<(ostream& out, const Id& id) { out << id.s_; return out; } using browser_sync::FastDump; -FastDump& operator << (FastDump& dump, const syncable::Id& id) { +FastDump& operator<<(FastDump& dump, const Id& id) { dump.out_->sputn(id.s_.data(), id.s_.size()); return dump; } -namespace syncable { - 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 8fb6358..148fe21 100644 --- a/chrome/browser/sync/syncable/syncable_id.h +++ b/chrome/browser/sync/syncable/syncable_id.h @@ -28,12 +28,11 @@ class Id; class MockConnectionManager; class SQLStatement; -std::ostream& operator << (std::ostream& out, const syncable::Id& id); -browser_sync::FastDump& operator << - (browser_sync::FastDump& out, const syncable::Id& id); - 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. // 2. Flag specifing whether server know about this object. @@ -49,10 +48,9 @@ class Id { syncable::EntryKernel** kernel); friend struct syncable::IdRowTraits; friend int BindFields(const EntryKernel& entry, SQLStatement* statement); - friend std::ostream& ::operator << (std::ostream& out, - const syncable::Id& id); - friend browser_sync::FastDump& ::operator << - (browser_sync::FastDump& out, const syncable::Id& id); + 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 index 28d1484..44e48c1 100644 --- a/chrome/browser/sync/util/fast_dump.h +++ b/chrome/browser/sync/util/fast_dump.h @@ -28,34 +28,31 @@ class FastDump { ostream::sentry sentry_; streambuf* const out_; }; -} // namespace browser_sync -inline browser_sync::FastDump& operator << - (browser_sync::FastDump& dump, int64 n) { +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 browser_sync::FastDump& operator << - (browser_sync::FastDump& dump, int32 n) { +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 browser_sync::FastDump& operator << - (browser_sync::FastDump& dump, const char* s) { +inline FastDump& operator << (FastDump& dump, const char* s) { dump.out_->sputn(s, strlen(s)); return dump; } -inline browser_sync::FastDump& operator << - (browser_sync::FastDump& dump, const string& s) { +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_ |