diff options
author | adamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-25 16:29:07 +0000 |
---|---|---|
committer | adamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-25 16:29:07 +0000 |
commit | 8effd3f691277e168a10890127085a3bc999810f (patch) | |
tree | f249b4aa38200eeba84d5324debf1776f80253b5 /net | |
parent | 9c7ec6dd24d8774cc88232354cd15f31ed28d61d (diff) | |
download | chromium_src-8effd3f691277e168a10890127085a3bc999810f.zip chromium_src-8effd3f691277e168a10890127085a3bc999810f.tar.gz chromium_src-8effd3f691277e168a10890127085a3bc999810f.tar.bz2 |
Remove most unnecessary uses of "net::" in net/base/.
Also removes several empty and unused gtest test fixtures.
R=willchan@chromium.org
Review URL: http://codereview.chromium.org/6676134
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79411 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
45 files changed, 790 insertions, 790 deletions
diff --git a/net/base/address_list_unittest.cc b/net/base/address_list_unittest.cc index 2a13f45..e387f25 100644 --- a/net/base/address_list_unittest.cc +++ b/net/base/address_list_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -14,16 +14,17 @@ #endif #include "testing/gtest/include/gtest/gtest.h" +namespace net { namespace { // Use getaddrinfo() to allocate an addrinfo structure. int CreateAddressList(const std::string& hostname, int port, - net::AddressList* addrlist) { + AddressList* addrlist) { #if defined(OS_WIN) - net::EnsureWinsockInit(); + EnsureWinsockInit(); #endif int rv = SystemHostResolverProc(hostname, - net::ADDRESS_FAMILY_UNSPECIFIED, + ADDRESS_FAMILY_UNSPECIFIED, 0, addrlist, NULL); if (rv == 0) @@ -31,15 +32,15 @@ int CreateAddressList(const std::string& hostname, int port, return rv; } -void CreateLongAddressList(net::AddressList* addrlist, int port) { +void CreateLongAddressList(AddressList* addrlist, int port) { EXPECT_EQ(0, CreateAddressList("192.168.1.1", port, addrlist)); - net::AddressList second_list; + AddressList second_list; EXPECT_EQ(0, CreateAddressList("192.168.1.2", port, &second_list)); addrlist->Append(second_list.head()); } TEST(AddressListTest, GetPort) { - net::AddressList addrlist; + AddressList addrlist; EXPECT_EQ(0, CreateAddressList("192.168.1.1", 81, &addrlist)); EXPECT_EQ(81, addrlist.GetPort()); @@ -48,13 +49,13 @@ TEST(AddressListTest, GetPort) { } TEST(AddressListTest, Assignment) { - net::AddressList addrlist1; + AddressList addrlist1; EXPECT_EQ(0, CreateAddressList("192.168.1.1", 85, &addrlist1)); EXPECT_EQ(85, addrlist1.GetPort()); // Should reference the same data as addrlist1 -- so when we change addrlist1 // both are changed. - net::AddressList addrlist2 = addrlist1; + AddressList addrlist2 = addrlist1; EXPECT_EQ(85, addrlist2.GetPort()); addrlist1.SetPort(80); @@ -63,11 +64,11 @@ TEST(AddressListTest, Assignment) { } TEST(AddressListTest, CopyRecursive) { - net::AddressList addrlist1; + AddressList addrlist1; CreateLongAddressList(&addrlist1, 85); EXPECT_EQ(85, addrlist1.GetPort()); - net::AddressList addrlist2; + AddressList addrlist2; addrlist2.Copy(addrlist1.head(), true); ASSERT_TRUE(addrlist2.head()->ai_next != NULL); @@ -85,11 +86,11 @@ TEST(AddressListTest, CopyRecursive) { } TEST(AddressListTest, CopyNonRecursive) { - net::AddressList addrlist1; + AddressList addrlist1; CreateLongAddressList(&addrlist1, 85); EXPECT_EQ(85, addrlist1.GetPort()); - net::AddressList addrlist2; + AddressList addrlist2; addrlist2.Copy(addrlist1.head(), false); ASSERT_TRUE(addrlist2.head()->ai_next == NULL); @@ -107,10 +108,10 @@ TEST(AddressListTest, CopyNonRecursive) { } TEST(AddressListTest, Append) { - net::AddressList addrlist1; + AddressList addrlist1; EXPECT_EQ(0, CreateAddressList("192.168.1.1", 11, &addrlist1)); EXPECT_EQ(11, addrlist1.GetPort()); - net::AddressList addrlist2; + AddressList addrlist2; EXPECT_EQ(0, CreateAddressList("192.168.1.2", 12, &addrlist2)); EXPECT_EQ(12, addrlist2.GetPort()); @@ -118,7 +119,7 @@ TEST(AddressListTest, Append) { addrlist1.Append(addrlist2.head()); ASSERT_TRUE(addrlist1.head()->ai_next != NULL); - net::AddressList addrlist3; + AddressList addrlist3; addrlist3.Copy(addrlist1.head()->ai_next, false); EXPECT_EQ(12, addrlist3.GetPort()); } @@ -141,7 +142,7 @@ TEST(AddressListTest, Canonical) { // Copy the addrinfo struct into an AddressList object and // make sure it seems correct. - net::AddressList addrlist1; + AddressList addrlist1; addrlist1.Copy(&ai, true); const struct addrinfo* addrinfo1 = addrlist1.head(); EXPECT_TRUE(addrinfo1 != NULL); @@ -151,7 +152,7 @@ TEST(AddressListTest, Canonical) { EXPECT_EQ("canonical.bar.com", canon_name1); // Copy the AddressList to another one. - net::AddressList addrlist2; + AddressList addrlist2; addrlist2.Copy(addrinfo1, true); const struct addrinfo* addrinfo2 = addrlist2.head(); EXPECT_TRUE(addrinfo2 != NULL); @@ -166,7 +167,7 @@ TEST(AddressListTest, Canonical) { // Make sure that GetCanonicalName correctly returns false // when ai_canonname is NULL. ai.ai_canonname = NULL; - net::AddressList addrlist_no_canon; + AddressList addrlist_no_canon; addrlist_no_canon.Copy(&ai, true); std::string canon_name3 = "blah"; EXPECT_FALSE(addrlist_no_canon.GetCanonicalName(&canon_name3)); @@ -185,7 +186,7 @@ TEST(AddressListTest, IPLiteralConstructor) { { "2001:db8:0::42", "2001:db8::42", true }, }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); i++) { - net::AddressList expected_list; + AddressList expected_list; int rv = CreateAddressList(tests[i].canonical_ip_address, 80, &expected_list); if (tests[i].is_ipv6 && rv != 0) { @@ -196,9 +197,9 @@ TEST(AddressListTest, IPLiteralConstructor) { ASSERT_EQ(0, rv); const struct addrinfo* good_ai = expected_list.head(); - net::IPAddressNumber ip_number; - net::ParseIPLiteralToNumber(tests[i].ip_address, &ip_number); - net::AddressList test_list(ip_number, 80, true); + IPAddressNumber ip_number; + ParseIPLiteralToNumber(tests[i].ip_address, &ip_number); + AddressList test_list(ip_number, 80, true); const struct addrinfo* test_ai = test_list.head(); EXPECT_EQ(good_ai->ai_family, test_ai->ai_family); @@ -226,7 +227,7 @@ TEST(AddressListTest, AddressFromAddrInfo) { { "2001:db8:0::42", "2001:db8::42", true }, }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); i++) { - net::AddressList expected_list; + AddressList expected_list; int rv = CreateAddressList(tests[i].canonical_ip_address, 80, &expected_list); if (tests[i].is_ipv6 && rv != 0) { @@ -237,11 +238,11 @@ TEST(AddressListTest, AddressFromAddrInfo) { ASSERT_EQ(0, rv); const struct addrinfo* good_ai = expected_list.head(); - scoped_ptr<net::AddressList> test_list( - net::AddressList::CreateAddressListFromSockaddr(good_ai->ai_addr, - good_ai->ai_addrlen, - SOCK_STREAM, - IPPROTO_TCP)); + scoped_ptr<AddressList> test_list( + AddressList::CreateAddressListFromSockaddr(good_ai->ai_addr, + good_ai->ai_addrlen, + SOCK_STREAM, + IPPROTO_TCP)); const struct addrinfo* test_ai = test_list->head(); EXPECT_EQ(good_ai->ai_family, test_ai->ai_family); @@ -255,3 +256,4 @@ TEST(AddressListTest, AddressFromAddrInfo) { } } // namespace +} // namespace net diff --git a/net/base/cert_database.h b/net/base/cert_database.h index 5760dff..dbfbcc3 100644 --- a/net/base/cert_database.h +++ b/net/base/cert_database.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -104,7 +104,7 @@ class CertDatabase { // Import certificates and private keys from PKCS #12 blob into the module. // Returns OK or a network error code such as ERR_PKCS12_IMPORT_BAD_PASSWORD // or ERR_PKCS12_IMPORT_ERROR. - int ImportFromPKCS12(net::CryptoModule* module, + int ImportFromPKCS12(CryptoModule* module, const std::string& data, const string16& password); diff --git a/net/base/cert_database_nss.cc b/net/base/cert_database_nss.cc index 60cc4bc..f1467c3 100644 --- a/net/base/cert_database_nss.cc +++ b/net/base/cert_database_nss.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -144,7 +144,7 @@ void CertDatabase::ListModules(CryptoModuleList* modules, bool need_rw) const { } int CertDatabase::ImportFromPKCS12( - net::CryptoModule* module, + CryptoModule* module, const std::string& data, const string16& password) { return psm::nsPKCS12Blob_Import(module->os_module_handle(), diff --git a/net/base/cert_database_openssl.cc b/net/base/cert_database_openssl.cc index 1e7a5d7..4de96fa 100644 --- a/net/base/cert_database_openssl.cc +++ b/net/base/cert_database_openssl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -53,7 +53,7 @@ void CertDatabase::ListModules(CryptoModuleList* modules, bool need_rw) const { modules->clear(); } -int CertDatabase::ImportFromPKCS12(net::CryptoModule* module, +int CertDatabase::ImportFromPKCS12(CryptoModule* module, const std::string& data, const string16& password) { // TODO(bulach): implement me. diff --git a/net/base/cert_verifier.h b/net/base/cert_verifier.h index c0fc9fc..4483214 100644 --- a/net/base/cert_verifier.h +++ b/net/base/cert_verifier.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -205,7 +205,7 @@ class SingleRequestCertVerifier { CompletionCallback* cur_request_callback_; // Completion callback for when request to |cert_verifier_| completes. - net::CompletionCallbackImpl<SingleRequestCertVerifier> callback_; + CompletionCallbackImpl<SingleRequestCertVerifier> callback_; DISALLOW_COPY_AND_ASSIGN(SingleRequestCertVerifier); }; diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc index 2a1c30c..2c9d110 100644 --- a/net/base/cookie_monster.cc +++ b/net/base/cookie_monster.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -201,7 +201,7 @@ bool GetCookieDomainWithString(const GURL& url, // also treats domain=.....my.domain.com like domain=.my.domain.com, but // neither IE nor Safari do this, and we don't either. url_canon::CanonHostInfo ignored; - std::string cookie_domain(net::CanonicalizeHost(domain_string, &ignored)); + std::string cookie_domain(CanonicalizeHost(domain_string, &ignored)); if (cookie_domain.empty()) return false; if (cookie_domain[0] != '.') diff --git a/net/base/cookie_monster_store_test.cc b/net/base/cookie_monster_store_test.cc index 30125eb..b975c28 100644 --- a/net/base/cookie_monster_store_test.cc +++ b/net/base/cookie_monster_store_test.cc @@ -20,13 +20,13 @@ MockPersistentCookieStore::~MockPersistentCookieStore() {} void MockPersistentCookieStore::SetLoadExpectation( bool return_value, - const std::vector<net::CookieMonster::CanonicalCookie*>& result) { + const std::vector<CookieMonster::CanonicalCookie*>& result) { load_return_value_ = return_value; load_result_ = result; } bool MockPersistentCookieStore::Load( - std::vector<net::CookieMonster::CanonicalCookie*>* out_cookies) { + std::vector<CookieMonster::CanonicalCookie*>* out_cookies) { bool ok = load_return_value_; if (ok) *out_cookies = load_result_; @@ -34,19 +34,19 @@ bool MockPersistentCookieStore::Load( } void MockPersistentCookieStore::AddCookie( - const net::CookieMonster::CanonicalCookie& cookie) { + const CookieMonster::CanonicalCookie& cookie) { commands_.push_back( CookieStoreCommand(CookieStoreCommand::ADD, cookie)); } void MockPersistentCookieStore::UpdateCookieAccessTime( - const net::CookieMonster::CanonicalCookie& cookie) { + const CookieMonster::CanonicalCookie& cookie) { commands_.push_back(CookieStoreCommand( CookieStoreCommand::UPDATE_ACCESS_TIME, cookie)); } void MockPersistentCookieStore::DeleteCookie( - const net::CookieMonster::CanonicalCookie& cookie) { + const CookieMonster::CanonicalCookie& cookie) { commands_.push_back( CookieStoreCommand(CookieStoreCommand::REMOVE, cookie)); } @@ -64,9 +64,9 @@ MockPersistentCookieStore::SetClearLocalStateOnExit(bool clear_local_state) { MockCookieMonsterDelegate::MockCookieMonsterDelegate() {} void MockCookieMonsterDelegate::OnCookieChanged( - const net::CookieMonster::CanonicalCookie& cookie, + const CookieMonster::CanonicalCookie& cookie, bool removed, - net::CookieMonster::Delegate::ChangeCause cause) { + CookieMonster::Delegate::ChangeCause cause) { CookieNotification notification(cookie, removed); changes_.push_back(notification); } @@ -77,10 +77,10 @@ void AddCookieToList( const std::string& key, const std::string& cookie_line, const base::Time& creation_time, - std::vector<net::CookieMonster::CanonicalCookie*>* out_list) { + std::vector<CookieMonster::CanonicalCookie*>* out_list) { // Parse the cookie line. - net::CookieMonster::ParsedCookie pc(cookie_line); + CookieMonster::ParsedCookie pc(cookie_line); EXPECT_TRUE(pc.IsValid()); // This helper is simplistic in interpreting a parsed cookie, in order to @@ -89,11 +89,11 @@ void AddCookieToList( EXPECT_FALSE(pc.HasMaxAge()); EXPECT_TRUE(pc.HasPath()); base::Time cookie_expires = pc.HasExpires() ? - net::CookieMonster::ParseCookieTime(pc.Expires()) : base::Time(); + CookieMonster::ParseCookieTime(pc.Expires()) : base::Time(); std::string cookie_path = pc.Path(); - scoped_ptr<net::CookieMonster::CanonicalCookie> cookie( - new net::CookieMonster::CanonicalCookie( + scoped_ptr<CookieMonster::CanonicalCookie> cookie( + new CookieMonster::CanonicalCookie( GURL(), pc.Name(), pc.Value(), key, cookie_path, pc.IsSecure(), pc.IsHttpOnly(), creation_time, creation_time, @@ -108,30 +108,30 @@ MockSimplePersistentCookieStore::MockSimplePersistentCookieStore() {} MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() {} bool MockSimplePersistentCookieStore::Load( - std::vector<net::CookieMonster::CanonicalCookie*>* out_cookies) { + std::vector<CookieMonster::CanonicalCookie*>* out_cookies) { for (CanonicalCookieMap::const_iterator it = cookies_.begin(); it != cookies_.end(); it++) out_cookies->push_back( - new net::CookieMonster::CanonicalCookie(it->second)); + new CookieMonster::CanonicalCookie(it->second)); return true; } void MockSimplePersistentCookieStore::AddCookie( - const net::CookieMonster::CanonicalCookie& cookie) { + const CookieMonster::CanonicalCookie& cookie) { int64 creation_time = cookie.CreationDate().ToInternalValue(); EXPECT_TRUE(cookies_.find(creation_time) == cookies_.end()); cookies_[creation_time] = cookie; } void MockSimplePersistentCookieStore::UpdateCookieAccessTime( - const net::CookieMonster::CanonicalCookie& cookie) { + const CookieMonster::CanonicalCookie& cookie) { int64 creation_time = cookie.CreationDate().ToInternalValue(); ASSERT_TRUE(cookies_.find(creation_time) != cookies_.end()); cookies_[creation_time].SetLastAccessDate(base::Time::Now()); } void MockSimplePersistentCookieStore::DeleteCookie( - const net::CookieMonster::CanonicalCookie& cookie) { + const CookieMonster::CanonicalCookie& cookie) { int64 creation_time = cookie.CreationDate().ToInternalValue(); CanonicalCookieMap::iterator it = cookies_.find(creation_time); ASSERT_TRUE(it != cookies_.end()); @@ -147,7 +147,7 @@ void MockSimplePersistentCookieStore::SetClearLocalStateOnExit( bool clear_local_state) { } -net::CookieMonster* CreateMonsterFromStoreForGC( +CookieMonster* CreateMonsterFromStoreForGC( int num_cookies, int num_old_cookies, int days_old) { @@ -157,7 +157,7 @@ net::CookieMonster* CreateMonsterFromStoreForGC( new MockSimplePersistentCookieStore); // Must expire to be persistent for (int i = 0; i < num_old_cookies; i++) { - net::CookieMonster::CanonicalCookie cc( + CookieMonster::CanonicalCookie cc( GURL(), "a", "1", base::StringPrintf("h%05d.izzle", i), "/path", false, false, past_creation + base::TimeDelta::FromMicroseconds(i), current - base::TimeDelta::FromDays(days_old), @@ -165,14 +165,14 @@ net::CookieMonster* CreateMonsterFromStoreForGC( store->AddCookie(cc); } for (int i = num_old_cookies; i < num_cookies; i++) { - net::CookieMonster::CanonicalCookie cc( + CookieMonster::CanonicalCookie cc( GURL(), "a", "1", base::StringPrintf("h%05d.izzle", i), "/path", false, false, past_creation + base::TimeDelta::FromMicroseconds(i), current, true, current + base::TimeDelta::FromDays(30)); store->AddCookie(cc); } - return new net::CookieMonster(store, NULL); + return new CookieMonster(store, NULL); } } // namespace net diff --git a/net/base/cookie_monster_store_test.h b/net/base/cookie_monster_store_test.h index 8f39c63..1ee757d 100644 --- a/net/base/cookie_monster_store_test.h +++ b/net/base/cookie_monster_store_test.h @@ -24,19 +24,19 @@ struct CookieStoreCommand { }; CookieStoreCommand(Type type, - const net::CookieMonster::CanonicalCookie& cookie) + const CookieMonster::CanonicalCookie& cookie) : type(type), cookie(cookie) {} Type type; - net::CookieMonster::CanonicalCookie cookie; + CookieMonster::CanonicalCookie cookie; }; // Implementation of PersistentCookieStore that captures the // received commands and saves them to a list. // The result of calls to Load() can be configured using SetLoadExpectation(). class MockPersistentCookieStore - : public net::CookieMonster::PersistentCookieStore { + : public CookieMonster::PersistentCookieStore { public: typedef std::vector<CookieStoreCommand> CommandList; @@ -45,22 +45,22 @@ class MockPersistentCookieStore void SetLoadExpectation( bool return_value, - const std::vector<net::CookieMonster::CanonicalCookie*>& result); + const std::vector<CookieMonster::CanonicalCookie*>& result); const CommandList& commands() const { return commands_; } virtual bool Load( - std::vector<net::CookieMonster::CanonicalCookie*>* out_cookies); + std::vector<CookieMonster::CanonicalCookie*>* out_cookies); - virtual void AddCookie(const net::CookieMonster::CanonicalCookie& cookie); + virtual void AddCookie(const CookieMonster::CanonicalCookie& cookie); virtual void UpdateCookieAccessTime( - const net::CookieMonster::CanonicalCookie& cookie); + const CookieMonster::CanonicalCookie& cookie); virtual void DeleteCookie( - const net::CookieMonster::CanonicalCookie& cookie); + const CookieMonster::CanonicalCookie& cookie); virtual void Flush(Task* completion_task); @@ -72,15 +72,15 @@ class MockPersistentCookieStore // Deferred result to use when Load() is called. bool load_return_value_; - std::vector<net::CookieMonster::CanonicalCookie*> load_result_; + std::vector<CookieMonster::CanonicalCookie*> load_result_; DISALLOW_COPY_AND_ASSIGN(MockPersistentCookieStore); }; // Mock for CookieMonster::Delegate -class MockCookieMonsterDelegate : public net::CookieMonster::Delegate { +class MockCookieMonsterDelegate : public CookieMonster::Delegate { public: - typedef std::pair<net::CookieMonster::CanonicalCookie, bool> + typedef std::pair<CookieMonster::CanonicalCookie, bool> CookieNotification; MockCookieMonsterDelegate(); @@ -90,9 +90,9 @@ class MockCookieMonsterDelegate : public net::CookieMonster::Delegate { void reset() { changes_.clear(); } virtual void OnCookieChanged( - const net::CookieMonster::CanonicalCookie& cookie, + const CookieMonster::CanonicalCookie& cookie, bool removed, - net::CookieMonster::Delegate::ChangeCause cause); + CookieMonster::Delegate::ChangeCause cause); private: virtual ~MockCookieMonsterDelegate(); @@ -107,34 +107,34 @@ void AddCookieToList( const std::string& key, const std::string& cookie_line, const base::Time& creation_time, - std::vector<net::CookieMonster::CanonicalCookie*>* out_list); + std::vector<CookieMonster::CanonicalCookie*>* out_list); // Just act like a backing database. Keep cookie information from // Add/Update/Delete and regurgitate it when Load is called. class MockSimplePersistentCookieStore - : public net::CookieMonster::PersistentCookieStore { + : public CookieMonster::PersistentCookieStore { public: MockSimplePersistentCookieStore(); virtual ~MockSimplePersistentCookieStore(); virtual bool Load( - std::vector<net::CookieMonster::CanonicalCookie*>* out_cookies); + std::vector<CookieMonster::CanonicalCookie*>* out_cookies); virtual void AddCookie( - const net::CookieMonster::CanonicalCookie& cookie); + const CookieMonster::CanonicalCookie& cookie); virtual void UpdateCookieAccessTime( - const net::CookieMonster::CanonicalCookie& cookie); + const CookieMonster::CanonicalCookie& cookie); virtual void DeleteCookie( - const net::CookieMonster::CanonicalCookie& cookie); + const CookieMonster::CanonicalCookie& cookie); virtual void Flush(Task* completion_task); virtual void SetClearLocalStateOnExit(bool clear_local_state); private: - typedef std::map<int64, net::CookieMonster::CanonicalCookie> + typedef std::map<int64, CookieMonster::CanonicalCookie> CanonicalCookieMap; CanonicalCookieMap cookies_; @@ -148,7 +148,7 @@ class MockSimplePersistentCookieStore // Do two SetCookies(). Return whether each of the two SetCookies() took // longer than |gc_perf_micros| to complete, and how many cookie were // left in the store afterwards. -net::CookieMonster* CreateMonsterFromStoreForGC( +CookieMonster* CreateMonsterFromStoreForGC( int num_cookies, int num_old_cookies, int days_old); diff --git a/net/base/cookie_monster_unittest.cc b/net/base/cookie_monster_unittest.cc index 78b6d1a..07dccfd 100644 --- a/net/base/cookie_monster_unittest.cc +++ b/net/base/cookie_monster_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -39,7 +39,7 @@ const char* kTopLevelDomainPlus3 = "http://www.bourbaki.math.harvard.edu"; const char* kOtherDomain = "http://www.mit.edu"; -void PopulateCmForDeleteAllForHost(scoped_refptr<net::CookieMonster> cm) { +void PopulateCmForDeleteAllForHost(scoped_refptr<CookieMonster> cm) { GURL url_top_level_domain_plus_1(kTopLevelDomainPlus1); GURL url_top_level_domain_plus_2(kTopLevelDomainPlus2); GURL url_top_level_domain_plus_2_secure(kTopLevelDomainPlus2Secure); @@ -118,7 +118,7 @@ void PopulateCmForDeleteAllForHost(scoped_refptr<net::CookieMonster> cm) { } // namespace TEST(ParsedCookieTest, TestBasic) { - net::CookieMonster::ParsedCookie pc("a=b"); + CookieMonster::ParsedCookie pc("a=b"); EXPECT_TRUE(pc.IsValid()); EXPECT_FALSE(pc.IsSecure()); EXPECT_EQ("a", pc.Name()); @@ -153,7 +153,7 @@ TEST(ParsedCookieTest, TestQuoted) { std::string input(values[i]); std::string expected(values[i + 1]); - net::CookieMonster::ParsedCookie pc( + CookieMonster::ParsedCookie pc( "aBc=" + input + " ; path=\"/\" ; httponly "); EXPECT_TRUE(pc.IsValid()); EXPECT_FALSE(pc.IsSecure()); @@ -170,7 +170,7 @@ TEST(ParsedCookieTest, TestQuoted) { } TEST(ParsedCookieTest, TestNameless) { - net::CookieMonster::ParsedCookie pc("BLAHHH; path=/; secure;"); + CookieMonster::ParsedCookie pc("BLAHHH; path=/; secure;"); EXPECT_TRUE(pc.IsValid()); EXPECT_TRUE(pc.IsSecure()); EXPECT_TRUE(pc.HasPath()); @@ -180,7 +180,7 @@ TEST(ParsedCookieTest, TestNameless) { } TEST(ParsedCookieTest, TestAttributeCase) { - net::CookieMonster::ParsedCookie pc("BLAHHH; Path=/; sECuRe; httpONLY"); + CookieMonster::ParsedCookie pc("BLAHHH; Path=/; sECuRe; httpONLY"); EXPECT_TRUE(pc.IsValid()); EXPECT_TRUE(pc.IsSecure()); EXPECT_TRUE(pc.IsHttpOnly()); @@ -192,7 +192,7 @@ TEST(ParsedCookieTest, TestAttributeCase) { } TEST(ParsedCookieTest, TestDoubleQuotedNameless) { - net::CookieMonster::ParsedCookie pc("\"BLA\\\"HHH\"; path=/; secure;"); + CookieMonster::ParsedCookie pc("\"BLA\\\"HHH\"; path=/; secure;"); EXPECT_TRUE(pc.IsValid()); EXPECT_TRUE(pc.IsSecure()); EXPECT_TRUE(pc.HasPath()); @@ -203,7 +203,7 @@ TEST(ParsedCookieTest, TestDoubleQuotedNameless) { } TEST(ParsedCookieTest, QuoteOffTheEnd) { - net::CookieMonster::ParsedCookie pc("a=\"B"); + CookieMonster::ParsedCookie pc("a=\"B"); EXPECT_TRUE(pc.IsValid()); EXPECT_EQ("a", pc.Name()); EXPECT_EQ("\"B", pc.Value()); @@ -211,7 +211,7 @@ TEST(ParsedCookieTest, QuoteOffTheEnd) { } TEST(ParsedCookieTest, MissingName) { - net::CookieMonster::ParsedCookie pc("=ABC"); + CookieMonster::ParsedCookie pc("=ABC"); EXPECT_TRUE(pc.IsValid()); EXPECT_EQ("", pc.Name()); EXPECT_EQ("ABC", pc.Value()); @@ -219,7 +219,7 @@ TEST(ParsedCookieTest, MissingName) { } TEST(ParsedCookieTest, MissingValue) { - net::CookieMonster::ParsedCookie pc("ABC=; path = /wee"); + CookieMonster::ParsedCookie pc("ABC=; path = /wee"); EXPECT_TRUE(pc.IsValid()); EXPECT_EQ("ABC", pc.Name()); EXPECT_EQ("", pc.Value()); @@ -229,7 +229,7 @@ TEST(ParsedCookieTest, MissingValue) { } TEST(ParsedCookieTest, Whitespace) { - net::CookieMonster::ParsedCookie pc(" A = BC ;secure;;; httponly"); + CookieMonster::ParsedCookie pc(" A = BC ;secure;;; httponly"); EXPECT_TRUE(pc.IsValid()); EXPECT_EQ("A", pc.Name()); EXPECT_EQ("BC", pc.Value()); @@ -242,7 +242,7 @@ TEST(ParsedCookieTest, Whitespace) { EXPECT_EQ(4U, pc.NumberOfAttributes()); } TEST(ParsedCookieTest, MultipleEquals) { - net::CookieMonster::ParsedCookie pc(" A=== BC ;secure;;; httponly"); + CookieMonster::ParsedCookie pc(" A=== BC ;secure;;; httponly"); EXPECT_TRUE(pc.IsValid()); EXPECT_EQ("A", pc.Name()); EXPECT_EQ("== BC", pc.Value()); @@ -254,7 +254,7 @@ TEST(ParsedCookieTest, MultipleEquals) { } TEST(ParsedCookieTest, QuotedTrailingWhitespace) { - net::CookieMonster::ParsedCookie pc("ANCUUID=\"zohNumRKgI0oxyhSsV3Z7D\" ; " + CookieMonster::ParsedCookie pc("ANCUUID=\"zohNumRKgI0oxyhSsV3Z7D\" ; " "expires=Sun, 18-Apr-2027 21:06:29 GMT ; " "path=/ ; "); EXPECT_TRUE(pc.IsValid()); @@ -268,7 +268,7 @@ TEST(ParsedCookieTest, QuotedTrailingWhitespace) { } TEST(ParsedCookieTest, TrailingWhitespace) { - net::CookieMonster::ParsedCookie pc("ANCUUID=zohNumRKgI0oxyhSsV3Z7D ; " + CookieMonster::ParsedCookie pc("ANCUUID=zohNumRKgI0oxyhSsV3Z7D ; " "expires=Sun, 18-Apr-2027 21:06:29 GMT ; " "path=/ ; "); EXPECT_TRUE(pc.IsValid()); @@ -282,43 +282,43 @@ TEST(ParsedCookieTest, TrailingWhitespace) { TEST(ParsedCookieTest, TooManyPairs) { std::string blankpairs; - blankpairs.resize(net::CookieMonster::ParsedCookie::kMaxPairs - 1, ';'); + blankpairs.resize(CookieMonster::ParsedCookie::kMaxPairs - 1, ';'); - net::CookieMonster::ParsedCookie pc1(blankpairs + "secure"); + CookieMonster::ParsedCookie pc1(blankpairs + "secure"); EXPECT_TRUE(pc1.IsValid()); EXPECT_TRUE(pc1.IsSecure()); - net::CookieMonster::ParsedCookie pc2(blankpairs + ";secure"); + CookieMonster::ParsedCookie pc2(blankpairs + ";secure"); EXPECT_TRUE(pc2.IsValid()); EXPECT_FALSE(pc2.IsSecure()); } // TODO some better test cases for invalid cookies. TEST(ParsedCookieTest, InvalidWhitespace) { - net::CookieMonster::ParsedCookie pc(" "); + CookieMonster::ParsedCookie pc(" "); EXPECT_FALSE(pc.IsValid()); } TEST(ParsedCookieTest, InvalidTooLong) { std::string maxstr; - maxstr.resize(net::CookieMonster::ParsedCookie::kMaxCookieSize, 'a'); + maxstr.resize(CookieMonster::ParsedCookie::kMaxCookieSize, 'a'); - net::CookieMonster::ParsedCookie pc1(maxstr); + CookieMonster::ParsedCookie pc1(maxstr); EXPECT_TRUE(pc1.IsValid()); - net::CookieMonster::ParsedCookie pc2(maxstr + "A"); + CookieMonster::ParsedCookie pc2(maxstr + "A"); EXPECT_FALSE(pc2.IsValid()); } TEST(ParsedCookieTest, InvalidEmpty) { - net::CookieMonster::ParsedCookie pc(""); + CookieMonster::ParsedCookie pc(""); EXPECT_FALSE(pc.IsValid()); } TEST(ParsedCookieTest, EmbeddedTerminator) { - net::CookieMonster::ParsedCookie pc1("AAA=BB\0ZYX"); - net::CookieMonster::ParsedCookie pc2("AAA=BB\rZYX"); - net::CookieMonster::ParsedCookie pc3("AAA=BB\nZYX"); + CookieMonster::ParsedCookie pc1("AAA=BB\0ZYX"); + CookieMonster::ParsedCookie pc2("AAA=BB\rZYX"); + CookieMonster::ParsedCookie pc3("AAA=BB\nZYX"); EXPECT_TRUE(pc1.IsValid()); EXPECT_EQ("AAA", pc1.Name()); EXPECT_EQ("BB", pc1.Value()); @@ -332,28 +332,28 @@ TEST(ParsedCookieTest, EmbeddedTerminator) { TEST(ParsedCookieTest, ParseTokensAndValues) { EXPECT_EQ("hello", - net::CookieMonster::ParsedCookie::ParseTokenString( + CookieMonster::ParsedCookie::ParseTokenString( "hello\nworld")); EXPECT_EQ("fs!!@", - net::CookieMonster::ParsedCookie::ParseTokenString( + CookieMonster::ParsedCookie::ParseTokenString( "fs!!@;helloworld")); EXPECT_EQ("hello world\tgood", - net::CookieMonster::ParsedCookie::ParseTokenString( + CookieMonster::ParsedCookie::ParseTokenString( "hello world\tgood\rbye")); EXPECT_EQ("A", - net::CookieMonster::ParsedCookie::ParseTokenString( + CookieMonster::ParsedCookie::ParseTokenString( "A=B=C;D=E")); EXPECT_EQ("hello", - net::CookieMonster::ParsedCookie::ParseValueString( + CookieMonster::ParsedCookie::ParseValueString( "hello\nworld")); EXPECT_EQ("fs!!@", - net::CookieMonster::ParsedCookie::ParseValueString( + CookieMonster::ParsedCookie::ParseValueString( "fs!!@;helloworld")); EXPECT_EQ("hello world\tgood", - net::CookieMonster::ParsedCookie::ParseValueString( + CookieMonster::ParsedCookie::ParseValueString( "hello world\tgood\rbye")); EXPECT_EQ("A=B=C", - net::CookieMonster::ParsedCookie::ParseValueString( + CookieMonster::ParsedCookie::ParseValueString( "A=B=C;D=E")); } @@ -369,7 +369,7 @@ TEST(CookieMonsterTest, DomainTest) { scoped_refptr<MockPersistentCookieStore> store( new MockPersistentCookieStore); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(store, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL)); EXPECT_TRUE(cm->SetCookie(url_google, "A=B")); EXPECT_EQ("A=B", cm->GetCookies(url_google)); EXPECT_TRUE(cm->SetCookie(url_google, "C=D; domain=.google.izzle")); @@ -405,7 +405,7 @@ TEST(CookieMonsterTest, DomainTest) { TEST(CookieMonsterTest, DomainWithTrailingDotTest) { scoped_refptr<MockPersistentCookieStore> store( new MockPersistentCookieStore); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(store, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL)); GURL url_google("http://www.google.com"); EXPECT_FALSE(cm->SetCookie(url_google, "a=1; domain=.www.google.com.")); @@ -421,7 +421,7 @@ TEST(CookieMonsterTest, DomainWithTrailingDotTest) { TEST(CookieMonsterTest, ValidSubdomainTest) { scoped_refptr<MockPersistentCookieStore> store( new MockPersistentCookieStore); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(store, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL)); GURL url_abcd("http://a.b.c.d.com"); GURL url_bcd("http://b.c.d.com"); GURL url_cd("http://c.d.com"); @@ -456,7 +456,7 @@ TEST(CookieMonsterTest, InvalidDomainTest) { scoped_refptr<MockPersistentCookieStore> store( new MockPersistentCookieStore); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(store, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL)); GURL url_foobar("http://foo.bar.com"); // More specific sub-domain than allowed. @@ -496,7 +496,7 @@ TEST(CookieMonsterTest, InvalidDomainTest) { // Make sure the cookie code hasn't gotten its subdomain string handling // reversed, missed a suffix check, etc. It's important here that the two // hosts below have the same domain + registry. - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); GURL url_foocom("http://foo.com.com"); EXPECT_FALSE(cm->SetCookie(url_foocom, "a=1; domain=.foo.com.com.com")); EXPECT_EQ("", cm->GetCookies(url_foocom)); @@ -508,7 +508,7 @@ TEST(CookieMonsterTest, InvalidDomainTest) { // http://b/issue?id=889898 TEST(CookieMonsterTest, DomainWithoutLeadingDotTest) { { // The omission of dot results in setting a domain cookie. - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); GURL url_hosted("http://manage.hosted.filefront.com"); GURL url_filefront("http://www.filefront.com"); EXPECT_TRUE(cm->SetCookie(url_hosted, "sawAd=1; domain=filefront.com")); @@ -517,7 +517,7 @@ TEST(CookieMonsterTest, DomainWithoutLeadingDotTest) { } { // Even when the domains match exactly, don't consider it host cookie. - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); GURL url("http://www.google.com"); EXPECT_TRUE(cm->SetCookie(url, "a=1; domain=www.google.com")); EXPECT_EQ("a=1", cm->GetCookies(url)); @@ -529,7 +529,7 @@ TEST(CookieMonsterTest, DomainWithoutLeadingDotTest) { // Test that the domain specified in cookie string is treated case-insensitive // http://b/issue?id=896475. TEST(CookieMonsterTest, CaseInsensitiveDomainTest) { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); GURL url_google("http://www.google.com"); EXPECT_TRUE(cm->SetCookie(url_google, "a=1; domain=.GOOGLE.COM")); EXPECT_TRUE(cm->SetCookie(url_google, "b=2; domain=.wWw.gOOgLE.coM")); @@ -539,13 +539,13 @@ TEST(CookieMonsterTest, CaseInsensitiveDomainTest) { TEST(CookieMonsterTest, TestIpAddress) { GURL url_ip("http://1.2.3.4/weee"); { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); EXPECT_TRUE(cm->SetCookie(url_ip, kValidCookieLine)); EXPECT_EQ("A=B", cm->GetCookies(url_ip)); } { // IP addresses should not be able to set domain cookies. - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); EXPECT_FALSE(cm->SetCookie(url_ip, "b=2; domain=.1.2.3.4")); EXPECT_FALSE(cm->SetCookie(url_ip, "c=3; domain=.3.4")); EXPECT_EQ("", cm->GetCookies(url_ip)); @@ -561,7 +561,7 @@ TEST(CookieMonsterTest, TestIpAddress) { // Test host cookies, and setting of cookies on TLD. TEST(CookieMonsterTest, TestNonDottedAndTLD) { { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); GURL url("http://com/"); // Allow setting on "com", (but only as a host cookie). EXPECT_TRUE(cm->SetCookie(url, "a=1")); @@ -575,7 +575,7 @@ TEST(CookieMonsterTest, TestNonDottedAndTLD) { } { // http://com. should be treated the same as http://com. - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); GURL url("http://com./index.html"); EXPECT_TRUE(cm->SetCookie(url, "a=1")); EXPECT_EQ("a=1", cm->GetCookies(url)); @@ -583,7 +583,7 @@ TEST(CookieMonsterTest, TestNonDottedAndTLD) { } { // Should not be able to set host cookie from a subdomain. - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); GURL url("http://a.b"); EXPECT_FALSE(cm->SetCookie(url, "a=1; domain=.b")); EXPECT_FALSE(cm->SetCookie(url, "b=2; domain=b")); @@ -591,7 +591,7 @@ TEST(CookieMonsterTest, TestNonDottedAndTLD) { } { // Same test as above, but explicitly on a known TLD (com). - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); GURL url("http://google.com"); EXPECT_FALSE(cm->SetCookie(url, "a=1; domain=.com")); EXPECT_FALSE(cm->SetCookie(url, "b=2; domain=com")); @@ -599,7 +599,7 @@ TEST(CookieMonsterTest, TestNonDottedAndTLD) { } { // Make sure can't set cookie on TLD which is dotted. - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); GURL url("http://google.co.uk"); EXPECT_FALSE(cm->SetCookie(url, "a=1; domain=.co.uk")); EXPECT_FALSE(cm->SetCookie(url, "b=2; domain=.uk")); @@ -609,7 +609,7 @@ TEST(CookieMonsterTest, TestNonDottedAndTLD) { } { // Intranet URLs should only be able to set host cookies. - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); GURL url("http://b"); EXPECT_TRUE(cm->SetCookie(url, "a=1")); EXPECT_FALSE(cm->SetCookie(url, "b=2; domain=.b")); @@ -621,7 +621,7 @@ TEST(CookieMonsterTest, TestNonDottedAndTLD) { // Test reading/writing cookies when the domain ends with a period, // as in "www.google.com." TEST(CookieMonsterTest, TestHostEndsWithDot) { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); GURL url("http://www.google.com"); GURL url_with_dot("http://www.google.com."); EXPECT_TRUE(cm->SetCookie(url, "a=1")); @@ -641,19 +641,19 @@ TEST(CookieMonsterTest, TestHostEndsWithDot) { } TEST(CookieMonsterTest, InvalidScheme) { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); EXPECT_FALSE(cm->SetCookie(GURL(kUrlFtp), kValidCookieLine)); } TEST(CookieMonsterTest, InvalidScheme_Read) { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); EXPECT_TRUE(cm->SetCookie(GURL(kUrlGoogle), kValidDomainCookieLine)); EXPECT_EQ("", cm->GetCookies(GURL(kUrlFtp))); } TEST(CookieMonsterTest, PathTest) { std::string url("http://www.google.izzle"); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); EXPECT_TRUE(cm->SetCookie(GURL(url), "A=B; path=/wee")); EXPECT_EQ("A=B", cm->GetCookies(GURL(url + "/wee"))); EXPECT_EQ("A=B", cm->GetCookies(GURL(url + "/wee/"))); @@ -670,8 +670,8 @@ TEST(CookieMonsterTest, PathTest) { TEST(CookieMonsterTest, HttpOnlyTest) { GURL url_google(kUrlGoogle); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); - net::CookieOptions options; + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); + CookieOptions options; options.set_include_httponly(); // Create a httponly cookie. @@ -785,7 +785,7 @@ TEST(CookieMonsterTest, TestCookieDateParsing) { Time parsed_time; for (size_t i = 0; i < arraysize(tests); ++i) { - parsed_time = net::CookieMonster::ParseCookieTime(tests[i].str); + parsed_time = CookieMonster::ParseCookieTime(tests[i].str); if (!tests[i].valid) { EXPECT_FALSE(!parsed_time.is_null()) << tests[i].str; continue; @@ -804,7 +804,7 @@ TEST(CookieMonsterTest, TestDomainIsHostOnly) { for (size_t i = 0; i < arraysize(tests); ++i) { EXPECT_EQ(tests[i].is_host_only, - net::CookieMonster::DomainIsHostOnly(tests[i].str)); + CookieMonster::DomainIsHostOnly(tests[i].str)); } } @@ -812,7 +812,7 @@ TEST(CookieMonsterTest, TestCookieDeletion) { GURL url_google(kUrlGoogle); scoped_refptr<MockPersistentCookieStore> store( new MockPersistentCookieStore); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(store, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL)); // Create a session cookie. EXPECT_TRUE(cm->SetCookie(url_google, kValidCookieLine)); @@ -881,8 +881,8 @@ TEST(CookieMonsterTest, TestCookieDeleteAll) { GURL url_google(kUrlGoogle); scoped_refptr<MockPersistentCookieStore> store( new MockPersistentCookieStore); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(store, NULL)); - net::CookieOptions options; + scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL)); + CookieOptions options; options.set_include_httponly(); EXPECT_TRUE(cm->SetCookie(url_google, kValidCookieLine)); @@ -912,7 +912,7 @@ TEST(CookieMonsterTest, TestCookieDeleteAll) { TEST(CookieMonsterTest, TestCookieDeleteAllCreatedAfterTimestamp) { GURL url_google(kUrlGoogle); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); Time now = Time::Now(); // Nothing has been added so nothing should be deleted. @@ -940,7 +940,7 @@ TEST(CookieMonsterTest, TestCookieDeleteAllCreatedAfterTimestamp) { TEST(CookieMonsterTest, TestCookieDeleteAllCreatedBetweenTimestamps) { GURL url_google(kUrlGoogle); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); Time now = Time::Now(); // Nothing has been added so nothing should be deleted. @@ -983,7 +983,7 @@ TEST(CookieMonsterTest, TestCookieDeleteAllCreatedBetweenTimestamps) { TEST(CookieMonsterTest, TestSecure) { GURL url_google(kUrlGoogle); GURL url_google_secure(kUrlGoogleSecure); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); EXPECT_TRUE(cm->SetCookie(url_google, "A=B")); EXPECT_EQ("A=B", cm->GetCookies(url_google)); @@ -1004,8 +1004,8 @@ TEST(CookieMonsterTest, TestSecure) { EXPECT_EQ("D=E; A=B", cm->GetCookies(url_google_secure)); } -static Time GetFirstCookieAccessDate(net::CookieMonster* cm) { - const net::CookieList all_cookies(cm->GetAllCookies()); +static Time GetFirstCookieAccessDate(CookieMonster* cm) { + const CookieList all_cookies(cm->GetAllCookies()); return all_cookies.front().LastAccessDate(); } @@ -1013,8 +1013,8 @@ static const int kLastAccessThresholdMilliseconds = 200; TEST(CookieMonsterTest, TestLastAccess) { GURL url_google(kUrlGoogle); - scoped_refptr<net::CookieMonster> cm( - new net::CookieMonster(NULL, NULL, kLastAccessThresholdMilliseconds)); + scoped_refptr<CookieMonster> cm( + new CookieMonster(NULL, NULL, kLastAccessThresholdMilliseconds)); EXPECT_TRUE(cm->SetCookie(url_google, "A=B")); const Time last_access_date(GetFirstCookieAccessDate(cm)); @@ -1043,7 +1043,7 @@ static void TestHostGarbageCollectHelper( (domain_max_cookies + domain_purge_cookies) * 2; // Add a bunch of cookies on a single host, should purge them. { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); cm->SetExpiryAndKeyScheme(key_scheme); for (int i = 0; i < more_than_enough_cookies; ++i) { std::string cookie = base::StringPrintf("a%03d=b", i); @@ -1065,7 +1065,7 @@ static void TestHostGarbageCollectHelper( // individual domain shouldn't go above kDomainMaxCookies. GURL url_google_specific(kUrlGoogleSpecific); { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); cm->SetExpiryAndKeyScheme(key_scheme); for (int i = 0; i < more_than_enough_cookies; ++i) { std::string cookie_general = base::StringPrintf("a%03d=b", i); @@ -1121,7 +1121,7 @@ TEST(CookieMonsterTest, TestHostGarbageCollection) { TEST(CookieMonsterTest, NetUtilCookieTest) { const GURL test_url("http://mojo.jojo.google.izzle/"); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); EXPECT_TRUE(cm->SetCookie(test_url, "foo=bar")); std::string value = cm->GetCookies(test_url); @@ -1137,11 +1137,11 @@ TEST(CookieMonsterTest, NetUtilCookieTest) { EXPECT_NE(result.find("y=2"), std::string::npos) << result; } -static bool FindAndDeleteCookie(net::CookieMonster* cm, +static bool FindAndDeleteCookie(CookieMonster* cm, const std::string& domain, const std::string& name) { - net::CookieList cookies = cm->GetAllCookies(); - for (net::CookieList::iterator it = cookies.begin(); + CookieList cookies = cm->GetAllCookies(); + for (CookieList::iterator it = cookies.begin(); it != cookies.end(); ++it) if (it->Domain() == domain && it->Name() == name) return cm->DeleteCanonicalCookie(*it); @@ -1151,7 +1151,7 @@ static bool FindAndDeleteCookie(net::CookieMonster* cm, TEST(CookieMonsterTest, TestDeleteSingleCookie) { GURL url_google(kUrlGoogle); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); EXPECT_TRUE(cm->SetCookie(url_google, "A=B")); EXPECT_TRUE(cm->SetCookie(url_google, "C=D")); @@ -1166,8 +1166,8 @@ TEST(CookieMonsterTest, TestDeleteSingleCookie) { } TEST(CookieMonsterTest, SetCookieableSchemes) { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); - scoped_refptr<net::CookieMonster> cm_foo(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm_foo(new CookieMonster(NULL, NULL)); // Only cm_foo should allow foo:// cookies. const char* kSchemes[] = {"foo"}; @@ -1186,11 +1186,11 @@ TEST(CookieMonsterTest, GetAllCookiesForURL) { GURL url_google(kUrlGoogle); GURL url_google_secure(kUrlGoogleSecure); - scoped_refptr<net::CookieMonster> cm( - new net::CookieMonster(NULL, NULL, kLastAccessThresholdMilliseconds)); + scoped_refptr<CookieMonster> cm( + new CookieMonster(NULL, NULL, kLastAccessThresholdMilliseconds)); // Create an httponly cookie. - net::CookieOptions options; + CookieOptions options; options.set_include_httponly(); EXPECT_TRUE(cm->SetCookieWithOptions(url_google, "A=B; httponly", options)); @@ -1206,8 +1206,8 @@ TEST(CookieMonsterTest, GetAllCookiesForURL) { base::PlatformThread::Sleep(kLastAccessThresholdMilliseconds + 20); // Check cookies for url. - net::CookieList cookies = cm->GetAllCookiesForURL(url_google); - net::CookieList::iterator it = cookies.begin(); + CookieList cookies = cm->GetAllCookiesForURL(url_google); + CookieList::iterator it = cookies.begin(); ASSERT_TRUE(it != cookies.end()); EXPECT_EQ("www.google.izzle", it->Domain()); @@ -1221,7 +1221,7 @@ TEST(CookieMonsterTest, GetAllCookiesForURL) { // Check cookies for url excluding http-only cookies. cookies = - cm->GetAllCookiesForURLWithOptions(url_google, net::CookieOptions()); + cm->GetAllCookiesForURLWithOptions(url_google, CookieOptions()); it = cookies.begin(); ASSERT_TRUE(it != cookies.end()); @@ -1257,8 +1257,8 @@ TEST(CookieMonsterTest, GetAllCookiesForURLPathMatching) { GURL url_google_foo("http://www.google.izzle/foo"); GURL url_google_bar("http://www.google.izzle/bar"); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); - net::CookieOptions options; + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); + CookieOptions options; EXPECT_TRUE(cm->SetCookieWithOptions(url_google_foo, "A=B; path=/foo;", @@ -1270,8 +1270,8 @@ TEST(CookieMonsterTest, GetAllCookiesForURLPathMatching) { "E=F;", options)); - net::CookieList cookies = cm->GetAllCookiesForURL(url_google_foo); - net::CookieList::iterator it = cookies.begin(); + CookieList cookies = cm->GetAllCookiesForURL(url_google_foo); + CookieList::iterator it = cookies.begin(); ASSERT_TRUE(it != cookies.end()); EXPECT_EQ("A", it->Name()); @@ -1298,7 +1298,7 @@ TEST(CookieMonsterTest, GetAllCookiesForURLPathMatching) { } TEST(CookieMonsterTest, DeleteCookieByName) { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); GURL url_google(kUrlGoogle); EXPECT_TRUE(cm->SetCookie(url_google, "A=A1; path=/")); @@ -1310,10 +1310,10 @@ TEST(CookieMonsterTest, DeleteCookieByName) { cm->DeleteCookie(GURL(std::string(kUrlGoogle) + "/foo/bar"), "A"); - net::CookieList cookies = cm->GetAllCookies(); + CookieList cookies = cm->GetAllCookies(); size_t expected_size = 4; EXPECT_EQ(expected_size, cookies.size()); - for (net::CookieList::iterator it = cookies.begin(); + for (CookieList::iterator it = cookies.begin(); it != cookies.end(); ++it) { EXPECT_NE("A1", it->Value()); EXPECT_NE("A2", it->Value()); @@ -1327,7 +1327,7 @@ TEST(CookieMonsterTest, OverwritePersistentCookie) { GURL url_chromium("http://chromium.org"); scoped_refptr<MockPersistentCookieStore> store( new MockPersistentCookieStore); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(store, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL)); // Insert a cookie "a" for path "/path1" EXPECT_TRUE( @@ -1345,7 +1345,7 @@ TEST(CookieMonsterTest, OverwritePersistentCookie) { // Insert a cookie "b" for path "/path1", that is httponly. This should // overwrite the non-http-only version. - net::CookieOptions allow_httponly; + CookieOptions allow_httponly; allow_httponly.set_include_httponly(); EXPECT_TRUE( cm->SetCookieWithOptions(url_google, @@ -1402,7 +1402,7 @@ TEST(CookieMonsterTest, DontImportDuplicateCookies) { // be careful not to have any duplicate creation times at all (as it's a // violation of a CookieMonster invariant) even if Time::Now() doesn't // move between calls. - std::vector<net::CookieMonster::CanonicalCookie*> initial_cookies; + std::vector<CookieMonster::CanonicalCookie*> initial_cookies; // Insert 4 cookies with name "X" on path "/", with varying creation // dates. We expect only the most recent one to be preserved following @@ -1452,7 +1452,7 @@ TEST(CookieMonsterTest, DontImportDuplicateCookies) { // Inject our initial cookies into the mock PersistentCookieStore. store->SetLoadExpectation(true, initial_cookies); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(store, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL)); // Verify that duplicates were not imported for path "/". // (If this had failed, GetCookies() would have also returned X=1, X=2, X=4). @@ -1489,7 +1489,7 @@ TEST(CookieMonsterTest, DontImportDuplicateCreationTimes) { // four with the earlier time as creation times. We should only get // two cookies remaining, but which two (other than that there should // be one from each set) will be random. - std::vector<net::CookieMonster::CanonicalCookie*> initial_cookies; + std::vector<CookieMonster::CanonicalCookie*> initial_cookies; AddCookieToList("www.google.com", "X=1; path=/", now, &initial_cookies); AddCookieToList("www.google.com", "X=2; path=/", now, &initial_cookies); AddCookieToList("www.google.com", "X=3; path=/", now, &initial_cookies); @@ -1503,9 +1503,9 @@ TEST(CookieMonsterTest, DontImportDuplicateCreationTimes) { // Inject our initial cookies into the mock PersistentCookieStore. store->SetLoadExpectation(true, initial_cookies); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(store, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL)); - net::CookieList list(cm->GetAllCookies()); + CookieList list(cm->GetAllCookies()); EXPECT_EQ(2U, list.size()); // Confirm that we have one of each. std::string name1(list[0].Name()); @@ -1522,7 +1522,7 @@ TEST(CookieMonsterTest, Delegate) { new MockPersistentCookieStore); scoped_refptr<MockCookieMonsterDelegate> delegate( new MockCookieMonsterDelegate); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(store, delegate)); + scoped_refptr<CookieMonster> cm(new CookieMonster(store, delegate)); EXPECT_TRUE(cm->SetCookie(url_google, "A=B")); EXPECT_TRUE(cm->SetCookie(url_google, "C=D")); @@ -1571,7 +1571,7 @@ TEST(CookieMonsterTest, Delegate) { // Insert a cookie "a" for path "/path1", that is httponly. This should // overwrite the non-http-only version. - net::CookieOptions allow_httponly; + CookieOptions allow_httponly; allow_httponly.set_include_httponly(); EXPECT_TRUE( cm->SetCookieWithOptions(url_google, @@ -1599,7 +1599,7 @@ TEST(CookieMonsterTest, SetCookieWithDetails) { GURL url_google_bar("http://www.google.izzle/bar"); GURL url_google_secure(kUrlGoogleSecure); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); EXPECT_TRUE(cm->SetCookieWithDetails( url_google_foo, "A", "B", std::string(), "/foo", base::Time(), @@ -1628,8 +1628,8 @@ TEST(CookieMonsterTest, SetCookieWithDetails) { url_google_foo, "A=", "B", std::string(), "foo", base::Time(), false, false)); - net::CookieList cookies = cm->GetAllCookiesForURL(url_google_foo); - net::CookieList::iterator it = cookies.begin(); + CookieList cookies = cm->GetAllCookiesForURL(url_google_foo); + CookieList::iterator it = cookies.begin(); ASSERT_TRUE(it != cookies.end()); EXPECT_EQ("A", it->Name()); @@ -1670,7 +1670,7 @@ TEST(CookieMonsterTest, SetCookieWithDetails) { } TEST(CookieMonsterTest, DeleteAllForHost) { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); // Test probes: // * Non-secure URL, mid-level (http://w.c.b.a) @@ -1733,9 +1733,9 @@ TEST(CookieMonsterTest, DeleteAllForHost) { } TEST(CookieMonsterTest, UniqueCreationTime) { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); GURL url_google(kUrlGoogle); - net::CookieOptions options; + CookieOptions options; // Add in three cookies through every public interface to the // CookieMonster and confirm that none of them have duplicate @@ -1781,10 +1781,10 @@ TEST(CookieMonsterTest, UniqueCreationTime) { ".google.com", "/", Time(), false, false); // Now we check - net::CookieList cookie_list(cm->GetAllCookies()); - typedef std::map<int64, net::CookieMonster::CanonicalCookie> TimeCookieMap; + CookieList cookie_list(cm->GetAllCookies()); + typedef std::map<int64, CookieMonster::CanonicalCookie> TimeCookieMap; TimeCookieMap check_map; - for (net::CookieList::const_iterator it = cookie_list.begin(); + for (CookieList::const_iterator it = cookie_list.begin(); it != cookie_list.end(); it++) { const int64 creation_date = it->CreationDate().ToInternalValue(); TimeCookieMap::const_iterator @@ -1805,7 +1805,7 @@ TEST(CookieMonsterTest, UniqueCreationTime) { // Mainly a test of GetEffectiveDomain, or more specifically, of the // expected behavior of GetEffectiveDomain within the CookieMonster. TEST(CookieMonsterTest, GetKey) { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); // This test is really only interesting if GetKey() actually does something. if (cm->expiry_and_key_scheme_ == @@ -1862,7 +1862,7 @@ TEST(CookieMonsterTest, BackingStoreCommunication) { // Create new cookies and flush them to the store. { - scoped_refptr<net::CookieMonster> cmout(new CookieMonster(store, NULL)); + scoped_refptr<CookieMonster> cmout(new CookieMonster(store, NULL)); for (const CookiesInputInfo* p = input_info; p < &input_info[ARRAYSIZE_UNSAFE(input_info)]; p++) { EXPECT_TRUE(cmout->SetCookieWithDetails(GURL(p->gurl), p->name, p->value, @@ -1876,7 +1876,7 @@ TEST(CookieMonsterTest, BackingStoreCommunication) { // Create a new cookie monster and make sure that everything is correct { - scoped_refptr<net::CookieMonster> cmin(new CookieMonster(store, NULL)); + scoped_refptr<CookieMonster> cmin(new CookieMonster(store, NULL)); CookieList cookies(cmin->GetAllCookies()); ASSERT_EQ(2u, cookies.size()); // Ordering is path length, then creation time. So second cookie @@ -1905,7 +1905,7 @@ TEST(CookieMonsterTest, BackingStoreCommunication) { TEST(CookieMonsterTest, CookieOrdering) { // Put a random set of cookies into a monster and make sure // they're returned in the right order. - scoped_refptr<net::CookieMonster> cm(new CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); EXPECT_TRUE(cm->SetCookie(GURL("http://d.c.b.a.google.com/aa/x.html"), "c=1")); EXPECT_TRUE(cm->SetCookie(GURL("http://b.a.google.com/aa/bb/cc/x.html"), @@ -1951,8 +1951,8 @@ TEST(CookieMonsterTest, CookieOrdering) { // Function for creating a CM with a number of cookies in it, // no store (and hence no ability to affect access time). -static net::CookieMonster* CreateMonsterForGC(int num_cookies) { - net::CookieMonster* cm(new net::CookieMonster(NULL, NULL)); +static CookieMonster* CreateMonsterForGC(int num_cookies) { + CookieMonster* cm(new CookieMonster(NULL, NULL)); for (int i = 0; i < num_cookies; i++) cm->SetCookie(GURL(StringPrintf("http://h%05d.izzle", i)), "a=1"); return cm; @@ -1974,7 +1974,7 @@ TEST(CookieMonsterTest, DISABLED_GarbageCollectionTriggers) { // First we check to make sure that a whole lot of recent cookies // doesn't get rid of anything after garbage collection is checked for. { - scoped_refptr<net::CookieMonster> cm( + scoped_refptr<CookieMonster> cm( CreateMonsterForGC(CookieMonster::kMaxCookies * 2)); EXPECT_EQ(CookieMonster::kMaxCookies * 2, cm->GetAllCookies().size()); cm->SetCookie(GURL("http://newdomain.com"), "b=2"); @@ -2033,7 +2033,7 @@ TEST(CookieMonsterTest, DISABLED_GarbageCollectionTriggers) { recent_scheme < static_cast<int>(ARRAYSIZE_UNSAFE(schemes)); recent_scheme++) { const TestCase *test_case = &test_cases[ci]; - scoped_refptr<net::CookieMonster> cm( + scoped_refptr<CookieMonster> cm( CreateMonsterFromStoreForGC( test_case->num_cookies, test_case->num_old_cookies, CookieMonster::kSafeFromGlobalPurgeDays * 2)); @@ -2057,8 +2057,8 @@ TEST(CookieMonsterTest, DISABLED_GarbageCollectionTriggers) { // cookie works as expected. TEST(CookieMonsterTest, ForceSessionOnly) { GURL url_google(kUrlGoogle); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); - net::CookieOptions options; + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); + CookieOptions options; // Set a persistent cookie, but force it to be a session cookie. options.set_force_session(); @@ -2084,9 +2084,9 @@ TEST(CookieMonsterTest, ForceSessionOnly) { // This test checks that keep expired cookies flag is working. TEST(CookieMonsterTest, KeepExpiredCookies) { GURL url_google(kUrlGoogle); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); cm->SetKeepExpiredCookies(); - net::CookieOptions options; + CookieOptions options; // Set a persistent cookie. ASSERT_TRUE(cm->SetCookieWithOptions(url_google, @@ -2165,7 +2165,7 @@ class CallbackCounter : public base::RefCountedThreadSafe<CallbackCounter> { TEST(CookieMonsterTest, FlushStore) { scoped_refptr<CallbackCounter> counter(new CallbackCounter()); scoped_refptr<FlushablePersistentStore> store(new FlushablePersistentStore()); - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(store, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL)); ASSERT_EQ(0, store->flush_count()); ASSERT_EQ(0, counter->callback_count()); @@ -2200,7 +2200,7 @@ TEST(CookieMonsterTest, FlushStore) { ASSERT_EQ(2, counter->callback_count()); // If there's no backing store, FlushStore() is always a safe no-op. - cm = new net::CookieMonster(NULL, NULL); + cm = new CookieMonster(NULL, NULL); cm->GetAllCookies(); // Force init. cm->FlushStore(NULL); MessageLoop::current()->RunAllPending(); @@ -2244,7 +2244,7 @@ TEST(CookieMonsterTest, GetCookieSourceFromURL) { } TEST(CookieMonsterTest, HistogramCheck) { - scoped_refptr<net::CookieMonster> cm(new net::CookieMonster(NULL, NULL)); + scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); // Should match call in InitializeHistograms, but doesn't really matter // since the histogram should have been initialized by the CM construction // above. diff --git a/net/base/data_url_unittest.cc b/net/base/data_url_unittest.cc index c90fb8b..d9fe7a5 100644 --- a/net/base/data_url_unittest.cc +++ b/net/base/data_url_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -17,9 +17,6 @@ struct ParseTestData { const char* data; }; -class DataURLTest : public testing::Test { -}; - } TEST(DataURLTest, Parse) { diff --git a/net/base/directory_lister.cc b/net/base/directory_lister.cc index 5f17511..621461f 100644 --- a/net/base/directory_lister.cc +++ b/net/base/directory_lister.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -96,7 +96,7 @@ void DirectoryLister::ThreadMain() { DirectoryDataEvent* e = new DirectoryDataEvent(this); if (!file_util::DirectoryExists(dir_)) { - e->error = net::ERR_FILE_NOT_FOUND; + e->error = ERR_FILE_NOT_FOUND; message_loop_->PostTask(FROM_HERE, e); Release(); return; @@ -230,7 +230,7 @@ void DirectoryLister::OnDone(int error) { // If canceled is set, we need to report some kind of error, // but don't overwrite the error condition if it is already set. if (!error && canceled_.IsSet()) - error = net::ERR_ABORTED; + error = ERR_ABORTED; if (delegate_) delegate_->OnListDone(error); diff --git a/net/base/directory_lister.h b/net/base/directory_lister.h index 26ac0d7..b0e524f 100644 --- a/net/base/directory_lister.h +++ b/net/base/directory_lister.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -74,7 +74,7 @@ class DirectoryLister : public base::RefCountedThreadSafe<DirectoryLister>, // Call this method to asynchronously stop directory enumeration. The // delegate will receive the OnListDone notification with an error code of - // net::ERR_ABORTED. + // ERR_ABORTED. void Cancel(); // The delegate pointer may be modified at any time. diff --git a/net/base/directory_lister_unittest.cc b/net/base/directory_lister_unittest.cc index 5607bc5..91c8224 100644 --- a/net/base/directory_lister_unittest.cc +++ b/net/base/directory_lister_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -12,15 +12,13 @@ #include "net/base/net_errors.h" #include "testing/gtest/include/gtest/gtest.h" -namespace { -class DirectoryListerTest : public testing::Test {}; -} +namespace net { -class ListerDelegate : public net::DirectoryLister::DirectoryListerDelegate { +class ListerDelegate : public DirectoryLister::DirectoryListerDelegate { public: explicit ListerDelegate(bool recursive) : error_(-1), recursive_(recursive) { } - void OnListFile(const net::DirectoryLister::DirectoryListerData& data) { + void OnListFile(const DirectoryLister::DirectoryListerData& data) { file_list_.push_back(data.info); paths_.push_back(data.path); } @@ -77,14 +75,14 @@ TEST(DirectoryListerTest, BigDirTest) { ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &path)); ListerDelegate delegate(false); - scoped_refptr<net::DirectoryLister> lister( - new net::DirectoryLister(path, &delegate)); + scoped_refptr<DirectoryLister> lister( + new DirectoryLister(path, &delegate)); lister->Start(); MessageLoop::current()->Run(); - EXPECT_EQ(delegate.error(), net::OK); + EXPECT_EQ(delegate.error(), OK); } TEST(DirectoryListerTest, BigDirRecursiveTest) { @@ -92,17 +90,14 @@ TEST(DirectoryListerTest, BigDirRecursiveTest) { ASSERT_TRUE(PathService::Get(base::DIR_EXE, &path)); ListerDelegate delegate(true); - scoped_refptr<net::DirectoryLister> lister( - new net::DirectoryLister(path, - true, - net::DirectoryLister::FULL_PATH, - &delegate)); + scoped_refptr<DirectoryLister> lister( + new DirectoryLister(path, true, DirectoryLister::FULL_PATH, &delegate)); lister->Start(); MessageLoop::current()->Run(); - EXPECT_EQ(delegate.error(), net::OK); + EXPECT_EQ(delegate.error(), OK); } TEST(DirectoryListerTest, CancelTest) { @@ -110,13 +105,15 @@ TEST(DirectoryListerTest, CancelTest) { ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &path)); ListerDelegate delegate(false); - scoped_refptr<net::DirectoryLister> lister( - new net::DirectoryLister(path, &delegate)); + scoped_refptr<DirectoryLister> lister( + new DirectoryLister(path, &delegate)); lister->Start(); lister->Cancel(); MessageLoop::current()->Run(); - EXPECT_EQ(delegate.error(), net::ERR_ABORTED); + EXPECT_EQ(delegate.error(), ERR_ABORTED); } + +} // namespace net diff --git a/net/base/dnssec_unittest.cc b/net/base/dnssec_unittest.cc index f95c771..6d19057 100644 --- a/net/base/dnssec_unittest.cc +++ b/net/base/dnssec_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -9,15 +9,7 @@ #include "net/base/dnssec_keyset.h" #include "testing/gtest/include/gtest/gtest.h" -namespace { - -class SignatureVerifierDNSSECTest : public testing::Test { -}; - -class DNSSECChainVerifierTest : public testing::Test { -}; - -} // anonymous namespace +namespace net { // This is a DNSKEY record. You can get one with `dig dnskey .` (where '.' can // be any signed zone). @@ -46,14 +38,14 @@ static const unsigned char kExampleKey[] = { }; TEST(SignatureVerifierDNSSECTest, KeyID) { - uint16 keyid = net::DNSSECKeySet::DNSKEYToKeyID( + uint16 keyid = DNSSECKeySet::DNSKEYToKeyID( base::StringPiece(reinterpret_cast<const char*>(kExampleKey), sizeof(kExampleKey))); ASSERT_EQ(19036u, keyid); } TEST(SignatureVerifierDNSSECTest, ImportKey) { - net::DNSSECKeySet keyset; + DNSSECKeySet keyset; ASSERT_TRUE(keyset.AddKey( base::StringPiece(reinterpret_cast<const char*>(kExampleKey), @@ -118,7 +110,7 @@ static const unsigned char kRRDATA2[] = { }; TEST(SignatureVerifierDNSSECTest, VerifySignature) { - net::DNSSECKeySet keyset; + DNSSECKeySet keyset; ASSERT_TRUE(keyset.AddKey( base::StringPiece(reinterpret_cast<const char*>(kExampleKey), @@ -140,7 +132,7 @@ TEST(SignatureVerifierDNSSECTest, VerifySignature) { static std::string FromDNSName(const char* name) { std::string result; - bool ok = net::DNSDomainFromDot(name, &result); + bool ok = DNSDomainFromDot(name, &result); EXPECT_TRUE(ok); if (!ok) result = ""; @@ -148,19 +140,19 @@ static std::string FromDNSName(const char* name) { } TEST(DNSSECChainVerifierTest, MatchingLabels) { - ASSERT_EQ(1u, net::DNSSECChainVerifier::MatchingLabels( + ASSERT_EQ(1u, DNSSECChainVerifier::MatchingLabels( FromDNSName(""), FromDNSName(""))); - ASSERT_EQ(2u, net::DNSSECChainVerifier::MatchingLabels( + ASSERT_EQ(2u, DNSSECChainVerifier::MatchingLabels( FromDNSName("org"), FromDNSName("org"))); - ASSERT_EQ(3u, net::DNSSECChainVerifier::MatchingLabels( + ASSERT_EQ(3u, DNSSECChainVerifier::MatchingLabels( FromDNSName("foo.org"), FromDNSName("foo.org"))); - ASSERT_EQ(3u, net::DNSSECChainVerifier::MatchingLabels( + ASSERT_EQ(3u, DNSSECChainVerifier::MatchingLabels( FromDNSName("bar.foo.org"), FromDNSName("foo.org"))); - ASSERT_EQ(3u, net::DNSSECChainVerifier::MatchingLabels( + ASSERT_EQ(3u, DNSSECChainVerifier::MatchingLabels( FromDNSName("foo.org"), FromDNSName("bar.foo.org"))); - ASSERT_EQ(1u, net::DNSSECChainVerifier::MatchingLabels( + ASSERT_EQ(1u, DNSSECChainVerifier::MatchingLabels( FromDNSName("foo.org"), FromDNSName("foo.com"))); - ASSERT_EQ(2u, net::DNSSECChainVerifier::MatchingLabels( + ASSERT_EQ(2u, DNSSECChainVerifier::MatchingLabels( FromDNSName("foo.org"), FromDNSName("bar.org"))); } @@ -558,35 +550,35 @@ static const unsigned char kCNAMEChain[] = { TEST(DNSSECChainVerifierTest, TestChain) { base::StringPiece chain(reinterpret_cast<const char*>(kChain), sizeof(kChain)); - net::DNSSECChainVerifier verifier(FromDNSName("dnssec-exp.org"), chain); + DNSSECChainVerifier verifier(FromDNSName("dnssec-exp.org"), chain); verifier.IgnoreTimestamps(); - ASSERT_EQ(net::DNSSECChainVerifier::OK, verifier.Verify()); - ASSERT_EQ(net::kDNS_CERT, verifier.rrtype()); + ASSERT_EQ(DNSSECChainVerifier::OK, verifier.Verify()); + ASSERT_EQ(kDNS_CERT, verifier.rrtype()); } TEST(DNSSECChainVerifierTest, OffCourse) { base::StringPiece chain(reinterpret_cast<const char*>(kChain), sizeof(kChain)); - net::DNSSECChainVerifier verifier(FromDNSName("foo.org"), chain); + DNSSECChainVerifier verifier(FromDNSName("foo.org"), chain); verifier.IgnoreTimestamps(); - ASSERT_EQ(net::DNSSECChainVerifier::OFF_COURSE, verifier.Verify()); + ASSERT_EQ(DNSSECChainVerifier::OFF_COURSE, verifier.Verify()); } TEST(DNSSECChainVerifierTest, BadTarget) { base::StringPiece chain(reinterpret_cast<const char*>(kChain), sizeof(kChain)); - net::DNSSECChainVerifier verifier(FromDNSName("www.dnssec-exp.org"), chain); + DNSSECChainVerifier verifier(FromDNSName("www.dnssec-exp.org"), chain); verifier.IgnoreTimestamps(); - ASSERT_EQ(net::DNSSECChainVerifier::BAD_TARGET, verifier.Verify()); + ASSERT_EQ(DNSSECChainVerifier::BAD_TARGET, verifier.Verify()); } TEST(DNSSECChainVerifierTest, TestCNAMEChain) { base::StringPiece chain(reinterpret_cast<const char*>(kCNAMEChain), sizeof(kCNAMEChain)); - net::DNSSECChainVerifier verifier(FromDNSName("www.dnssec-exp.org"), chain); + DNSSECChainVerifier verifier(FromDNSName("www.dnssec-exp.org"), chain); verifier.IgnoreTimestamps(); - ASSERT_EQ(net::DNSSECChainVerifier::OK, verifier.Verify()); - ASSERT_EQ(net::kDNS_TXT, verifier.rrtype()); + ASSERT_EQ(DNSSECChainVerifier::OK, verifier.Verify()); + ASSERT_EQ(kDNS_TXT, verifier.rrtype()); } // This is too slow to run all the time. @@ -602,9 +594,9 @@ TEST(DNSSECChainVerifierTest, DISABLED_Fuzz) { unsigned bit = bit_to_flip & 7; copy[byte] ^= (1 << bit); - net::DNSSECChainVerifier verifier(FromDNSName("dnssec-exp.org"), chain); + DNSSECChainVerifier verifier(FromDNSName("dnssec-exp.org"), chain); verifier.IgnoreTimestamps(); - ASSERT_NE(net::DNSSECChainVerifier::OK, verifier.Verify()); + ASSERT_NE(DNSSECChainVerifier::OK, verifier.Verify()); } } @@ -631,10 +623,10 @@ TEST(DNSSECChainVerifierTest, BadTXT) { for (unsigned i = 0; i < arraysize(kBadTXTRecords); i++) { std::string wrapped(StringToTXTRecord(kBadTXTRecords[i])); - EXPECT_TRUE(net::DNSSECChainVerifier::ParseTLSTXTRecord(wrapped).empty()); + EXPECT_TRUE(DNSSECChainVerifier::ParseTLSTXTRecord(wrapped).empty()); } - EXPECT_TRUE(net::DNSSECChainVerifier::ParseTLSTXTRecord( + EXPECT_TRUE(DNSSECChainVerifier::ParseTLSTXTRecord( std::string("a=b\0", 4)).empty()); } @@ -685,10 +677,12 @@ TEST(DNSSECChainVerifierTest, GoodTXT) { for (unsigned i = 0; kTXTRecords[i]; i++) { std::string wrapped(StringToTXTRecord(kTXTRecords[i])); std::map<std::string, std::string> m( - net::DNSSECChainVerifier::ParseTLSTXTRecord(wrapped)); + DNSSECChainVerifier::ParseTLSTXTRecord(wrapped)); ASSERT_FALSE(m.empty()); ASSERT_TRUE(MatchMap(m, &kTXTRecords[i+1])); while (kTXTRecords[i]) i++; } } + +} // namespace net diff --git a/net/base/file_stream_posix.cc b/net/base/file_stream_posix.cc index 2e0dac1..e960267 100644 --- a/net/base/file_stream_posix.cc +++ b/net/base/file_stream_posix.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -27,15 +27,16 @@ #include "base/synchronization/waitable_event.h" #include "net/base/net_errors.h" +namespace net { + // We cast back and forth, so make sure it's the size we're expecting. COMPILE_ASSERT(sizeof(int64) == sizeof(off_t), off_t_64_bit); // Make sure our Whence mappings match the system headers. -COMPILE_ASSERT(net::FROM_BEGIN == SEEK_SET && - net::FROM_CURRENT == SEEK_CUR && - net::FROM_END == SEEK_END, whence_matches_system); +COMPILE_ASSERT(FROM_BEGIN == SEEK_SET && + FROM_CURRENT == SEEK_CUR && + FROM_END == SEEK_END, whence_matches_system); -namespace net { namespace { // Map from errno to net error codes. diff --git a/net/base/file_stream_unittest.cc b/net/base/file_stream_unittest.cc index 7c2ef50..82aaa24 100644 --- a/net/base/file_stream_unittest.cc +++ b/net/base/file_stream_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -13,6 +13,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" +namespace net { namespace { const char kTestData[] = "0123456789"; @@ -37,10 +38,10 @@ class FileStreamTest : public PlatformTest { }; TEST_F(FileStreamTest, BasicOpenClose) { - net::FileStream stream; + FileStream stream; int rv = stream.Open(temp_file_path(), base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); } // Test the use of FileStream with a file handle provided at construction. @@ -55,8 +56,8 @@ TEST_F(FileStreamTest, UseFileHandle) { temp_file_path(), flags, &created, NULL); // Seek to the beginning of the file and read. - net::FileStream read_stream(file, flags); - ASSERT_EQ(0, read_stream.Seek(net::FROM_BEGIN, 0)); + FileStream read_stream(file, flags); + ASSERT_EQ(0, read_stream.Seek(FROM_BEGIN, 0)); ASSERT_EQ(kTestDataSize, read_stream.Available()); // Read into buffer and compare. char buffer[kTestDataSize]; @@ -69,8 +70,8 @@ TEST_F(FileStreamTest, UseFileHandle) { flags = base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE; file = base::CreatePlatformFile(temp_file_path(), flags, &created, NULL); - net::FileStream write_stream(file, flags); - ASSERT_EQ(0, write_stream.Seek(net::FROM_BEGIN, 0)); + FileStream write_stream(file, flags); + ASSERT_EQ(0, write_stream.Seek(FROM_BEGIN, 0)); ASSERT_EQ(kTestDataSize, write_stream.Write(kTestData, kTestDataSize, NULL)); write_stream.Close(); @@ -81,22 +82,22 @@ TEST_F(FileStreamTest, UseFileHandle) { } TEST_F(FileStreamTest, UseClosedStream) { - net::FileStream stream; + FileStream stream; EXPECT_FALSE(stream.IsOpen()); // Try seeking... - int64 new_offset = stream.Seek(net::FROM_BEGIN, 5); - EXPECT_EQ(net::ERR_UNEXPECTED, new_offset); + int64 new_offset = stream.Seek(FROM_BEGIN, 5); + EXPECT_EQ(ERR_UNEXPECTED, new_offset); // Try available... int64 avail = stream.Available(); - EXPECT_EQ(net::ERR_UNEXPECTED, avail); + EXPECT_EQ(ERR_UNEXPECTED, avail); // Try reading... char buf[10]; int rv = stream.Read(buf, arraysize(buf), NULL); - EXPECT_EQ(net::ERR_UNEXPECTED, rv); + EXPECT_EQ(ERR_UNEXPECTED, rv); } TEST_F(FileStreamTest, BasicRead) { @@ -104,11 +105,11 @@ TEST_F(FileStreamTest, BasicRead) { bool ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); EXPECT_EQ(file_size, total_bytes_avail); @@ -134,12 +135,12 @@ TEST_F(FileStreamTest, AsyncRead) { bool ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_ASYNC; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); EXPECT_EQ(file_size, total_bytes_avail); @@ -152,7 +153,7 @@ TEST_F(FileStreamTest, AsyncRead) { for (;;) { char buf[4]; rv = stream.Read(buf, arraysize(buf), &callback); - if (rv == net::ERR_IO_PENDING) + if (rv == ERR_IO_PENDING) rv = callback.WaitForResult(); EXPECT_LE(0, rv); if (rv <= 0) @@ -169,12 +170,12 @@ TEST_F(FileStreamTest, AsyncRead_EarlyClose) { bool ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_ASYNC; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); EXPECT_EQ(file_size, total_bytes_avail); @@ -185,7 +186,7 @@ TEST_F(FileStreamTest, AsyncRead_EarlyClose) { rv = stream.Read(buf, arraysize(buf), &callback); stream.Close(); if (rv < 0) { - EXPECT_EQ(net::ERR_IO_PENDING, rv); + EXPECT_EQ(ERR_IO_PENDING, rv); // The callback should not be called if the request is cancelled. MessageLoop::current()->RunAllPending(); EXPECT_FALSE(callback.have_result()); @@ -199,14 +200,14 @@ TEST_F(FileStreamTest, BasicRead_FromOffset) { bool ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); const int64 kOffset = 3; - int64 new_offset = stream.Seek(net::FROM_BEGIN, kOffset); + int64 new_offset = stream.Seek(FROM_BEGIN, kOffset); EXPECT_EQ(kOffset, new_offset); int64 total_bytes_avail = stream.Available(); @@ -234,15 +235,15 @@ TEST_F(FileStreamTest, AsyncRead_FromOffset) { bool ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_ASYNC; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); const int64 kOffset = 3; - int64 new_offset = stream.Seek(net::FROM_BEGIN, kOffset); + int64 new_offset = stream.Seek(FROM_BEGIN, kOffset); EXPECT_EQ(kOffset, new_offset); int64 total_bytes_avail = stream.Available(); @@ -256,7 +257,7 @@ TEST_F(FileStreamTest, AsyncRead_FromOffset) { for (;;) { char buf[4]; rv = stream.Read(buf, arraysize(buf), &callback); - if (rv == net::ERR_IO_PENDING) + if (rv == ERR_IO_PENDING) rv = callback.WaitForResult(); EXPECT_LE(0, rv); if (rv <= 0) @@ -269,34 +270,34 @@ TEST_F(FileStreamTest, AsyncRead_FromOffset) { } TEST_F(FileStreamTest, SeekAround) { - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); const int64 kOffset = 3; - int64 new_offset = stream.Seek(net::FROM_BEGIN, kOffset); + int64 new_offset = stream.Seek(FROM_BEGIN, kOffset); EXPECT_EQ(kOffset, new_offset); - new_offset = stream.Seek(net::FROM_CURRENT, kOffset); + new_offset = stream.Seek(FROM_CURRENT, kOffset); EXPECT_EQ(2 * kOffset, new_offset); - new_offset = stream.Seek(net::FROM_CURRENT, -kOffset); + new_offset = stream.Seek(FROM_CURRENT, -kOffset); EXPECT_EQ(kOffset, new_offset); const int kTestDataLen = arraysize(kTestData) - 1; - new_offset = stream.Seek(net::FROM_END, -kTestDataLen); + new_offset = stream.Seek(FROM_END, -kTestDataLen); EXPECT_EQ(0, new_offset); } TEST_F(FileStreamTest, BasicWrite) { - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); int64 file_size; bool ok = file_util::GetFileSize(temp_file_path(), &file_size); @@ -313,12 +314,12 @@ TEST_F(FileStreamTest, BasicWrite) { } TEST_F(FileStreamTest, AsyncWrite) { - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); int64 file_size; bool ok = file_util::GetFileSize(temp_file_path(), &file_size); @@ -332,7 +333,7 @@ TEST_F(FileStreamTest, AsyncWrite) { rv = stream.Write(kTestData + total_bytes_written, kTestDataSize - total_bytes_written, &callback); - if (rv == net::ERR_IO_PENDING) + if (rv == ERR_IO_PENDING) rv = callback.WaitForResult(); EXPECT_LT(0, rv); if (rv <= 0) @@ -345,12 +346,12 @@ TEST_F(FileStreamTest, AsyncWrite) { } TEST_F(FileStreamTest, AsyncWrite_EarlyClose) { - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); int64 file_size; bool ok = file_util::GetFileSize(temp_file_path(), &file_size); @@ -365,7 +366,7 @@ TEST_F(FileStreamTest, AsyncWrite_EarlyClose) { &callback); stream.Close(); if (rv < 0) { - EXPECT_EQ(net::ERR_IO_PENDING, rv); + EXPECT_EQ(ERR_IO_PENDING, rv); // The callback should not be called if the request is cancelled. MessageLoop::current()->RunAllPending(); EXPECT_FALSE(callback.have_result()); @@ -377,11 +378,11 @@ TEST_F(FileStreamTest, AsyncWrite_EarlyClose) { } TEST_F(FileStreamTest, BasicWrite_FromOffset) { - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); int64 file_size; bool ok = file_util::GetFileSize(temp_file_path(), &file_size); @@ -389,7 +390,7 @@ TEST_F(FileStreamTest, BasicWrite_FromOffset) { EXPECT_EQ(kTestDataSize, file_size); const int64 kOffset = 0; - int64 new_offset = stream.Seek(net::FROM_END, kOffset); + int64 new_offset = stream.Seek(FROM_END, kOffset); EXPECT_EQ(kTestDataSize, new_offset); rv = stream.Write(kTestData, kTestDataSize, NULL); @@ -406,15 +407,15 @@ TEST_F(FileStreamTest, AsyncWrite_FromOffset) { bool ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); const int64 kOffset = 0; - int64 new_offset = stream.Seek(net::FROM_END, kOffset); + int64 new_offset = stream.Seek(FROM_END, kOffset); EXPECT_EQ(kTestDataSize, new_offset); TestCompletionCallback callback; @@ -424,7 +425,7 @@ TEST_F(FileStreamTest, AsyncWrite_FromOffset) { rv = stream.Write(kTestData + total_bytes_written, kTestDataSize - total_bytes_written, &callback); - if (rv == net::ERR_IO_PENDING) + if (rv == ERR_IO_PENDING) rv = callback.WaitForResult(); EXPECT_LT(0, rv); if (rv <= 0) @@ -441,12 +442,12 @@ TEST_F(FileStreamTest, BasicReadWrite) { bool ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); EXPECT_EQ(file_size, total_bytes_avail); @@ -480,23 +481,23 @@ TEST_F(FileStreamTest, BasicWriteRead) { bool ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); EXPECT_EQ(file_size, total_bytes_avail); - int64 offset = stream.Seek(net::FROM_END, 0); + int64 offset = stream.Seek(FROM_END, 0); EXPECT_EQ(offset, file_size); rv = stream.Write(kTestData, kTestDataSize, NULL); EXPECT_EQ(kTestDataSize, rv); - offset = stream.Seek(net::FROM_BEGIN, 0); + offset = stream.Seek(FROM_BEGIN, 0); EXPECT_EQ(0, offset); int64 total_bytes_read = 0; @@ -528,13 +529,13 @@ TEST_F(FileStreamTest, BasicAsyncReadWrite) { bool ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); EXPECT_EQ(file_size, total_bytes_avail); @@ -546,7 +547,7 @@ TEST_F(FileStreamTest, BasicAsyncReadWrite) { for (;;) { char buf[4]; rv = stream.Read(buf, arraysize(buf), &callback); - if (rv == net::ERR_IO_PENDING) + if (rv == ERR_IO_PENDING) rv = callback.WaitForResult(); EXPECT_LE(0, rv); if (rv <= 0) @@ -563,7 +564,7 @@ TEST_F(FileStreamTest, BasicAsyncReadWrite) { rv = stream.Write(kTestData + total_bytes_written, kTestDataSize - total_bytes_written, &callback); - if (rv == net::ERR_IO_PENDING) + if (rv == ERR_IO_PENDING) rv = callback.WaitForResult(); EXPECT_LT(0, rv); if (rv <= 0) @@ -583,18 +584,18 @@ TEST_F(FileStreamTest, BasicAsyncWriteRead) { bool ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); EXPECT_EQ(file_size, total_bytes_avail); - int64 offset = stream.Seek(net::FROM_END, 0); + int64 offset = stream.Seek(FROM_END, 0); EXPECT_EQ(offset, file_size); TestCompletionCallback callback; @@ -604,7 +605,7 @@ TEST_F(FileStreamTest, BasicAsyncWriteRead) { rv = stream.Write(kTestData + total_bytes_written, kTestDataSize - total_bytes_written, &callback); - if (rv == net::ERR_IO_PENDING) + if (rv == ERR_IO_PENDING) rv = callback.WaitForResult(); EXPECT_LT(0, rv); if (rv <= 0) @@ -614,7 +615,7 @@ TEST_F(FileStreamTest, BasicAsyncWriteRead) { EXPECT_EQ(kTestDataSize, total_bytes_written); - offset = stream.Seek(net::FROM_BEGIN, 0); + offset = stream.Seek(FROM_BEGIN, 0); EXPECT_EQ(0, offset); int total_bytes_read = 0; @@ -623,7 +624,7 @@ TEST_F(FileStreamTest, BasicAsyncWriteRead) { for (;;) { char buf[4]; rv = stream.Read(buf, arraysize(buf), &callback); - if (rv == net::ERR_IO_PENDING) + if (rv == ERR_IO_PENDING) rv = callback.WaitForResult(); EXPECT_LE(0, rv); if (rv <= 0) @@ -646,7 +647,7 @@ TEST_F(FileStreamTest, BasicAsyncWriteRead) { class TestWriteReadCompletionCallback : public Callback1<int>::Type { public: explicit TestWriteReadCompletionCallback( - net::FileStream* stream, + FileStream* stream, int* total_bytes_written, int* total_bytes_read, std::string* data_read) @@ -685,19 +686,19 @@ class TestWriteReadCompletionCallback : public Callback1<int>::Type { rv = stream_->Write(kTestData + *total_bytes_written_, kTestDataSize - *total_bytes_written_, &callback); - DCHECK_EQ(net::ERR_IO_PENDING, rv); + DCHECK_EQ(ERR_IO_PENDING, rv); rv = callback.WaitForResult(); *total_bytes_written_ += total_bytes_written; *total_bytes_read_ += total_bytes_read; *data_read_ += data_read; } else { // We're done writing all data. Start reading the data. - stream_->Seek(net::FROM_BEGIN, 0); + stream_->Seek(FROM_BEGIN, 0); TestCompletionCallback callback; for (;;) { char buf[4]; rv = stream_->Read(buf, arraysize(buf), &callback); - if (rv == net::ERR_IO_PENDING) { + if (rv == ERR_IO_PENDING) { bool old_state = MessageLoop::current()->NestableTasksAllowed(); MessageLoop::current()->SetNestableTasksAllowed(true); rv = callback.WaitForResult(); @@ -720,7 +721,7 @@ class TestWriteReadCompletionCallback : public Callback1<int>::Type { int result_; bool have_result_; bool waiting_for_result_; - net::FileStream* stream_; + FileStream* stream_; int* total_bytes_written_; int* total_bytes_read_; std::string* data_read_; @@ -733,18 +734,18 @@ TEST_F(FileStreamTest, AsyncWriteRead) { bool ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); EXPECT_EQ(file_size, total_bytes_avail); - int64 offset = stream.Seek(net::FROM_END, 0); + int64 offset = stream.Seek(FROM_END, 0); EXPECT_EQ(offset, file_size); int total_bytes_written = 0; @@ -756,7 +757,7 @@ TEST_F(FileStreamTest, AsyncWriteRead) { rv = stream.Write(kTestData + total_bytes_written, kTestDataSize - static_cast<int>(total_bytes_written), &callback); - if (rv == net::ERR_IO_PENDING) + if (rv == ERR_IO_PENDING) rv = callback.WaitForResult(); EXPECT_LT(0, rv); EXPECT_EQ(kTestDataSize, total_bytes_written); @@ -775,7 +776,7 @@ TEST_F(FileStreamTest, AsyncWriteRead) { class TestWriteCloseCompletionCallback : public Callback1<int>::Type { public: - explicit TestWriteCloseCompletionCallback(net::FileStream* stream, + explicit TestWriteCloseCompletionCallback(FileStream* stream, int* total_bytes_written) : result_(0), have_result_(false), @@ -808,7 +809,7 @@ class TestWriteCloseCompletionCallback : public Callback1<int>::Type { rv = stream_->Write(kTestData + *total_bytes_written_, kTestDataSize - *total_bytes_written_, &callback); - DCHECK_EQ(net::ERR_IO_PENDING, rv); + DCHECK_EQ(ERR_IO_PENDING, rv); rv = callback.WaitForResult(); *total_bytes_written_ += total_bytes_written; } else { // We're done writing all data. Close the file. @@ -824,7 +825,7 @@ class TestWriteCloseCompletionCallback : public Callback1<int>::Type { int result_; bool have_result_; bool waiting_for_result_; - net::FileStream* stream_; + FileStream* stream_; int* total_bytes_written_; DISALLOW_COPY_AND_ASSIGN(TestWriteCloseCompletionCallback); @@ -835,25 +836,25 @@ TEST_F(FileStreamTest, AsyncWriteClose) { bool ok = file_util::GetFileSize(temp_file_path(), &file_size); EXPECT_TRUE(ok); - net::FileStream stream; + FileStream stream; int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC; int rv = stream.Open(temp_file_path(), flags); - EXPECT_EQ(net::OK, rv); + EXPECT_EQ(OK, rv); int64 total_bytes_avail = stream.Available(); EXPECT_EQ(file_size, total_bytes_avail); - int64 offset = stream.Seek(net::FROM_END, 0); + int64 offset = stream.Seek(FROM_END, 0); EXPECT_EQ(offset, file_size); int total_bytes_written = 0; TestWriteCloseCompletionCallback callback(&stream, &total_bytes_written); rv = stream.Write(kTestData, kTestDataSize, &callback); - if (rv == net::ERR_IO_PENDING) + if (rv == ERR_IO_PENDING) total_bytes_written = callback.WaitForResult(); EXPECT_LT(0, total_bytes_written); EXPECT_EQ(kTestDataSize, total_bytes_written); @@ -867,8 +868,8 @@ TEST_F(FileStreamTest, AsyncWriteClose) { TEST_F(FileStreamTest, Truncate) { int flags = base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE; - net::FileStream write_stream; - ASSERT_EQ(net::OK, write_stream.Open(temp_file_path(), flags)); + FileStream write_stream; + ASSERT_EQ(OK, write_stream.Open(temp_file_path(), flags)); // Write some data to the file. const char test_data[] = "0123456789"; @@ -891,3 +892,4 @@ TEST_F(FileStreamTest, Truncate) { } } // namespace +} // namespace net diff --git a/net/base/filter.cc b/net/base/filter.cc index e1f7986..eb8a2c5 100644 --- a/net/base/filter.cc +++ b/net/base/filter.cc @@ -200,7 +200,7 @@ void Filter::FixupEncodingTypes( // download it, and in that case, don't decompress .gz/.tgz files. if ((EndsWith(extension, FILE_PATH_LITERAL(".gz"), false) || LowerCaseEqualsASCII(extension, ".tgz")) && - !net::IsSupportedMimeType(mime_type)) + !IsSupportedMimeType(mime_type)) encoding_types->clear(); } } @@ -210,13 +210,13 @@ void Filter::FixupEncodingTypes( // It was not an SDCH request, so we'll just record stats. if (1 < encoding_types->size()) { // Multiple filters were intended to only be used for SDCH (thus far!) - net::SdchManager::SdchErrorRecovery( - net::SdchManager::MULTIENCODING_FOR_NON_SDCH_REQUEST); + SdchManager::SdchErrorRecovery( + SdchManager::MULTIENCODING_FOR_NON_SDCH_REQUEST); } if ((1 == encoding_types->size()) && (FILTER_TYPE_SDCH == encoding_types->front())) { - net::SdchManager::SdchErrorRecovery( - net::SdchManager::SDCH_CONTENT_ENCODE_FOR_NON_SDCH_REQUEST); + SdchManager::SdchErrorRecovery( + SdchManager::SDCH_CONTENT_ENCODE_FOR_NON_SDCH_REQUEST); } return; } @@ -236,8 +236,8 @@ void Filter::FixupEncodingTypes( // no-op pass through filter if it doesn't get gzip headers where expected. if (1 == encoding_types->size()) { encoding_types->push_back(FILTER_TYPE_GZIP_HELPING_SDCH); - net::SdchManager::SdchErrorRecovery( - net::SdchManager::OPTIONAL_GUNZIP_ENCODING_ADDED); + SdchManager::SdchErrorRecovery( + SdchManager::OPTIONAL_GUNZIP_ENCODING_ADDED); } return; } @@ -271,14 +271,14 @@ void Filter::FixupEncodingTypes( // Suspicious case: Advertised dictionary, but server didn't use sdch, and // we're HTML tagged. if (encoding_types->empty()) { - net::SdchManager::SdchErrorRecovery( - net::SdchManager::ADDED_CONTENT_ENCODING); + SdchManager::SdchErrorRecovery( + SdchManager::ADDED_CONTENT_ENCODING); } else if (1 == encoding_types->size()) { - net::SdchManager::SdchErrorRecovery( - net::SdchManager::FIXED_CONTENT_ENCODING); + SdchManager::SdchErrorRecovery( + SdchManager::FIXED_CONTENT_ENCODING); } else { - net::SdchManager::SdchErrorRecovery( - net::SdchManager::FIXED_CONTENT_ENCODINGS); + SdchManager::SdchErrorRecovery( + SdchManager::FIXED_CONTENT_ENCODINGS); } } else { // Remarkable case!?! We advertised an SDCH dictionary, content-encoding @@ -290,14 +290,14 @@ void Filter::FixupEncodingTypes( // start with "text/html" for some other reason?? We'll report this as a // fixup to a binary file, but it probably really is text/html (some how). if (encoding_types->empty()) { - net::SdchManager::SdchErrorRecovery( - net::SdchManager::BINARY_ADDED_CONTENT_ENCODING); + SdchManager::SdchErrorRecovery( + SdchManager::BINARY_ADDED_CONTENT_ENCODING); } else if (1 == encoding_types->size()) { - net::SdchManager::SdchErrorRecovery( - net::SdchManager::BINARY_FIXED_CONTENT_ENCODING); + SdchManager::SdchErrorRecovery( + SdchManager::BINARY_FIXED_CONTENT_ENCODING); } else { - net::SdchManager::SdchErrorRecovery( - net::SdchManager::BINARY_FIXED_CONTENT_ENCODINGS); + SdchManager::SdchErrorRecovery( + SdchManager::BINARY_FIXED_CONTENT_ENCODINGS); } } @@ -392,12 +392,12 @@ Filter* Filter::PrependNewFilter(FilterType type_id, void Filter::InitBuffer(int buffer_size) { DCHECK(!stream_buffer()); DCHECK_GT(buffer_size, 0); - stream_buffer_ = new net::IOBuffer(buffer_size); + stream_buffer_ = new IOBuffer(buffer_size); stream_buffer_size_ = buffer_size; } void Filter::PushDataIntoNextFilter() { - net::IOBuffer* next_buffer = next_filter_->stream_buffer(); + IOBuffer* next_buffer = next_filter_->stream_buffer(); int next_size = next_filter_->stream_buffer_size(); last_status_ = ReadFilteredData(next_buffer->data(), &next_size); if (FILTER_ERROR != last_status_) diff --git a/net/base/filter.h b/net/base/filter.h index a85b00c..b158d59 100644 --- a/net/base/filter.h +++ b/net/base/filter.h @@ -158,7 +158,7 @@ class Filter { FilterStatus ReadData(char* dest_buffer, int* dest_len); // Returns a pointer to the stream_buffer_. - net::IOBuffer* stream_buffer() const { return stream_buffer_.get(); } + IOBuffer* stream_buffer() const { return stream_buffer_.get(); } // Returns the maximum size of stream_buffer_ in number of chars. int stream_buffer_size() const { return stream_buffer_size_; } @@ -221,7 +221,7 @@ class Filter { FilterStatus last_status() const { return last_status_; } // Buffer to hold the data to be filtered (the input queue). - scoped_refptr<net::IOBuffer> stream_buffer_; + scoped_refptr<IOBuffer> stream_buffer_; // Maximum size of stream_buffer_ in number of chars. int stream_buffer_size_; diff --git a/net/base/filter_unittest.cc b/net/base/filter_unittest.cc index 3bf7c94..73bde73 100644 --- a/net/base/filter_unittest.cc +++ b/net/base/filter_unittest.cc @@ -37,7 +37,7 @@ TEST(FilterTest, ContentTypeId) { // Check various fixups that modify content encoding lists. TEST(FilterTest, ApacheGzip) { - net::MockFilterContext filter_context; + MockFilterContext filter_context; filter_context.SetSdchResponse(false); // Check that redundant gzip mime type removes only solo gzip encoding. @@ -85,7 +85,7 @@ TEST(FilterTest, ApacheGzip) { TEST(FilterTest, SdchEncoding) { // Handle content encodings including SDCH. const std::string kTextHtmlMime("text/html"); - net::MockFilterContext filter_context; + MockFilterContext filter_context; filter_context.SetSdchResponse(true); std::vector<Filter::FilterType> encoding_types; @@ -122,7 +122,7 @@ TEST(FilterTest, SdchEncoding) { TEST(FilterTest, MissingSdchEncoding) { // Handle interesting case where entire SDCH encoding assertion "got lost." const std::string kTextHtmlMime("text/html"); - net::MockFilterContext filter_context; + MockFilterContext filter_context; filter_context.SetSdchResponse(true); std::vector<Filter::FilterType> encoding_types; @@ -157,7 +157,7 @@ TEST(FilterTest, MissingSdchEncoding) { } TEST(FilterTest, Svgz) { - net::MockFilterContext filter_context; + MockFilterContext filter_context; // Check that svgz files are only decompressed when not downloading. const std::string kSvgzMime("image/svg+xml"); @@ -205,7 +205,7 @@ TEST(FilterTest, Svgz) { TEST(FilterTest, UnsupportedMimeGzip) { // From issue 8170 - handling files with Content-Encoding: x-gzip - net::MockFilterContext filter_context; + MockFilterContext filter_context; std::vector<Filter::FilterType> encoding_types; const std::string kTarMime("application/x-tar"); const std::string kCpioMime("application/x-cpio"); @@ -292,7 +292,7 @@ TEST(FilterTest, UnsupportedMimeGzip) { TEST(FilterTest, SupportedMimeGzip) { // From issue 16430 - Files with supported mime types should be decompressed, // even though these files end in .gz/.tgz. - net::MockFilterContext filter_context; + MockFilterContext filter_context; std::vector<Filter::FilterType> encoding_types; const std::string kGzUrl("http://ignore.com/foo.gz"); const std::string kUrl("http://ignore.com/foo"); diff --git a/net/base/gzip_filter_unittest.cc b/net/base/gzip_filter_unittest.cc index 06b3da1..aaf3187 100644 --- a/net/base/gzip_filter_unittest.cc +++ b/net/base/gzip_filter_unittest.cc @@ -253,7 +253,7 @@ class GZipUnitTest : public PlatformTest { int gzip_encode_len_; private: - net::MockFilterContext filter_context_; + MockFilterContext filter_context_; }; // Basic scenario: decoding deflate data with big enough buffer. diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc index 592b03c..cd17c47 100644 --- a/net/base/host_resolver.cc +++ b/net/base/host_resolver.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -24,7 +24,7 @@ HostResolver::~HostResolver() { } AddressFamily HostResolver::GetDefaultAddressFamily() const { - return net::ADDRESS_FAMILY_UNSPECIFIED; + return ADDRESS_FAMILY_UNSPECIFIED; } HostResolverImpl* HostResolver::GetAsHostResolverImpl() { diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h index 6a97b46..da3816e 100644 --- a/net/base/host_resolver.h +++ b/net/base/host_resolver.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -230,7 +230,7 @@ class SingleRequestHostResolver { CompletionCallback* cur_request_callback_; // Completion callback for when request to |resolver_| completes. - net::CompletionCallbackImpl<SingleRequestHostResolver> callback_; + CompletionCallbackImpl<SingleRequestHostResolver> callback_; DISALLOW_COPY_AND_ASSIGN(SingleRequestHostResolver); }; diff --git a/net/base/host_resolver_impl_unittest.cc b/net/base/host_resolver_impl_unittest.cc index 8be87b6..01c32f7 100644 --- a/net/base/host_resolver_impl_unittest.cc +++ b/net/base/host_resolver_impl_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -271,7 +271,7 @@ TEST_F(HostResolverImplTest, SynchronousLookup) { int err = host_resolver->Resolve(info, &addrlist, NULL, NULL, log.bound()); EXPECT_EQ(OK, err); - net::CapturingNetLog::EntryList entries; + CapturingNetLog::EntryList entries; log.GetEntries(&entries); EXPECT_EQ(2u, entries.size()); @@ -307,7 +307,7 @@ TEST_F(HostResolverImplTest, AsynchronousLookup) { log.bound()); EXPECT_EQ(ERR_IO_PENDING, err); - net::CapturingNetLog::EntryList entries; + CapturingNetLog::EntryList entries; log.GetEntries(&entries); EXPECT_EQ(1u, entries.size()); @@ -364,7 +364,7 @@ TEST_F(HostResolverImplTest, CanceledAsynchronousLookup) { resolver_proc->Signal(); - net::CapturingNetLog::EntryList entries; + CapturingNetLog::EntryList entries; log.GetEntries(&entries); EXPECT_EQ(2u, entries.size()); @@ -373,30 +373,30 @@ TEST_F(HostResolverImplTest, CanceledAsynchronousLookup) { EXPECT_TRUE(LogContainsEndEvent( entries, 1, NetLog::TYPE_HOST_RESOLVER_IMPL)); - net::CapturingNetLog::EntryList net_log_entries; + CapturingNetLog::EntryList net_log_entries; net_log.GetEntries(&net_log_entries); - int pos = net::ExpectLogContainsSomewhereAfter(net_log_entries, 0, - net::NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST, - net::NetLog::PHASE_BEGIN); - pos = net::ExpectLogContainsSomewhereAfter(net_log_entries, pos + 1, - net::NetLog::TYPE_HOST_RESOLVER_IMPL_JOB, - net::NetLog::PHASE_BEGIN); + int pos = ExpectLogContainsSomewhereAfter(net_log_entries, 0, + NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST, + NetLog::PHASE_BEGIN); + pos = ExpectLogContainsSomewhereAfter(net_log_entries, pos + 1, + NetLog::TYPE_HOST_RESOLVER_IMPL_JOB, + NetLog::PHASE_BEGIN); // Both Job and Request need to be cancelled. - pos = net::ExpectLogContainsSomewhereAfter(net_log_entries, pos + 1, - net::NetLog::TYPE_CANCELLED, - net::NetLog::PHASE_NONE); + pos = ExpectLogContainsSomewhereAfter(net_log_entries, pos + 1, + NetLog::TYPE_CANCELLED, + NetLog::PHASE_NONE); // Don't care about order in which they end, or when the other one is // cancelled. - net::ExpectLogContainsSomewhereAfter(net_log_entries, pos + 1, - net::NetLog::TYPE_CANCELLED, - net::NetLog::PHASE_NONE); - net::ExpectLogContainsSomewhereAfter(net_log_entries, pos + 1, - net::NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST, - net::NetLog::PHASE_END); - net::ExpectLogContainsSomewhereAfter(net_log_entries, pos + 1, - net::NetLog::TYPE_HOST_RESOLVER_IMPL_JOB, - net::NetLog::PHASE_END); + ExpectLogContainsSomewhereAfter(net_log_entries, pos + 1, + NetLog::TYPE_CANCELLED, + NetLog::PHASE_NONE); + ExpectLogContainsSomewhereAfter(net_log_entries, pos + 1, + NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST, + NetLog::PHASE_END); + ExpectLogContainsSomewhereAfter(net_log_entries, pos + 1, + NetLog::TYPE_HOST_RESOLVER_IMPL_JOB, + NetLog::PHASE_END); EXPECT_FALSE(callback_called_); } @@ -957,7 +957,7 @@ TEST_F(HostResolverImplTest, Observers) { int rv = host_resolver->Resolve(info1, &addrlist, NULL, NULL, log.bound()); EXPECT_EQ(OK, rv); - net::CapturingNetLog::EntryList entries; + CapturingNetLog::EntryList entries; log.GetEntries(&entries); EXPECT_EQ(2u, entries.size()); diff --git a/net/base/load_flags_list.h b/net/base/load_flags_list.h index 25f6131..25b7948 100644 --- a/net/base/load_flags_list.h +++ b/net/base/load_flags_list.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -30,7 +30,7 @@ LOAD_FLAG(ONLY_FROM_CACHE, 1 << 3) LOAD_FLAG(DISABLE_CACHE, 1 << 4) // This is a navigation that will not be intercepted by any registered -// net::URLRequest::Interceptors. +// URLRequest::Interceptors. LOAD_FLAG(DISABLE_INTERCEPT, 1 << 5) // If present, upload progress messages should be provided to initiator. diff --git a/net/base/load_states.h b/net/base/load_states.h index 64b2a46..a3e5339 100644 --- a/net/base/load_states.h +++ b/net/base/load_states.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -13,7 +13,7 @@ namespace net { enum LoadState { // This is the default state. It corresponds to a resource load that has // either not yet begun or is idle waiting for the consumer to do something - // to move things along (e.g., the consumer of an net::URLRequest may not have + // to move things along (e.g., the consumer of an URLRequest may not have // called Read yet). LOAD_STATE_IDLE, @@ -65,7 +65,7 @@ enum LoadState { // read to complete. In the case of a HTTP transaction, this corresponds to // the period after the response headers have been received and before all of // the response body has been downloaded. (NOTE: This state only applies for - // an net::URLRequest while there is an outstanding Read operation.) + // an URLRequest while there is an outstanding Read operation.) LOAD_STATE_READING_RESPONSE, }; diff --git a/net/base/mime_sniffer_unittest.cc b/net/base/mime_sniffer_unittest.cc index d70cb23..a4bde0f 100644 --- a/net/base/mime_sniffer_unittest.cc +++ b/net/base/mime_sniffer_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -7,10 +7,7 @@ #include "net/base/mime_sniffer.h" #include "testing/gtest/include/gtest/gtest.h" -namespace { - class MimeSnifferTest : public testing::Test { - }; -} +namespace net { struct SnifferTest { const char* content; @@ -24,7 +21,7 @@ static void TestArray(SnifferTest* tests, size_t count) { std::string mime_type; for (size_t i = 0; i < count; ++i) { - net::SniffMimeType(tests[i].content, + SniffMimeType(tests[i].content, tests[i].content_len, GURL(tests[i].url), tests[i].type_hint, @@ -39,7 +36,7 @@ static std::string SniffMimeType(const std::string& content, const std::string& url, const std::string& mime_type_hint) { std::string mime_type; - net::SniffMimeType(content.data(), content.size(), GURL(url), + SniffMimeType(content.data(), content.size(), GURL(url), mime_type_hint, &mime_type); return mime_type; } @@ -54,11 +51,11 @@ TEST(MimeSnifferTest, BoundaryConditionsTest) { GURL url; - net::SniffMimeType(buf, 0, url, type_hint, &mime_type); + SniffMimeType(buf, 0, url, type_hint, &mime_type); EXPECT_EQ("text/plain", mime_type); - net::SniffMimeType(buf, 1, url, type_hint, &mime_type); + SniffMimeType(buf, 1, url, type_hint, &mime_type); EXPECT_EQ("text/plain", mime_type); - net::SniffMimeType(buf, 2, url, type_hint, &mime_type); + SniffMimeType(buf, 2, url, type_hint, &mime_type); EXPECT_EQ("application/octet-stream", mime_type); } @@ -372,8 +369,8 @@ TEST(MimeSnifferTest, XMLTestLargeNoAngledBracket) { // content.size() >= 1024 so the sniff is unambiguous. std::string mime_type; - EXPECT_TRUE(net::SniffMimeType(content.data(), content.size(), GURL(), - "text/xml", &mime_type)); + EXPECT_TRUE(SniffMimeType(content.data(), content.size(), GURL(), + "text/xml", &mime_type)); EXPECT_EQ("text/xml", mime_type); } @@ -388,7 +385,9 @@ TEST(MimeSnifferTest, LooksBinary) { // content.size() >= 1024 so the sniff is unambiguous. std::string mime_type; - EXPECT_TRUE(net::SniffMimeType(content.data(), content.size(), GURL(), - "text/plain", &mime_type)); + EXPECT_TRUE(SniffMimeType(content.data(), content.size(), GURL(), + "text/plain", &mime_type)); EXPECT_EQ("application/octet-stream", mime_type); } + +} // namespace net diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc index d95c029..988922e 100644 --- a/net/base/mime_util.cc +++ b/net/base/mime_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -633,7 +633,7 @@ void GetExtensionsHelper( base::hash_set<FilePath::StringType>* extensions) { FilePath::StringType extension; for (size_t i = 0; i < standard_types_len; ++i) { - if (net::GetPreferredExtensionForMimeType(standard_types[i], &extension)) + if (GetPreferredExtensionForMimeType(standard_types[i], &extension)) extensions->insert(extension); } @@ -695,7 +695,7 @@ void GetExtensionsForMimeType(const std::string& mime_type, std::vector<FilePath::StringType>* extensions) { base::hash_set<FilePath::StringType> unique_extensions; FilePath::StringType extension; - if (net::GetPreferredExtensionForMimeType(mime_type, &extension)) + if (GetPreferredExtensionForMimeType(mime_type, &extension)) unique_extensions.insert(extension); // Also look up the extensions from hard-coded mappings in case that some diff --git a/net/base/mime_util_unittest.cc b/net/base/mime_util_unittest.cc index d4f3a3f..a63c39e 100644 --- a/net/base/mime_util_unittest.cc +++ b/net/base/mime_util_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -6,10 +6,7 @@ #include "net/base/mime_util.h" #include "testing/gtest/include/gtest/gtest.h" -namespace { - class MimeUtilTest : public testing::Test { - }; -} +namespace net { TEST(MimeUtilTest, ExtensionTest) { const struct { @@ -28,7 +25,7 @@ TEST(MimeUtilTest, ExtensionTest) { bool rv; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - rv = net::GetMimeTypeFromExtension(tests[i].extension, &mime_type); + rv = GetMimeTypeFromExtension(tests[i].extension, &mime_type); EXPECT_EQ(tests[i].valid, rv); if (rv) EXPECT_EQ(tests[i].mime_type, mime_type); @@ -53,7 +50,7 @@ TEST(MimeUtilTest, FileTest) { bool rv; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - rv = net::GetMimeTypeFromFile(FilePath(tests[i].file_path), + rv = GetMimeTypeFromFile(FilePath(tests[i].file_path), &mime_type); EXPECT_EQ(tests[i].valid, rv); if (rv) @@ -62,35 +59,35 @@ TEST(MimeUtilTest, FileTest) { } TEST(MimeUtilTest, LookupTypes) { - EXPECT_TRUE(net::IsSupportedImageMimeType("image/jpeg")); - EXPECT_FALSE(net::IsSupportedImageMimeType("image/lolcat")); - EXPECT_TRUE(net::IsSupportedNonImageMimeType("text/html")); - EXPECT_FALSE(net::IsSupportedNonImageMimeType("text/virus")); + EXPECT_TRUE(IsSupportedImageMimeType("image/jpeg")); + EXPECT_FALSE(IsSupportedImageMimeType("image/lolcat")); + EXPECT_TRUE(IsSupportedNonImageMimeType("text/html")); + EXPECT_FALSE(IsSupportedNonImageMimeType("text/virus")); - EXPECT_TRUE(net::IsSupportedMimeType("image/jpeg")); - EXPECT_FALSE(net::IsSupportedMimeType("image/lolcat")); - EXPECT_TRUE(net::IsSupportedMimeType("text/html")); - EXPECT_FALSE(net::IsSupportedMimeType("text/virus")); + EXPECT_TRUE(IsSupportedMimeType("image/jpeg")); + EXPECT_FALSE(IsSupportedMimeType("image/lolcat")); + EXPECT_TRUE(IsSupportedMimeType("text/html")); + EXPECT_FALSE(IsSupportedMimeType("text/virus")); } TEST(MimeUtilTest, MatchesMimeType) { - EXPECT_TRUE(net::MatchesMimeType("*", "video/x-mpeg")); - EXPECT_TRUE(net::MatchesMimeType("video/*", "video/x-mpeg")); - EXPECT_TRUE(net::MatchesMimeType("video/x-mpeg", "video/x-mpeg")); - EXPECT_TRUE(net::MatchesMimeType("application/*+xml", + EXPECT_TRUE(MatchesMimeType("*", "video/x-mpeg")); + EXPECT_TRUE(MatchesMimeType("video/*", "video/x-mpeg")); + EXPECT_TRUE(MatchesMimeType("video/x-mpeg", "video/x-mpeg")); + EXPECT_TRUE(MatchesMimeType("application/*+xml", "application/html+xml")); - EXPECT_TRUE(net::MatchesMimeType("application/*+xml", "application/+xml")); - EXPECT_TRUE(net::MatchesMimeType("aaa*aaa", "aaaaaa")); - EXPECT_FALSE(net::MatchesMimeType("video/", "video/x-mpeg")); - EXPECT_FALSE(net::MatchesMimeType("", "video/x-mpeg")); - EXPECT_FALSE(net::MatchesMimeType("", "")); - EXPECT_FALSE(net::MatchesMimeType("video/x-mpeg", "")); - EXPECT_FALSE(net::MatchesMimeType("application/*+xml", "application/xml")); - EXPECT_FALSE(net::MatchesMimeType("application/*+xml", + EXPECT_TRUE(MatchesMimeType("application/*+xml", "application/+xml")); + EXPECT_TRUE(MatchesMimeType("aaa*aaa", "aaaaaa")); + EXPECT_FALSE(MatchesMimeType("video/", "video/x-mpeg")); + EXPECT_FALSE(MatchesMimeType("", "video/x-mpeg")); + EXPECT_FALSE(MatchesMimeType("", "")); + EXPECT_FALSE(MatchesMimeType("video/x-mpeg", "")); + EXPECT_FALSE(MatchesMimeType("application/*+xml", "application/xml")); + EXPECT_FALSE(MatchesMimeType("application/*+xml", "application/html+xmlz")); - EXPECT_FALSE(net::MatchesMimeType("application/*+xml", + EXPECT_FALSE(MatchesMimeType("application/*+xml", "applcation/html+xml")); - EXPECT_FALSE(net::MatchesMimeType("aaa*aaa", "aaaaa")); + EXPECT_FALSE(MatchesMimeType("aaa*aaa", "aaaaa")); } // Note: codecs should only be a list of 2 or fewer; hence the restriction of @@ -114,7 +111,7 @@ TEST(MimeUtilTest, ParseCodecString) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { std::vector<std::string> codecs_out; - net::ParseCodecString(tests[i].original, &codecs_out, true); + ParseCodecString(tests[i].original, &codecs_out, true); EXPECT_EQ(tests[i].expected_size, codecs_out.size()); for (size_t j = 0; j < tests[i].expected_size; ++j) { EXPECT_EQ(tests[i].results[j], codecs_out[j]); @@ -123,8 +120,10 @@ TEST(MimeUtilTest, ParseCodecString) { // Test without stripping the codec type. std::vector<std::string> codecs_out; - net::ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false); + ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false); EXPECT_EQ(2u, codecs_out.size()); EXPECT_STREQ("avc1.42E01E", codecs_out[0].c_str()); EXPECT_STREQ("mp4a.40.2", codecs_out[1].c_str()); } + +} // namespace net diff --git a/net/base/net_log.cc b/net/base/net_log.cc index 4484a8a0..0449634 100644 --- a/net/base/net_log.cc +++ b/net/base/net_log.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -71,11 +71,11 @@ const char* NetLog::EventPhaseToString(EventPhase phase) { } // static -Value* NetLog::EntryToDictionaryValue(net::NetLog::EventType type, +Value* NetLog::EntryToDictionaryValue(NetLog::EventType type, const base::TimeTicks& time, - const net::NetLog::Source& source, - net::NetLog::EventPhase phase, - net::NetLog::EventParameters* params, + const NetLog::Source& source, + NetLog::EventPhase phase, + NetLog::EventParameters* params, bool use_strings) { DictionaryValue* entry_dict = new DictionaryValue(); @@ -88,7 +88,7 @@ Value* NetLog::EntryToDictionaryValue(net::NetLog::EventType type, source_dict->SetInteger("type", static_cast<int>(source.type)); } else { source_dict->SetString("type", - net::NetLog::SourceTypeToString(source.type)); + NetLog::SourceTypeToString(source.type)); } entry_dict->Set("source", source_dict); @@ -97,8 +97,8 @@ Value* NetLog::EntryToDictionaryValue(net::NetLog::EventType type, entry_dict->SetInteger("type", static_cast<int>(type)); entry_dict->SetInteger("phase", static_cast<int>(phase)); } else { - entry_dict->SetString("type", net::NetLog::EventTypeToString(type)); - entry_dict->SetString("phase", net::NetLog::EventPhaseToString(phase)); + entry_dict->SetString("type", NetLog::EventTypeToString(type)); + entry_dict->SetString("phase", NetLog::EventPhaseToString(phase)); } // Set the event-specific parameters. @@ -147,7 +147,7 @@ void BoundNetLog::EndEvent( void BoundNetLog::EndEventWithNetErrorCode(NetLog::EventType event_type, int net_error) const { - DCHECK_NE(net_error, net::ERR_IO_PENDING); + DCHECK_NE(net_error, ERR_IO_PENDING); if (net_error >= 0) { EndEvent(event_type, NULL); } else { diff --git a/net/base/net_log.h b/net/base/net_log.h index eb88038..4946c76a 100644 --- a/net/base/net_log.h +++ b/net/base/net_log.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -22,7 +22,7 @@ namespace net { // NetLog is the destination for log messages generated by the network stack. // Each log message has a "source" field which identifies the specific entity -// that generated the message (for example, which net::URLRequest or which +// that generated the message (for example, which URLRequest or which // SocketStream). // // To avoid needing to pass in the "source id" to the logging functions, NetLog @@ -32,7 +32,7 @@ namespace net { // ******** The NetLog (and associated logging) is a work in progress ******** // // TODO(eroman): Remove the 'const' qualitifer from the BoundNetLog methods. -// TODO(eroman): Start a new Source each time net::URLRequest redirects +// TODO(eroman): Start a new Source each time URLRequest redirects // (simpler to reason about each as a separate entity). class NetLog { @@ -150,11 +150,11 @@ class NetLog { // Serializes the specified event to a DictionaryValue. // If |use_strings| is true, uses strings rather than numeric ids. - static Value* EntryToDictionaryValue(net::NetLog::EventType type, + static Value* EntryToDictionaryValue(NetLog::EventType type, const base::TimeTicks& time, - const net::NetLog::Source& source, - net::NetLog::EventPhase phase, - net::NetLog::EventParameters* params, + const NetLog::Source& source, + NetLog::EventPhase phase, + NetLog::EventParameters* params, bool use_strings); private: diff --git a/net/base/net_util.cc b/net/base/net_util.cc index 1a8aa89..a850eb8 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -764,7 +764,7 @@ std::wstring FormatUrlInternal(const GURL& url, // Helper for FormatUrl()/FormatUrlInternal(). std::wstring FormatViewSourceUrl(const GURL& url, const std::wstring& languages, - net::FormatUrlTypes format_types, + FormatUrlTypes format_types, UnescapeRule::Type unescape_rules, url_parse::Parsed* new_parsed, size_t* prefix_end, @@ -1645,7 +1645,7 @@ void GetIdentityFromURL(const GURL& url, } std::string GetHostOrSpecFromURL(const GURL& url) { - return url.has_host() ? net::TrimEndingDot(url.host()) : url.spec(); + return url.has_host() ? TrimEndingDot(url.host()) : url.spec(); } void AppendFormattedHost(const GURL& url, @@ -1675,7 +1675,7 @@ void AppendFormattedHost(const GURL& url, DCHECK(host.begin >= 0 && ((spec.length() == 0 && host.begin == 0) || host.begin < static_cast<int>(spec.length()))); - output->append(net::IDNToUnicode(&spec[host.begin], + output->append(IDNToUnicode(&spec[host.begin], static_cast<size_t>(host.len), languages, offset_into_host)); int new_host_len = static_cast<int>(output->length()) - new_host_begin; diff --git a/net/base/net_util.h b/net/base/net_util.h index 9e30d2b..4e1d07e 100644 --- a/net/base/net_util.h +++ b/net/base/net_util.h @@ -133,7 +133,7 @@ void GetIdentityFromURL(const GURL& url, std::string GetHostOrSpecFromURL(const GURL& url); // Return the value of the HTTP response header with name 'name'. 'headers' -// should be in the format that net::URLRequest::GetResponseHeaders() returns. +// should be in the format that URLRequest::GetResponseHeaders() returns. // Returns the empty string if the header is not found. std::wstring GetSpecificHeader(const std::wstring& headers, const std::wstring& name); diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc index 8f05c20..9f15bc5 100644 --- a/net/base/net_util_unittest.cc +++ b/net/base/net_util_unittest.cc @@ -17,10 +17,9 @@ #include "net/base/sys_addrinfo.h" #include "testing/gtest/include/gtest/gtest.h" -namespace { +namespace net { -class NetUtilTest : public testing::Test { -}; +namespace { struct FileCase { const wchar_t* file; @@ -391,7 +390,7 @@ struct UrlTestData { const char* description; const char* input; const char* languages; - net::FormatUrlTypes format_types; + FormatUrlTypes format_types; UnescapeRule::Type escape_rules; const wchar_t* output; // Use |wchar_t| to handle Unicode constants easily. size_t prefix_len; @@ -458,7 +457,7 @@ void AppendLanguagesToOutputs(const wchar_t* languages, } // Helper to strignize an IP number (used to define expectations). -std::string DumpIPNumber(const net::IPAddressNumber& v) { +std::string DumpIPNumber(const IPAddressNumber& v) { std::string out; for (size_t i = 0; i < v.size(); ++i) { if (i != 0) @@ -512,12 +511,12 @@ TEST(NetUtilTest, FileURLConversion) { FilePath output; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(round_trip_cases); i++) { // convert to the file URL - GURL file_url(net::FilePathToFileURL( + GURL file_url(FilePathToFileURL( file_util::WStringAsFilePath(round_trip_cases[i].file))); EXPECT_EQ(round_trip_cases[i].url, file_url.spec()); // Back to the filename. - EXPECT_TRUE(net::FileURLToFilePath(file_url, &output)); + EXPECT_TRUE(FileURLToFilePath(file_url, &output)); EXPECT_EQ(round_trip_cases[i].file, file_util::FilePathAsWString(output)); } @@ -556,7 +555,7 @@ TEST(NetUtilTest, FileURLConversion) { #endif }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(url_cases); i++) { - net::FileURLToFilePath(GURL(url_cases[i].url), &output); + FileURLToFilePath(GURL(url_cases[i].url), &output); EXPECT_EQ(url_cases[i].file, file_util::FilePathAsWString(output)); } @@ -566,13 +565,13 @@ TEST(NetUtilTest, FileURLConversion) { // the input is preserved in UTF-8 const char invalid_utf8[] = "file:///d:/Blah/\xff.doc"; const wchar_t invalid_wide[] = L"D:\\Blah\\\xff.doc"; - EXPECT_TRUE(net::FileURLToFilePath( + EXPECT_TRUE(FileURLToFilePath( GURL(std::string(invalid_utf8)), &output)); EXPECT_EQ(std::wstring(invalid_wide), output); #endif // Test that if a file URL is malformed, we get a failure - EXPECT_FALSE(net::FileURLToFilePath(GURL("filefoobar"), &output)); + EXPECT_FALSE(FileURLToFilePath(GURL("filefoobar"), &output)); } TEST(NetUtilTest, GetIdentityFromURL) { @@ -623,7 +622,7 @@ TEST(NetUtilTest, GetIdentityFromURL) { GURL url(tests[i].input_url); string16 username, password; - net::GetIdentityFromURL(url, &username, &password); + GetIdentityFromURL(url, &username, &password); EXPECT_EQ(ASCIIToUTF16(tests[i].expected_username), username); EXPECT_EQ(ASCIIToUTF16(tests[i].expected_password), password); @@ -639,7 +638,7 @@ TEST(NetUtilTest, GetIdentityFromURL_UTF8) { // Extract the unescaped identity. string16 username, password; - net::GetIdentityFromURL(url, &username, &password); + GetIdentityFromURL(url, &username, &password); // Verify that it was decoded as UTF8. EXPECT_EQ(ASCIIToUTF16("foo"), username); @@ -680,14 +679,14 @@ TEST(NetUtilTest, GetSpecificHeader) { // Test first with google_headers. for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - std::wstring result = net::GetSpecificHeader(google_headers, + std::wstring result = GetSpecificHeader(google_headers, tests[i].header_name); EXPECT_EQ(result, tests[i].expected); } // Test again with empty headers. for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - std::wstring result = net::GetSpecificHeader(L"", tests[i].header_name); + std::wstring result = GetSpecificHeader(L"", tests[i].header_name); EXPECT_EQ(result, std::wstring()); } } @@ -710,19 +709,19 @@ TEST(NetUtilTest, GetHeaderParamValue) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { std::wstring header_value = - net::GetSpecificHeader(google_headers, tests[i].header_name); + GetSpecificHeader(google_headers, tests[i].header_name); std::wstring result = - net::GetHeaderParamValue(header_value, tests[i].param_name, - net::QuoteRule::REMOVE_OUTER_QUOTES); + GetHeaderParamValue(header_value, tests[i].param_name, + QuoteRule::REMOVE_OUTER_QUOTES); EXPECT_EQ(result, tests[i].expected); } for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { std::wstring header_value = - net::GetSpecificHeader(L"", tests[i].header_name); + GetSpecificHeader(L"", tests[i].header_name); std::wstring result = - net::GetHeaderParamValue(header_value, tests[i].param_name, - net::QuoteRule::REMOVE_OUTER_QUOTES); + GetHeaderParamValue(header_value, tests[i].param_name, + QuoteRule::REMOVE_OUTER_QUOTES); EXPECT_EQ(result, std::wstring()); } } @@ -741,11 +740,11 @@ TEST(NetUtilTest, GetHeaderParamValueQuotes) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { std::string actual_with_quotes = - net::GetHeaderParamValue(tests[i].header, "filename", - net::QuoteRule::KEEP_OUTER_QUOTES); + GetHeaderParamValue(tests[i].header, "filename", + QuoteRule::KEEP_OUTER_QUOTES); std::string actual_without_quotes = - net::GetHeaderParamValue(tests[i].header, "filename", - net::QuoteRule::REMOVE_OUTER_QUOTES); + GetHeaderParamValue(tests[i].header, "filename", + QuoteRule::REMOVE_OUTER_QUOTES); EXPECT_EQ(tests[i].expected_with_quotes, actual_with_quotes) << "Failed while processing: " << tests[i].header; EXPECT_EQ(tests[i].expected_without_quotes, actual_without_quotes) @@ -924,8 +923,8 @@ TEST(NetUtilTest, GetFileNameFromCD) { }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { EXPECT_EQ(tests[i].expected, - UTF8ToWide(net::GetFileNameFromCD(tests[i].header_field, - tests[i].referrer_charset))) + UTF8ToWide(GetFileNameFromCD(tests[i].header_field, + tests[i].referrer_charset))) << "Failed on input: " << tests[i].header_field; } } @@ -936,7 +935,7 @@ TEST(NetUtilTest, IDNToUnicodeFast) { // ja || zh-TW,en || ko,ja -> IDNToUnicodeSlow if (j == 3 || j == 17 || j == 18) continue; - std::wstring output(net::IDNToUnicode(idn_cases[i].input, + std::wstring output(IDNToUnicode(idn_cases[i].input, strlen(idn_cases[i].input), kLanguages[j], NULL)); std::wstring expected(idn_cases[i].unicode_allowed[j] ? idn_cases[i].unicode_output : ASCIIToWide(idn_cases[i].input)); @@ -952,7 +951,7 @@ TEST(NetUtilTest, IDNToUnicodeSlow) { // !(ja || zh-TW,en || ko,ja) -> IDNToUnicodeFast if (!(j == 3 || j == 17 || j == 18)) continue; - std::wstring output(net::IDNToUnicode(idn_cases[i].input, + std::wstring output(IDNToUnicode(idn_cases[i].input, strlen(idn_cases[i].input), kLanguages[j], NULL)); std::wstring expected(idn_cases[i].unicode_allowed[j] ? idn_cases[i].unicode_output : ASCIIToWide(idn_cases[i].input)); @@ -983,7 +982,7 @@ TEST(NetUtilTest, IDNToUnicodeAdjustOffset) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(adjust_cases); ++i) { size_t offset = adjust_cases[i].input_offset; // "test.\x89c6\x9891.\x5317\x4eac\x5927\x5b78.test" - net::IDNToUnicode("test.xn--cy2a840a.xn--1lq90ic7f1rc.test", 39, L"zh-CN", + IDNToUnicode("test.xn--cy2a840a.xn--1lq90ic7f1rc.test", 39, L"zh-CN", &offset); EXPECT_EQ(adjust_cases[i].output_offset, offset); } @@ -1018,16 +1017,16 @@ TEST(NetUtilTest, CompliantHost) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(compliant_host_cases); ++i) { EXPECT_EQ(compliant_host_cases[i].expected_output, - net::IsCanonicalizedHostCompliant(compliant_host_cases[i].host, + IsCanonicalizedHostCompliant(compliant_host_cases[i].host, compliant_host_cases[i].desired_tld)); } } TEST(NetUtilTest, StripWWW) { - EXPECT_EQ(string16(), net::StripWWW(string16())); - EXPECT_EQ(string16(), net::StripWWW(ASCIIToUTF16("www."))); - EXPECT_EQ(ASCIIToUTF16("blah"), net::StripWWW(ASCIIToUTF16("www.blah"))); - EXPECT_EQ(ASCIIToUTF16("blah"), net::StripWWW(ASCIIToUTF16("blah"))); + EXPECT_EQ(string16(), StripWWW(string16())); + EXPECT_EQ(string16(), StripWWW(ASCIIToUTF16("www."))); + EXPECT_EQ(ASCIIToUTF16("blah"), StripWWW(ASCIIToUTF16("www.blah"))); + EXPECT_EQ(ASCIIToUTF16("blah"), StripWWW(ASCIIToUTF16("blah"))); } TEST(NetUtilTest, GetSuggestedFilename) { @@ -1221,7 +1220,7 @@ TEST(NetUtilTest, GetSuggestedFilename) { }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { std::wstring default_name = test_cases[i].default_filename; - string16 filename = net::GetSuggestedFilename( + string16 filename = GetSuggestedFilename( GURL(test_cases[i].url), test_cases[i].content_disp_header, test_cases[i].referrer_charset, WideToUTF16(default_name)); EXPECT_EQ(std::wstring(test_cases[i].expected_filename), @@ -1287,7 +1286,7 @@ TEST(NetUtilTest, GetDirectoryListingEntry) { }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { - const std::string results = net::GetDirectoryListingEntry( + const std::string results = GetDirectoryListingEntry( WideToUTF16(test_cases[i].name), test_cases[i].raw_bytes, test_cases[i].is_dir, @@ -1333,7 +1332,7 @@ TEST(NetUtilTest, ParseHostAndPort) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { std::string host; int port; - bool ok = net::ParseHostAndPort(tests[i].input, &host, &port); + bool ok = ParseHostAndPort(tests[i].input, &host, &port); EXPECT_EQ(tests[i].success, ok); @@ -1357,7 +1356,7 @@ TEST(NetUtilTest, GetHostAndPort) { { GURL("http://[::a]:33/x"), "[::a]:33"}, }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - std::string host_and_port = net::GetHostAndPort(tests[i].url); + std::string host_and_port = GetHostAndPort(tests[i].url); EXPECT_EQ(std::string(tests[i].expected_host_and_port), host_and_port); } } @@ -1375,7 +1374,7 @@ TEST(NetUtilTest, GetHostAndOptionalPort) { { GURL("http://[::a]:33/x"), "[::a]:33"}, }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { - std::string host_and_port = net::GetHostAndOptionalPort(tests[i].url); + std::string host_and_port = GetHostAndOptionalPort(tests[i].url); EXPECT_EQ(std::string(tests[i].expected_host_and_port), host_and_port); } } @@ -1393,7 +1392,7 @@ TEST(NetUtilTest, NetAddressToString_IPv4) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { const addrinfo* ai = GetIPv4Address(tests[i].addr, 80); - std::string result = net::NetAddressToString(ai); + std::string result = NetAddressToString(ai); EXPECT_EQ(std::string(tests[i].result), result); } } @@ -1410,7 +1409,7 @@ TEST(NetUtilTest, NetAddressToString_IPv6) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { const addrinfo* ai = GetIPv6Address(tests[i].addr, 80); - std::string result = net::NetAddressToString(ai); + std::string result = NetAddressToString(ai); // Allow NetAddressToString() to fail, in case the system doesn't // support IPv6. if (!result.empty()) @@ -1421,7 +1420,7 @@ TEST(NetUtilTest, NetAddressToString_IPv6) { TEST(NetUtilTest, NetAddressToStringWithPort_IPv4) { uint8 addr[] = {127, 0, 0, 1}; const addrinfo* ai = GetIPv4Address(addr, 166); - std::string result = net::NetAddressToStringWithPort(ai); + std::string result = NetAddressToStringWithPort(ai); EXPECT_EQ("127.0.0.1:166", result); } @@ -1431,7 +1430,7 @@ TEST(NetUtilTest, NetAddressToStringWithPort_IPv6) { 0x98, 0x76, 0x54, 0x32, 0x10 }; const addrinfo* ai = GetIPv6Address(addr, 361); - std::string result = net::NetAddressToStringWithPort(ai); + std::string result = NetAddressToStringWithPort(ai); // May fail on systems that don't support IPv6. if (!result.empty()) @@ -1442,12 +1441,12 @@ TEST(NetUtilTest, GetHostName) { // We can't check the result of GetHostName() directly, since the result // will differ across machines. Our goal here is to simply exercise the // code path, and check that things "look about right". - std::string hostname = net::GetHostName(); + std::string hostname = GetHostName(); EXPECT_FALSE(hostname.empty()); } TEST(NetUtilTest, FormatUrl) { - net::FormatUrlTypes default_format_type = net::kFormatUrlOmitUsernamePassword; + FormatUrlTypes default_format_type = kFormatUrlOmitUsernamePassword; const UrlTestData tests[] = { {"Empty URL", "", "", default_format_type, UnescapeRule::NORMAL, L"", 0}, @@ -1494,7 +1493,7 @@ TEST(NetUtilTest, FormatUrl) { // -------- omit_username_password flag tests -------- {"With username and password, omit_username_password=false", "http://user:passwd@example.com/foo", "", - net::kFormatUrlOmitNothing, UnescapeRule::NORMAL, + kFormatUrlOmitNothing, UnescapeRule::NORMAL, L"http://user:passwd@example.com/foo", 19}, {"With username and password, omit_username_password=true", @@ -1539,53 +1538,53 @@ TEST(NetUtilTest, FormatUrl) { /* {"unescape=true with some special characters", "http://user%3A:%40passwd@example.com/foo%3Fbar?q=b%26z", "", - net::kFormatUrlOmitNothing, UnescapeRule::NORMAL, + kFormatUrlOmitNothing, UnescapeRule::NORMAL, L"http://user%3A:%40passwd@example.com/foo%3Fbar?q=b%26z", 25}, */ // Disabled: the resultant URL becomes "...user%253A:%2540passwd...". // -------- omit http: -------- {"omit http with user name", - "http://user@example.com/foo", "", net::kFormatUrlOmitAll, + "http://user@example.com/foo", "", kFormatUrlOmitAll, UnescapeRule::NORMAL, L"example.com/foo", 0}, {"omit http", - "http://www.google.com/", "en", net::kFormatUrlOmitHTTP, + "http://www.google.com/", "en", kFormatUrlOmitHTTP, UnescapeRule::NORMAL, L"www.google.com/", 0}, {"omit http with https", - "https://www.google.com/", "en", net::kFormatUrlOmitHTTP, + "https://www.google.com/", "en", kFormatUrlOmitHTTP, UnescapeRule::NORMAL, L"https://www.google.com/", 8}, {"omit http starts with ftp.", - "http://ftp.google.com/", "en", net::kFormatUrlOmitHTTP, + "http://ftp.google.com/", "en", kFormatUrlOmitHTTP, UnescapeRule::NORMAL, L"http://ftp.google.com/", 7}, // -------- omit trailing slash on bare hostname -------- {"omit slash when it's the entire path", "http://www.google.com/", "en", - net::kFormatUrlOmitTrailingSlashOnBareHostname, UnescapeRule::NORMAL, + kFormatUrlOmitTrailingSlashOnBareHostname, UnescapeRule::NORMAL, L"http://www.google.com", 7}, {"omit slash when there's a ref", "http://www.google.com/#ref", "en", - net::kFormatUrlOmitTrailingSlashOnBareHostname, UnescapeRule::NORMAL, + kFormatUrlOmitTrailingSlashOnBareHostname, UnescapeRule::NORMAL, L"http://www.google.com/#ref", 7}, {"omit slash when there's a query", "http://www.google.com/?", "en", - net::kFormatUrlOmitTrailingSlashOnBareHostname, UnescapeRule::NORMAL, + kFormatUrlOmitTrailingSlashOnBareHostname, UnescapeRule::NORMAL, L"http://www.google.com/?", 7}, {"omit slash when it's not the entire path", "http://www.google.com/foo", "en", - net::kFormatUrlOmitTrailingSlashOnBareHostname, UnescapeRule::NORMAL, + kFormatUrlOmitTrailingSlashOnBareHostname, UnescapeRule::NORMAL, L"http://www.google.com/foo", 7}, {"omit slash for nonstandard URLs", - "data:/", "en", net::kFormatUrlOmitTrailingSlashOnBareHostname, + "data:/", "en", kFormatUrlOmitTrailingSlashOnBareHostname, UnescapeRule::NORMAL, L"data:/", 5}, {"omit slash for file URLs", - "file:///", "en", net::kFormatUrlOmitTrailingSlashOnBareHostname, + "file:///", "en", kFormatUrlOmitTrailingSlashOnBareHostname, UnescapeRule::NORMAL, L"file:///", 7}, // -------- view-source: -------- @@ -1602,22 +1601,22 @@ TEST(NetUtilTest, FormatUrl) { // view-source should omit http and trailing slash where non-view-source // would. {"view-source omit http", - "view-source:http://a.b/c", "en", net::kFormatUrlOmitAll, + "view-source:http://a.b/c", "en", kFormatUrlOmitAll, UnescapeRule::NORMAL, L"view-source:a.b/c", 12}, {"view-source omit http starts with ftp.", - "view-source:http://ftp.b/c", "en", net::kFormatUrlOmitAll, + "view-source:http://ftp.b/c", "en", kFormatUrlOmitAll, UnescapeRule::NORMAL, L"view-source:http://ftp.b/c", 19}, {"view-source omit slash when it's the entire path", - "view-source:http://a.b/", "en", net::kFormatUrlOmitAll, + "view-source:http://a.b/", "en", kFormatUrlOmitAll, UnescapeRule::NORMAL, L"view-source:a.b", 12}, }; for (size_t i = 0; i < arraysize(tests); ++i) { size_t prefix_len; - string16 formatted = net::FormatUrl( + string16 formatted = FormatUrl( GURL(tests[i].input), tests[i].languages, tests[i].format_types, tests[i].escape_rules, NULL, &prefix_len, NULL); EXPECT_EQ(WideToUTF16(tests[i].output), formatted) << tests[i].description; @@ -1628,10 +1627,10 @@ TEST(NetUtilTest, FormatUrl) { TEST(NetUtilTest, FormatUrlParsed) { // No unescape case. url_parse::Parsed parsed; - string16 formatted = net::FormatUrl( + string16 formatted = FormatUrl( GURL("http://\xE3\x82\xB0:\xE3\x83\xBC@xn--qcka1pmc.jp:8080/" "%E3%82%B0/?q=%E3%82%B0#\xE3\x82\xB0"), - "ja", net::kFormatUrlOmitNothing, UnescapeRule::NONE, &parsed, NULL, + "ja", kFormatUrlOmitNothing, UnescapeRule::NONE, &parsed, NULL, NULL); EXPECT_EQ(WideToUTF16( L"http://%E3%82%B0:%E3%83%BC@\x30B0\x30FC\x30B0\x30EB.jp:8080" @@ -1652,10 +1651,10 @@ TEST(NetUtilTest, FormatUrlParsed) { formatted.substr(parsed.ref.begin, parsed.ref.len)); // Unescape case. - formatted = net::FormatUrl( + formatted = FormatUrl( GURL("http://\xE3\x82\xB0:\xE3\x83\xBC@xn--qcka1pmc.jp:8080/" "%E3%82%B0/?q=%E3%82%B0#\xE3\x82\xB0"), - "ja", net::kFormatUrlOmitNothing, UnescapeRule::NORMAL, &parsed, NULL, + "ja", kFormatUrlOmitNothing, UnescapeRule::NORMAL, &parsed, NULL, NULL); EXPECT_EQ(WideToUTF16(L"http://\x30B0:\x30FC@\x30B0\x30FC\x30B0\x30EB.jp:8080" L"/\x30B0/?q=\x30B0#\x30B0"), formatted); @@ -1675,10 +1674,10 @@ TEST(NetUtilTest, FormatUrlParsed) { formatted.substr(parsed.ref.begin, parsed.ref.len)); // Omit_username_password + unescape case. - formatted = net::FormatUrl( + formatted = FormatUrl( GURL("http://\xE3\x82\xB0:\xE3\x83\xBC@xn--qcka1pmc.jp:8080/" "%E3%82%B0/?q=%E3%82%B0#\xE3\x82\xB0"), - "ja", net::kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, &parsed, + "ja", kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, &parsed, NULL, NULL); EXPECT_EQ(WideToUTF16(L"http://\x30B0\x30FC\x30B0\x30EB.jp:8080" L"/\x30B0/?q=\x30B0#\x30B0"), formatted); @@ -1696,9 +1695,9 @@ TEST(NetUtilTest, FormatUrlParsed) { formatted.substr(parsed.ref.begin, parsed.ref.len)); // View-source case. - formatted = net::FormatUrl( + formatted = FormatUrl( GURL("view-source:http://user:passwd@host:81/path?query#ref"), - "", net::kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, &parsed, + "", kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, &parsed, NULL, NULL); EXPECT_EQ(WideToUTF16(L"view-source:http://host:81/path?query#ref"), formatted); @@ -1718,9 +1717,9 @@ TEST(NetUtilTest, FormatUrlParsed) { formatted.substr(parsed.ref.begin, parsed.ref.len)); // omit http case. - formatted = net::FormatUrl( + formatted = FormatUrl( GURL("http://host:8000/a?b=c#d"), - "", net::kFormatUrlOmitHTTP, UnescapeRule::NORMAL, &parsed, NULL, NULL); + "", kFormatUrlOmitHTTP, UnescapeRule::NORMAL, &parsed, NULL, NULL); EXPECT_EQ(WideToUTF16(L"host:8000/a?b=c#d"), formatted); EXPECT_FALSE(parsed.scheme.is_valid()); EXPECT_FALSE(parsed.username.is_valid()); @@ -1737,9 +1736,9 @@ TEST(NetUtilTest, FormatUrlParsed) { formatted.substr(parsed.ref.begin, parsed.ref.len)); // omit http starts with ftp case. - formatted = net::FormatUrl( + formatted = FormatUrl( GURL("http://ftp.host:8000/a?b=c#d"), - "", net::kFormatUrlOmitHTTP, UnescapeRule::NORMAL, &parsed, NULL, NULL); + "", kFormatUrlOmitHTTP, UnescapeRule::NORMAL, &parsed, NULL, NULL); EXPECT_EQ(WideToUTF16(L"http://ftp.host:8000/a?b=c#d"), formatted); EXPECT_TRUE(parsed.scheme.is_valid()); EXPECT_FALSE(parsed.username.is_valid()); @@ -1758,9 +1757,9 @@ TEST(NetUtilTest, FormatUrlParsed) { formatted.substr(parsed.ref.begin, parsed.ref.len)); // omit http starts with 'f' case. - formatted = net::FormatUrl( + formatted = FormatUrl( GURL("http://f/"), - "", net::kFormatUrlOmitHTTP, UnescapeRule::NORMAL, &parsed, NULL, NULL); + "", kFormatUrlOmitHTTP, UnescapeRule::NORMAL, &parsed, NULL, NULL); EXPECT_EQ(WideToUTF16(L"f/"), formatted); EXPECT_FALSE(parsed.scheme.is_valid()); EXPECT_FALSE(parsed.username.is_valid()); @@ -1792,8 +1791,8 @@ TEST(NetUtilTest, FormatUrlAdjustOffset) { }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(basic_cases); ++i) { size_t offset = basic_cases[i].input_offset; - net::FormatUrl(GURL("http://www.google.com/foo/"), "en", - net::kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, + FormatUrl(GURL("http://www.google.com/foo/"), "en", + kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, NULL, NULL, &offset); EXPECT_EQ(basic_cases[i].output_offset, offset); } @@ -1816,8 +1815,8 @@ TEST(NetUtilTest, FormatUrlAdjustOffset) { }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(omit_auth_cases); ++i) { size_t offset = omit_auth_cases[i].input_offset; - net::FormatUrl(GURL(omit_auth_cases[i].input_url), "en", - net::kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, + FormatUrl(GURL(omit_auth_cases[i].input_url), "en", + kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, NULL, NULL, &offset); EXPECT_EQ(omit_auth_cases[i].output_offset, offset); } @@ -1836,8 +1835,8 @@ TEST(NetUtilTest, FormatUrlAdjustOffset) { }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(view_source_cases); ++i) { size_t offset = view_source_cases[i].input_offset; - net::FormatUrl(GURL("view-source:http://foo@www.google.com/"), "en", - net::kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, + FormatUrl(GURL("view-source:http://foo@www.google.com/"), "en", + kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, NULL, NULL, &offset); EXPECT_EQ(view_source_cases[i].output_offset, offset); } @@ -1852,8 +1851,8 @@ TEST(NetUtilTest, FormatUrlAdjustOffset) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(idn_hostname_cases); ++i) { size_t offset = idn_hostname_cases[i].input_offset; // "http://\x671d\x65e5\x3042\x3055\x3072.jp/foo/" - net::FormatUrl(GURL("http://xn--l8jvb1ey91xtjb.jp/foo/"), "ja", - net::kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, + FormatUrl(GURL("http://xn--l8jvb1ey91xtjb.jp/foo/"), "ja", + kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, NULL, NULL, &offset); EXPECT_EQ(idn_hostname_cases[i].output_offset, offset); } @@ -1873,9 +1872,9 @@ TEST(NetUtilTest, FormatUrlAdjustOffset) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(unescape_cases); ++i) { size_t offset = unescape_cases[i].input_offset; // "http://www.google.com/foo bar/\x30B0\x30FC\x30B0\x30EB" - net::FormatUrl(GURL( + FormatUrl(GURL( "http://www.google.com/foo%20bar/%E3%82%B0%E3%83%BC%E3%82%B0%E3%83%AB"), - "en", net::kFormatUrlOmitUsernamePassword, UnescapeRule::SPACES, NULL, + "en", kFormatUrlOmitUsernamePassword, UnescapeRule::SPACES, NULL, NULL, &offset); EXPECT_EQ(unescape_cases[i].output_offset, offset); } @@ -1891,9 +1890,9 @@ TEST(NetUtilTest, FormatUrlAdjustOffset) { for (size_t i = 0; i < ARRAYSIZE_UNSAFE(ref_cases); ++i) { size_t offset = ref_cases[i].input_offset; // "http://www.google.com/foo.html#\x30B0\x30B0z" - net::FormatUrl(GURL( + FormatUrl(GURL( "http://www.google.com/foo.html#\xE3\x82\xB0\xE3\x82\xB0z"), "en", - net::kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, NULL, NULL, + kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, NULL, NULL, &offset); EXPECT_EQ(ref_cases[i].output_offset, offset); } @@ -1906,8 +1905,8 @@ TEST(NetUtilTest, FormatUrlAdjustOffset) { }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(omit_http_cases); ++i) { size_t offset = omit_http_cases[i].input_offset; - net::FormatUrl(GURL("http://www.google.com"), "en", - net::kFormatUrlOmitHTTP, UnescapeRule::NORMAL, NULL, NULL, &offset); + FormatUrl(GURL("http://www.google.com"), "en", + kFormatUrlOmitHTTP, UnescapeRule::NORMAL, NULL, NULL, &offset); EXPECT_EQ(omit_http_cases[i].output_offset, offset); } @@ -1918,8 +1917,8 @@ TEST(NetUtilTest, FormatUrlAdjustOffset) { }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(omit_http_start_with_ftp); ++i) { size_t offset = omit_http_start_with_ftp[i].input_offset; - net::FormatUrl(GURL("http://ftp.google.com"), "en", - net::kFormatUrlOmitHTTP, UnescapeRule::NORMAL, NULL, NULL, &offset); + FormatUrl(GURL("http://ftp.google.com"), "en", + kFormatUrlOmitHTTP, UnescapeRule::NORMAL, NULL, NULL, &offset); EXPECT_EQ(omit_http_start_with_ftp[i].output_offset, offset); } @@ -1931,7 +1930,7 @@ TEST(NetUtilTest, FormatUrlAdjustOffset) { }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(omit_all_cases); ++i) { size_t offset = omit_all_cases[i].input_offset; - net::FormatUrl(GURL("http://user@foo.com/"), "en", net::kFormatUrlOmitAll, + FormatUrl(GURL("http://user@foo.com/"), "en", kFormatUrlOmitAll, UnescapeRule::NORMAL, NULL, NULL, &offset); EXPECT_EQ(omit_all_cases[i].output_offset, offset); } @@ -1978,7 +1977,7 @@ TEST(NetUtilTest, SimplifyUrlForRequest) { tests[i].input_url)); GURL input_url(GURL(tests[i].input_url)); GURL expected_url(GURL(tests[i].expected_simplified_url)); - EXPECT_EQ(expected_url, net::SimplifyUrlForRequest(input_url)); + EXPECT_EQ(expected_url, SimplifyUrlForRequest(input_url)); } } @@ -1987,58 +1986,58 @@ TEST(NetUtilTest, SetExplicitlyAllowedPortsTest) { std::string valid[] = { "", "1", "1,2", "1,2,3", "10,11,12,13" }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(invalid); ++i) { - net::SetExplicitlyAllowedPorts(invalid[i]); - EXPECT_EQ(0, static_cast<int>(net::explicitly_allowed_ports.size())); + SetExplicitlyAllowedPorts(invalid[i]); + EXPECT_EQ(0, static_cast<int>(explicitly_allowed_ports.size())); } for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid); ++i) { - net::SetExplicitlyAllowedPorts(valid[i]); - EXPECT_EQ(i, net::explicitly_allowed_ports.size()); + SetExplicitlyAllowedPorts(valid[i]); + EXPECT_EQ(i, explicitly_allowed_ports.size()); } } TEST(NetUtilTest, GetHostOrSpecFromURL) { EXPECT_EQ("example.com", - net::GetHostOrSpecFromURL(GURL("http://example.com/test"))); + GetHostOrSpecFromURL(GURL("http://example.com/test"))); EXPECT_EQ("example.com", - net::GetHostOrSpecFromURL(GURL("http://example.com./test"))); + GetHostOrSpecFromURL(GURL("http://example.com./test"))); EXPECT_EQ("file:///tmp/test.html", - net::GetHostOrSpecFromURL(GURL("file:///tmp/test.html"))); + GetHostOrSpecFromURL(GURL("file:///tmp/test.html"))); } // Test that invalid IP literals fail to parse. TEST(NetUtilTest, ParseIPLiteralToNumber_FailParse) { - net::IPAddressNumber number; - - EXPECT_FALSE(net::ParseIPLiteralToNumber("bad value", &number)); - EXPECT_FALSE(net::ParseIPLiteralToNumber("bad:value", &number)); - EXPECT_FALSE(net::ParseIPLiteralToNumber("", &number)); - EXPECT_FALSE(net::ParseIPLiteralToNumber("192.168.0.1:30", &number)); - EXPECT_FALSE(net::ParseIPLiteralToNumber(" 192.168.0.1 ", &number)); - EXPECT_FALSE(net::ParseIPLiteralToNumber("[::1]", &number)); + IPAddressNumber number; + + EXPECT_FALSE(ParseIPLiteralToNumber("bad value", &number)); + EXPECT_FALSE(ParseIPLiteralToNumber("bad:value", &number)); + EXPECT_FALSE(ParseIPLiteralToNumber("", &number)); + EXPECT_FALSE(ParseIPLiteralToNumber("192.168.0.1:30", &number)); + EXPECT_FALSE(ParseIPLiteralToNumber(" 192.168.0.1 ", &number)); + EXPECT_FALSE(ParseIPLiteralToNumber("[::1]", &number)); } // Test parsing an IPv4 literal. TEST(NetUtilTest, ParseIPLiteralToNumber_IPv4) { - net::IPAddressNumber number; - EXPECT_TRUE(net::ParseIPLiteralToNumber("192.168.0.1", &number)); + IPAddressNumber number; + EXPECT_TRUE(ParseIPLiteralToNumber("192.168.0.1", &number)); EXPECT_EQ("192,168,0,1", DumpIPNumber(number)); } // Test parsing an IPv6 literal. TEST(NetUtilTest, ParseIPLiteralToNumber_IPv6) { - net::IPAddressNumber number; - EXPECT_TRUE(net::ParseIPLiteralToNumber("1:abcd::3:4:ff", &number)); + IPAddressNumber number; + EXPECT_TRUE(ParseIPLiteralToNumber("1:abcd::3:4:ff", &number)); EXPECT_EQ("0,1,171,205,0,0,0,0,0,0,0,3,0,4,0,255", DumpIPNumber(number)); } // Test mapping an IPv4 address to an IPv6 address. TEST(NetUtilTest, ConvertIPv4NumberToIPv6Number) { - net::IPAddressNumber ipv4_number; - EXPECT_TRUE(net::ParseIPLiteralToNumber("192.168.0.1", &ipv4_number)); + IPAddressNumber ipv4_number; + EXPECT_TRUE(ParseIPLiteralToNumber("192.168.0.1", &ipv4_number)); - net::IPAddressNumber ipv6_number = - net::ConvertIPv4NumberToIPv6Number(ipv4_number); + IPAddressNumber ipv6_number = + ConvertIPv4NumberToIPv6Number(ipv4_number); // ::ffff:192.168.1.1 EXPECT_EQ("0,0,0,0,0,0,0,0,0,0,255,255,192,168,0,1", @@ -2064,10 +2063,10 @@ TEST(NetUtilTest, ParseCIDRBlock_Invalid) { }; for (size_t i = 0; i < arraysize(bad_literals); ++i) { - net::IPAddressNumber ip_number; + IPAddressNumber ip_number; size_t prefix_length_in_bits; - EXPECT_FALSE(net::ParseCIDRBlock(bad_literals[i], + EXPECT_FALSE(ParseCIDRBlock(bad_literals[i], &ip_number, &prefix_length_in_bits)); } @@ -2075,10 +2074,10 @@ TEST(NetUtilTest, ParseCIDRBlock_Invalid) { // Test parsing a valid CIDR notation literal. TEST(NetUtilTest, ParseCIDRBlock_Valid) { - net::IPAddressNumber ip_number; + IPAddressNumber ip_number; size_t prefix_length_in_bits; - EXPECT_TRUE(net::ParseCIDRBlock("192.168.0.1/11", + EXPECT_TRUE(ParseCIDRBlock("192.168.0.1/11", &ip_number, &prefix_length_in_bits)); @@ -2150,36 +2149,36 @@ TEST(NetUtilTest, IPNumberMatchesPrefix) { tests[i].cidr_literal, tests[i].ip_literal)); - net::IPAddressNumber ip_number; - EXPECT_TRUE(net::ParseIPLiteralToNumber(tests[i].ip_literal, &ip_number)); + IPAddressNumber ip_number; + EXPECT_TRUE(ParseIPLiteralToNumber(tests[i].ip_literal, &ip_number)); - net::IPAddressNumber ip_prefix; + IPAddressNumber ip_prefix; size_t prefix_length_in_bits; - EXPECT_TRUE(net::ParseCIDRBlock(tests[i].cidr_literal, - &ip_prefix, - &prefix_length_in_bits)); + EXPECT_TRUE(ParseCIDRBlock(tests[i].cidr_literal, + &ip_prefix, + &prefix_length_in_bits)); EXPECT_EQ(tests[i].expected_to_match, - net::IPNumberMatchesPrefix(ip_number, - ip_prefix, - prefix_length_in_bits)); + IPNumberMatchesPrefix(ip_number, + ip_prefix, + prefix_length_in_bits)); } } // Verify GetNetworkList(). TEST(NetUtilTest, GetNetworkList) { - net::NetworkInterfaceList list; - ASSERT_TRUE(net::GetNetworkList(&list)); + NetworkInterfaceList list; + ASSERT_TRUE(GetNetworkList(&list)); - for (net::NetworkInterfaceList::iterator it = list.begin(); + for (NetworkInterfaceList::iterator it = list.begin(); it != list.end(); ++it) { // Verify that the name is not empty. EXPECT_FALSE(it->name.empty()); // Verify that the address is correct. - EXPECT_TRUE(it->address.size() == net::kIPv4AddressSize || - it->address.size() == net::kIPv6AddressSize) + EXPECT_TRUE(it->address.size() == kIPv4AddressSize || + it->address.size() == kIPv6AddressSize) << "Invalid address of size " << it->address.size(); bool all_zeroes = true; for (size_t i = 0; i < it->address.size(); ++i) { @@ -2191,3 +2190,5 @@ TEST(NetUtilTest, GetNetworkList) { EXPECT_FALSE(all_zeroes); } } + +} // namespace net diff --git a/net/base/registry_controlled_domain.cc b/net/base/registry_controlled_domain.cc index 1ee88747..d01b3d1 100644 --- a/net/base/registry_controlled_domain.cc +++ b/net/base/registry_controlled_domain.cc @@ -75,7 +75,7 @@ std::string RegistryControlledDomainService::GetDomainAndRegistry( std::string RegistryControlledDomainService::GetDomainAndRegistry( const std::string& host) { url_canon::CanonHostInfo host_info; - const std::string canon_host(net::CanonicalizeHost(host, &host_info)); + const std::string canon_host(CanonicalizeHost(host, &host_info)); if (canon_host.empty() || host_info.IsIPAddress()) return std::string(); return GetDomainAndRegistryImpl(canon_host); @@ -85,7 +85,7 @@ std::string RegistryControlledDomainService::GetDomainAndRegistry( std::string RegistryControlledDomainService::GetDomainAndRegistry( const std::wstring& host) { url_canon::CanonHostInfo host_info; - const std::string canon_host(net::CanonicalizeHost(host, &host_info)); + const std::string canon_host(CanonicalizeHost(host, &host_info)); if (canon_host.empty() || host_info.IsIPAddress()) return std::string(); return GetDomainAndRegistryImpl(canon_host); @@ -133,7 +133,7 @@ size_t RegistryControlledDomainService::GetRegistryLength( const std::string& host, bool allow_unknown_registries) { url_canon::CanonHostInfo host_info; - const std::string canon_host(net::CanonicalizeHost(host, &host_info)); + const std::string canon_host(CanonicalizeHost(host, &host_info)); if (canon_host.empty()) return std::string::npos; if (host_info.IsIPAddress()) @@ -147,7 +147,7 @@ size_t RegistryControlledDomainService::GetRegistryLength( const std::wstring& host, bool allow_unknown_registries) { url_canon::CanonHostInfo host_info; - const std::string canon_host(net::CanonicalizeHost(host, &host_info)); + const std::string canon_host(CanonicalizeHost(host, &host_info)); if (canon_host.empty()) return std::string::npos; if (host_info.IsIPAddress()) diff --git a/net/base/registry_controlled_domain_unittest.cc b/net/base/registry_controlled_domain_unittest.cc index 8c90c99..6f2041f 100644 --- a/net/base/registry_controlled_domain_unittest.cc +++ b/net/base/registry_controlled_domain_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -14,14 +14,15 @@ #undef MAX_HASH_VALUE #include "effective_tld_names_unittest2.cc" +namespace net { namespace { class TestRegistryControlledDomainService : - public net::RegistryControlledDomainService { + public RegistryControlledDomainService { public: // Sets the given data. static void UseDomainData(FindDomainPtr function) { - net::RegistryControlledDomainService::UseFindDomainFunction(function); + RegistryControlledDomainService::UseFindDomainFunction(function); } // Creates a new dedicated instance to be used for testing, deleting any @@ -252,4 +253,5 @@ TEST_F(RegistryControlledDomainTest, TestDefaultData) { EXPECT_EQ(3U, GetRegistryLengthFromURL("http://nowhere.foo", true)); } -} // namespace +} // namespace +} // namespace net diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc index 4d99426..9d4d496 100644 --- a/net/base/sdch_manager.cc +++ b/net/base/sdch_manager.cc @@ -106,7 +106,7 @@ bool SdchManager::Dictionary::CanSet(const std::string& domain, SdchErrorRecovery(DICTIONARY_MISSING_DOMAIN_SPECIFIER); return false; // Domain is required. } - if (net::RegistryControlledDomainService::GetDomainAndRegistry(domain).size() + if (RegistryControlledDomainService::GetDomainAndRegistry(domain).size() == 0) { SdchErrorRecovery(DICTIONARY_SPECIFIES_TOP_LEVEL_DOMAIN); return false; // domain was a TLD. diff --git a/net/base/ssl_config_service_mac_unittest.cc b/net/base/ssl_config_service_mac_unittest.cc index a933b1c..a22f044 100644 --- a/net/base/ssl_config_service_mac_unittest.cc +++ b/net/base/ssl_config_service_mac_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -8,6 +8,8 @@ using base::TimeDelta; using base::TimeTicks; +namespace net { + namespace { // SSLClientConfig service caches settings for 10 seconds for performance. @@ -16,7 +18,7 @@ namespace { // value by 11 seconds, we ensure fresh config settings. const int kSSLConfigNextTimeInternal = 11; -class SSLConfigServiceMacObserver : public net::SSLConfigService::Observer { +class SSLConfigServiceMacObserver : public SSLConfigService::Observer { public: SSLConfigServiceMacObserver() : change_was_observed_(false) { } @@ -30,69 +32,66 @@ class SSLConfigServiceMacObserver : public net::SSLConfigService::Observer { bool change_was_observed_; }; -class SSLConfigServiceMacTest : public testing::Test { -}; - } // namespace TEST(SSLConfigServiceMacTest, GetNowTest) { // Verify that the constructor sets the correct default values. - net::SSLConfig config; + SSLConfig config; EXPECT_TRUE(config.rev_checking_enabled); EXPECT_TRUE(config.ssl3_enabled); EXPECT_TRUE(config.tls1_enabled); - bool rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); + bool rv = SSLConfigServiceMac::GetSSLConfigNow(&config); EXPECT_TRUE(rv); } TEST(SSLConfigServiceMacTest, SetTest) { // Save the current settings so we can restore them after the tests. - net::SSLConfig config_save; - bool rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config_save); + SSLConfig config_save; + bool rv = SSLConfigServiceMac::GetSSLConfigNow(&config_save); EXPECT_TRUE(rv); - net::SSLConfig config; + SSLConfig config; // Test SetRevCheckingEnabled. - net::SSLConfigServiceMac::SetRevCheckingEnabled(true); - rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); + SSLConfigServiceMac::SetRevCheckingEnabled(true); + rv = SSLConfigServiceMac::GetSSLConfigNow(&config); EXPECT_TRUE(rv); EXPECT_TRUE(config.rev_checking_enabled); - net::SSLConfigServiceMac::SetRevCheckingEnabled(false); - rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); + SSLConfigServiceMac::SetRevCheckingEnabled(false); + rv = SSLConfigServiceMac::GetSSLConfigNow(&config); EXPECT_TRUE(rv); EXPECT_FALSE(config.rev_checking_enabled); - net::SSLConfigServiceMac::SetRevCheckingEnabled( + SSLConfigServiceMac::SetRevCheckingEnabled( config_save.rev_checking_enabled); // Test SetSSL3Enabled. - net::SSLConfigServiceMac::SetSSL3Enabled(true); - rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); + SSLConfigServiceMac::SetSSL3Enabled(true); + rv = SSLConfigServiceMac::GetSSLConfigNow(&config); EXPECT_TRUE(rv); EXPECT_TRUE(config.ssl3_enabled); - net::SSLConfigServiceMac::SetSSL3Enabled(false); - rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); + SSLConfigServiceMac::SetSSL3Enabled(false); + rv = SSLConfigServiceMac::GetSSLConfigNow(&config); EXPECT_TRUE(rv); EXPECT_FALSE(config.ssl3_enabled); - net::SSLConfigServiceMac::SetSSL3Enabled(config_save.ssl3_enabled); + SSLConfigServiceMac::SetSSL3Enabled(config_save.ssl3_enabled); // Test SetTLS1Enabled. - net::SSLConfigServiceMac::SetTLS1Enabled(true); - rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); + SSLConfigServiceMac::SetTLS1Enabled(true); + rv = SSLConfigServiceMac::GetSSLConfigNow(&config); EXPECT_TRUE(rv); EXPECT_TRUE(config.tls1_enabled); - net::SSLConfigServiceMac::SetTLS1Enabled(false); - rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config); + SSLConfigServiceMac::SetTLS1Enabled(false); + rv = SSLConfigServiceMac::GetSSLConfigNow(&config); EXPECT_TRUE(rv); EXPECT_FALSE(config.tls1_enabled); - net::SSLConfigServiceMac::SetTLS1Enabled(config_save.tls1_enabled); + SSLConfigServiceMac::SetTLS1Enabled(config_save.tls1_enabled); } TEST(SSLConfigServiceMacTest, GetTest) { @@ -100,13 +99,13 @@ TEST(SSLConfigServiceMacTest, GetTest) { TimeTicks now_1 = now + TimeDelta::FromSeconds(1); TimeTicks later = now + TimeDelta::FromSeconds(kSSLConfigNextTimeInternal); - net::SSLConfig config, config_1, config_later; - scoped_refptr<net::SSLConfigServiceMac> config_service( - new net::SSLConfigServiceMac(now)); + SSLConfig config, config_1, config_later; + scoped_refptr<SSLConfigServiceMac> config_service( + new SSLConfigServiceMac(now)); config_service->GetSSLConfigAt(&config, now); // Flip rev_checking_enabled. - net::SSLConfigServiceMac::SetRevCheckingEnabled( + SSLConfigServiceMac::SetRevCheckingEnabled( !config.rev_checking_enabled); config_service->GetSSLConfigAt(&config_1, now_1); @@ -116,7 +115,7 @@ TEST(SSLConfigServiceMacTest, GetTest) { EXPECT_EQ(!config.rev_checking_enabled, config_later.rev_checking_enabled); // Restore the original value. - net::SSLConfigServiceMac::SetRevCheckingEnabled( + SSLConfigServiceMac::SetRevCheckingEnabled( config.rev_checking_enabled); } @@ -124,22 +123,22 @@ TEST(SSLConfigServiceMacTest, ObserverTest) { TimeTicks now = TimeTicks::Now(); TimeTicks later = now + TimeDelta::FromSeconds(kSSLConfigNextTimeInternal); - scoped_refptr<net::SSLConfigServiceMac> config_service( - new net::SSLConfigServiceMac(now)); + scoped_refptr<SSLConfigServiceMac> config_service( + new SSLConfigServiceMac(now)); // Save the current settings so we can restore them after the tests. - net::SSLConfig config_save; - bool rv = net::SSLConfigServiceMac::GetSSLConfigNow(&config_save); + SSLConfig config_save; + bool rv = SSLConfigServiceMac::GetSSLConfigNow(&config_save); EXPECT_TRUE(rv); - net::SSLConfig config; + SSLConfig config; // Add an observer. SSLConfigServiceMacObserver observer; config_service->AddObserver(&observer); // Toggle SSL3. - net::SSLConfigServiceMac::SetSSL3Enabled(!config_save.ssl3_enabled); + SSLConfigServiceMac::SetSSL3Enabled(!config_save.ssl3_enabled); config_service->GetSSLConfigAt(&config, later); // Verify that the observer was notified. @@ -149,6 +148,7 @@ TEST(SSLConfigServiceMacTest, ObserverTest) { config_service->RemoveObserver(&observer); // Restore the original SSL3 setting. - net::SSLConfigServiceMac::SetSSL3Enabled(config_save.ssl3_enabled); + SSLConfigServiceMac::SetSSL3Enabled(config_save.ssl3_enabled); } +} // namespace net diff --git a/net/base/ssl_config_service_unittest.cc b/net/base/ssl_config_service_unittest.cc index 47af3ee..528cf99 100644 --- a/net/base/ssl_config_service_unittest.cc +++ b/net/base/ssl_config_service_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -7,9 +7,6 @@ namespace { -class SSLConfigServiceTest : public testing::Test { -}; - bool IsFalseStartIncompatible(const std::string& hostname) { return net::SSLConfigService::IsKnownFalseStartIncompatibleServer( hostname); diff --git a/net/base/ssl_config_service_win_unittest.cc b/net/base/ssl_config_service_win_unittest.cc index 6a87760..1959be7 100644 --- a/net/base/ssl_config_service_win_unittest.cc +++ b/net/base/ssl_config_service_win_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -8,6 +8,8 @@ using base::TimeDelta; using base::TimeTicks; +namespace net { + namespace { // SSLClientConfig service caches settings for 10 seconds for performance. @@ -16,7 +18,7 @@ namespace { // value by 11 seconds, we ensure fresh config settings. const int kSSLConfigNextTimeInternal = 11; -class SSLConfigServiceWinObserver : public net::SSLConfigService::Observer { +class SSLConfigServiceWinObserver : public SSLConfigService::Observer { public: SSLConfigServiceWinObserver() : change_was_observed_(false) { } @@ -30,69 +32,66 @@ class SSLConfigServiceWinObserver : public net::SSLConfigService::Observer { bool change_was_observed_; }; -class SSLConfigServiceWinTest : public testing::Test { -}; - } // namespace TEST(SSLConfigServiceWinTest, GetNowTest) { // Verify that the constructor sets the correct default values. - net::SSLConfig config; + SSLConfig config; EXPECT_TRUE(config.rev_checking_enabled); EXPECT_TRUE(config.ssl3_enabled); EXPECT_TRUE(config.tls1_enabled); - bool rv = net::SSLConfigServiceWin::GetSSLConfigNow(&config); + bool rv = SSLConfigServiceWin::GetSSLConfigNow(&config); EXPECT_TRUE(rv); } TEST(SSLConfigServiceWinTest, SetTest) { // Save the current settings so we can restore them after the tests. - net::SSLConfig config_save; - bool rv = net::SSLConfigServiceWin::GetSSLConfigNow(&config_save); + SSLConfig config_save; + bool rv = SSLConfigServiceWin::GetSSLConfigNow(&config_save); EXPECT_TRUE(rv); - net::SSLConfig config; + SSLConfig config; // Test SetRevCheckingEnabled. - net::SSLConfigServiceWin::SetRevCheckingEnabled(true); - rv = net::SSLConfigServiceWin::GetSSLConfigNow(&config); + SSLConfigServiceWin::SetRevCheckingEnabled(true); + rv = SSLConfigServiceWin::GetSSLConfigNow(&config); EXPECT_TRUE(rv); EXPECT_TRUE(config.rev_checking_enabled); - net::SSLConfigServiceWin::SetRevCheckingEnabled(false); - rv = net::SSLConfigServiceWin::GetSSLConfigNow(&config); + SSLConfigServiceWin::SetRevCheckingEnabled(false); + rv = SSLConfigServiceWin::GetSSLConfigNow(&config); EXPECT_TRUE(rv); EXPECT_FALSE(config.rev_checking_enabled); - net::SSLConfigServiceWin::SetRevCheckingEnabled( + SSLConfigServiceWin::SetRevCheckingEnabled( config_save.rev_checking_enabled); // Test SetSSL3Enabled. - net::SSLConfigServiceWin::SetSSL3Enabled(true); - rv = net::SSLConfigServiceWin::GetSSLConfigNow(&config); + SSLConfigServiceWin::SetSSL3Enabled(true); + rv = SSLConfigServiceWin::GetSSLConfigNow(&config); EXPECT_TRUE(rv); EXPECT_TRUE(config.ssl3_enabled); - net::SSLConfigServiceWin::SetSSL3Enabled(false); - rv = net::SSLConfigServiceWin::GetSSLConfigNow(&config); + SSLConfigServiceWin::SetSSL3Enabled(false); + rv = SSLConfigServiceWin::GetSSLConfigNow(&config); EXPECT_TRUE(rv); EXPECT_FALSE(config.ssl3_enabled); - net::SSLConfigServiceWin::SetSSL3Enabled(config_save.ssl3_enabled); + SSLConfigServiceWin::SetSSL3Enabled(config_save.ssl3_enabled); // Test SetTLS1Enabled. - net::SSLConfigServiceWin::SetTLS1Enabled(true); - rv = net::SSLConfigServiceWin::GetSSLConfigNow(&config); + SSLConfigServiceWin::SetTLS1Enabled(true); + rv = SSLConfigServiceWin::GetSSLConfigNow(&config); EXPECT_TRUE(rv); EXPECT_TRUE(config.tls1_enabled); - net::SSLConfigServiceWin::SetTLS1Enabled(false); - rv = net::SSLConfigServiceWin::GetSSLConfigNow(&config); + SSLConfigServiceWin::SetTLS1Enabled(false); + rv = SSLConfigServiceWin::GetSSLConfigNow(&config); EXPECT_TRUE(rv); EXPECT_FALSE(config.tls1_enabled); - net::SSLConfigServiceWin::SetTLS1Enabled(config_save.tls1_enabled); + SSLConfigServiceWin::SetTLS1Enabled(config_save.tls1_enabled); } TEST(SSLConfigServiceWinTest, GetTest) { @@ -100,13 +99,13 @@ TEST(SSLConfigServiceWinTest, GetTest) { TimeTicks now_1 = now + TimeDelta::FromSeconds(1); TimeTicks later = now + TimeDelta::FromSeconds(kSSLConfigNextTimeInternal); - net::SSLConfig config, config_1, config_later; - scoped_refptr<net::SSLConfigServiceWin> config_service( - new net::SSLConfigServiceWin(now)); + SSLConfig config, config_1, config_later; + scoped_refptr<SSLConfigServiceWin> config_service( + new SSLConfigServiceWin(now)); config_service->GetSSLConfigAt(&config, now); // Flip rev_checking_enabled. - net::SSLConfigServiceWin::SetRevCheckingEnabled( + SSLConfigServiceWin::SetRevCheckingEnabled( !config.rev_checking_enabled); config_service->GetSSLConfigAt(&config_1, now_1); @@ -116,7 +115,7 @@ TEST(SSLConfigServiceWinTest, GetTest) { EXPECT_EQ(!config.rev_checking_enabled, config_later.rev_checking_enabled); // Restore the original value. - net::SSLConfigServiceWin::SetRevCheckingEnabled( + SSLConfigServiceWin::SetRevCheckingEnabled( config.rev_checking_enabled); } @@ -124,22 +123,22 @@ TEST(SSLConfigServiceWinTest, ObserverTest) { TimeTicks now = TimeTicks::Now(); TimeTicks later = now + TimeDelta::FromSeconds(kSSLConfigNextTimeInternal); - scoped_refptr<net::SSLConfigServiceWin> config_service( - new net::SSLConfigServiceWin(now)); + scoped_refptr<SSLConfigServiceWin> config_service( + new SSLConfigServiceWin(now)); // Save the current settings so we can restore them after the tests. - net::SSLConfig config_save; - bool rv = net::SSLConfigServiceWin::GetSSLConfigNow(&config_save); + SSLConfig config_save; + bool rv = SSLConfigServiceWin::GetSSLConfigNow(&config_save); EXPECT_TRUE(rv); - net::SSLConfig config; + SSLConfig config; // Add an observer. SSLConfigServiceWinObserver observer; config_service->AddObserver(&observer); // Toggle SSL3. - net::SSLConfigServiceWin::SetSSL3Enabled(!config_save.ssl3_enabled); + SSLConfigServiceWin::SetSSL3Enabled(!config_save.ssl3_enabled); config_service->GetSSLConfigAt(&config, later); // Verify that the observer was notified. @@ -149,5 +148,7 @@ TEST(SSLConfigServiceWinTest, ObserverTest) { config_service->RemoveObserver(&observer); // Restore the original SSL3 setting. - net::SSLConfigServiceWin::SetSSL3Enabled(config_save.ssl3_enabled); + SSLConfigServiceWin::SetSSL3Enabled(config_save.ssl3_enabled); } + +} // namespace net diff --git a/net/base/ssl_false_start_blacklist_unittest.cc b/net/base/ssl_false_start_blacklist_unittest.cc index 7ade428..7eedae4 100644 --- a/net/base/ssl_false_start_blacklist_unittest.cc +++ b/net/base/ssl_false_start_blacklist_unittest.cc @@ -1,12 +1,14 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "net/base/ssl_false_start_blacklist.h" #include "testing/gtest/include/gtest/gtest.h" +namespace net { + TEST(SSLFalseStartBlacklistTest, LastTwoLabels) { -#define F net::SSLFalseStartBlacklist::LastTwoLabels +#define F SSLFalseStartBlacklist::LastTwoLabels EXPECT_STREQ(F("a.b.c.d"), "c.d"); EXPECT_STREQ(F("a.b"), "a.b"); EXPECT_STREQ(F("example.com"), "example.com"); @@ -20,9 +22,11 @@ TEST(SSLFalseStartBlacklistTest, LastTwoLabels) { } TEST(SSLFalseStartBlacklistTest, IsMember) { - EXPECT_TRUE(net::SSLFalseStartBlacklist::IsMember("example.com")); - EXPECT_TRUE(net::SSLFalseStartBlacklist::IsMember("www.example.com")); - EXPECT_TRUE(net::SSLFalseStartBlacklist::IsMember("a.b.example.com")); - EXPECT_FALSE(net::SSLFalseStartBlacklist::IsMember("aexample.com")); - EXPECT_FALSE(net::SSLFalseStartBlacklist::IsMember("com")); + EXPECT_TRUE(SSLFalseStartBlacklist::IsMember("example.com")); + EXPECT_TRUE(SSLFalseStartBlacklist::IsMember("www.example.com")); + EXPECT_TRUE(SSLFalseStartBlacklist::IsMember("a.b.example.com")); + EXPECT_FALSE(SSLFalseStartBlacklist::IsMember("aexample.com")); + EXPECT_FALSE(SSLFalseStartBlacklist::IsMember("com")); } + +} // namespace net diff --git a/net/base/static_cookie_policy_unittest.cc b/net/base/static_cookie_policy_unittest.cc index 57dc4fa..9fac666 100644 --- a/net/base/static_cookie_policy_unittest.cc +++ b/net/base/static_cookie_policy_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -7,6 +7,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "googleurl/src/gurl.h" +namespace net { + class StaticCookiePolicyTest : public testing::Test { public: StaticCookiePolicyTest() @@ -15,7 +17,7 @@ class StaticCookiePolicyTest : public testing::Test { url_google_mail_("http://mail.google.izzle"), url_google_analytics_("http://www.googleanalytics.izzle") { } - void SetPolicyType(net::StaticCookiePolicy::Type type) { + void SetPolicyType(StaticCookiePolicy::Type type) { policy_.set_type(type); } int CanGetCookies(const GURL& url, const GURL& first_party) { @@ -25,7 +27,7 @@ class StaticCookiePolicyTest : public testing::Test { return policy_.CanSetCookie(url, first_party, std::string(), NULL); } protected: - net::StaticCookiePolicy policy_; + StaticCookiePolicy policy_; GURL url_google_; GURL url_google_secure_; GURL url_google_mail_; @@ -33,79 +35,81 @@ class StaticCookiePolicyTest : public testing::Test { }; TEST_F(StaticCookiePolicyTest, DefaultPolicyTest) { - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_secure_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_mail_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_analytics_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, GURL())); - - EXPECT_EQ(net::OK, CanSetCookie(url_google_, url_google_)); - EXPECT_EQ(net::OK, CanSetCookie(url_google_, url_google_secure_)); - EXPECT_EQ(net::OK, CanSetCookie(url_google_, url_google_mail_)); - EXPECT_EQ(net::OK, CanSetCookie(url_google_, url_google_analytics_)); - EXPECT_EQ(net::OK, CanSetCookie(url_google_, GURL())); + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_secure_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_mail_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_analytics_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, GURL())); + + EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_)); + EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_secure_)); + EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_mail_)); + EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_analytics_)); + EXPECT_EQ(OK, CanSetCookie(url_google_, GURL())); } TEST_F(StaticCookiePolicyTest, AllowAllCookiesTest) { - SetPolicyType(net::StaticCookiePolicy::ALLOW_ALL_COOKIES); - - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_secure_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_mail_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_analytics_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, GURL())); - - EXPECT_EQ(net::OK, CanSetCookie(url_google_, url_google_)); - EXPECT_EQ(net::OK, CanSetCookie(url_google_, url_google_secure_)); - EXPECT_EQ(net::OK, CanSetCookie(url_google_, url_google_mail_)); - EXPECT_EQ(net::OK, CanSetCookie(url_google_, url_google_analytics_)); - EXPECT_EQ(net::OK, CanSetCookie(url_google_, GURL())); + SetPolicyType(StaticCookiePolicy::ALLOW_ALL_COOKIES); + + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_secure_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_mail_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_analytics_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, GURL())); + + EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_)); + EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_secure_)); + EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_mail_)); + EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_analytics_)); + EXPECT_EQ(OK, CanSetCookie(url_google_, GURL())); } TEST_F(StaticCookiePolicyTest, BlockSettingThirdPartyCookiesTest) { - SetPolicyType(net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); - - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_secure_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_mail_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_analytics_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, GURL())); - - EXPECT_EQ(net::OK, CanSetCookie(url_google_, url_google_)); - EXPECT_EQ(net::OK, CanSetCookie(url_google_, url_google_secure_)); - EXPECT_EQ(net::OK, CanSetCookie(url_google_, url_google_mail_)); - EXPECT_NE(net::OK, CanSetCookie(url_google_, url_google_analytics_)); - EXPECT_EQ(net::OK, CanSetCookie(url_google_, GURL())); + SetPolicyType(StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); + + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_secure_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_mail_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_analytics_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, GURL())); + + EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_)); + EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_secure_)); + EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_mail_)); + EXPECT_NE(OK, CanSetCookie(url_google_, url_google_analytics_)); + EXPECT_EQ(OK, CanSetCookie(url_google_, GURL())); } TEST_F(StaticCookiePolicyTest, BlockAllThirdPartyCookiesTest) { - SetPolicyType(net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES); - - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_secure_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, url_google_mail_)); - EXPECT_NE(net::OK, CanGetCookies(url_google_, url_google_analytics_)); - EXPECT_EQ(net::OK, CanGetCookies(url_google_, GURL())); - - EXPECT_EQ(net::OK, CanSetCookie(url_google_, url_google_)); - EXPECT_EQ(net::OK, CanSetCookie(url_google_, url_google_secure_)); - EXPECT_EQ(net::OK, CanSetCookie(url_google_, url_google_mail_)); - EXPECT_NE(net::OK, CanSetCookie(url_google_, url_google_analytics_)); - EXPECT_EQ(net::OK, CanSetCookie(url_google_, GURL())); + SetPolicyType(StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES); + + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_secure_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, url_google_mail_)); + EXPECT_NE(OK, CanGetCookies(url_google_, url_google_analytics_)); + EXPECT_EQ(OK, CanGetCookies(url_google_, GURL())); + + EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_)); + EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_secure_)); + EXPECT_EQ(OK, CanSetCookie(url_google_, url_google_mail_)); + EXPECT_NE(OK, CanSetCookie(url_google_, url_google_analytics_)); + EXPECT_EQ(OK, CanSetCookie(url_google_, GURL())); } TEST_F(StaticCookiePolicyTest, BlockAllCookiesTest) { - SetPolicyType(net::StaticCookiePolicy::BLOCK_ALL_COOKIES); - - EXPECT_NE(net::OK, CanGetCookies(url_google_, url_google_)); - EXPECT_NE(net::OK, CanGetCookies(url_google_, url_google_secure_)); - EXPECT_NE(net::OK, CanGetCookies(url_google_, url_google_mail_)); - EXPECT_NE(net::OK, CanGetCookies(url_google_, url_google_analytics_)); - EXPECT_NE(net::OK, CanGetCookies(url_google_, GURL())); - - EXPECT_NE(net::OK, CanSetCookie(url_google_, url_google_)); - EXPECT_NE(net::OK, CanSetCookie(url_google_, url_google_secure_)); - EXPECT_NE(net::OK, CanSetCookie(url_google_, url_google_mail_)); - EXPECT_NE(net::OK, CanSetCookie(url_google_, url_google_analytics_)); - EXPECT_NE(net::OK, CanSetCookie(url_google_, GURL())); + SetPolicyType(StaticCookiePolicy::BLOCK_ALL_COOKIES); + + EXPECT_NE(OK, CanGetCookies(url_google_, url_google_)); + EXPECT_NE(OK, CanGetCookies(url_google_, url_google_secure_)); + EXPECT_NE(OK, CanGetCookies(url_google_, url_google_mail_)); + EXPECT_NE(OK, CanGetCookies(url_google_, url_google_analytics_)); + EXPECT_NE(OK, CanGetCookies(url_google_, GURL())); + + EXPECT_NE(OK, CanSetCookie(url_google_, url_google_)); + EXPECT_NE(OK, CanSetCookie(url_google_, url_google_secure_)); + EXPECT_NE(OK, CanSetCookie(url_google_, url_google_mail_)); + EXPECT_NE(OK, CanSetCookie(url_google_, url_google_analytics_)); + EXPECT_NE(OK, CanSetCookie(url_google_, GURL())); } + +} // namespace net diff --git a/net/base/upload_data_stream_unittest.cc b/net/base/upload_data_stream_unittest.cc index 780bd23..5f5cc6c 100644 --- a/net/base/upload_data_stream_unittest.cc +++ b/net/base/upload_data_stream_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -98,9 +98,9 @@ void UploadDataStreamTest::FileChangedHelper(const FilePath& file_path, scoped_ptr<UploadDataStream> stream( UploadDataStream::Create(upload_data_, &error_code)); if (error_expected) - ASSERT_TRUE(!stream.get() && error_code == net::ERR_UPLOAD_FILE_CHANGED); + ASSERT_TRUE(!stream.get() && error_code == ERR_UPLOAD_FILE_CHANGED); else - ASSERT_TRUE(stream.get() && error_code == net::OK); + ASSERT_TRUE(stream.get() && error_code == OK); } TEST_F(UploadDataStreamTest, FileChanged) { diff --git a/net/base/x509_certificate_mac.cc b/net/base/x509_certificate_mac.cc index 254469e..bc19399 100644 --- a/net/base/x509_certificate_mac.cc +++ b/net/base/x509_certificate_mac.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -46,7 +46,7 @@ int NetErrorFromOSStatus(OSStatus status) { case errSecAuthFailed: return ERR_ACCESS_DENIED; default: - LOG(ERROR) << "Unknown error " << status << " mapped to net::ERR_FAILED"; + LOG(ERROR) << "Unknown error " << status << " mapped to ERR_FAILED"; return ERR_FAILED; } } diff --git a/net/base/x509_certificate_nss.cc b/net/base/x509_certificate_nss.cc index efa9d9d..7cc7ac9 100644 --- a/net/base/x509_certificate_nss.cc +++ b/net/base/x509_certificate_nss.cc @@ -825,7 +825,7 @@ bool X509Certificate::VerifyNameMatch(const std::string& hostname) const { // Otherwise, we pass just that EV policy (as opposed to all the EV policies) // to the second PKIXVerifyCert call. bool X509Certificate::VerifyEV() const { - net::EVRootCAMetadata* metadata = net::EVRootCAMetadata::GetInstance(); + EVRootCAMetadata* metadata = EVRootCAMetadata::GetInstance(); CERTValOutParam cvout[3]; int cvout_index = 0; diff --git a/net/base/x509_certificate_unittest.cc b/net/base/x509_certificate_unittest.cc index f8ededc..53a131f 100644 --- a/net/base/x509_certificate_unittest.cc +++ b/net/base/x509_certificate_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -737,8 +737,8 @@ TEST(X509CertificateTest, IsIssuedBy) { TEST(X509CertificateTest, CreateSelfSigned) { scoped_ptr<base::RSAPrivateKey> private_key( base::RSAPrivateKey::Create(1024)); - scoped_refptr<net::X509Certificate> cert = - net::X509Certificate::CreateSelfSigned( + scoped_refptr<X509Certificate> cert = + X509Certificate::CreateSelfSigned( private_key.get(), "CN=subject", 1, base::TimeDelta::FromDays(1)); EXPECT_EQ("subject", cert->subject().GetDisplayName()); @@ -834,7 +834,7 @@ TEST(X509CertificateTest, CreateSelfSigned) { private_key.reset(base::RSAPrivateKey::CreateFromPrivateKeyInfo(input)); ASSERT_TRUE(private_key.get()); - cert = net::X509Certificate::CreateSelfSigned( + cert = X509Certificate::CreateSelfSigned( private_key.get(), "CN=subject", 1, base::TimeDelta::FromDays(1)); EXPECT_EQ("subject", cert->subject().GetDisplayName()); @@ -844,8 +844,8 @@ TEST(X509CertificateTest, CreateSelfSigned) { TEST(X509CertificateTest, GetDEREncoded) { scoped_ptr<base::RSAPrivateKey> private_key( base::RSAPrivateKey::Create(1024)); - scoped_refptr<net::X509Certificate> cert = - net::X509Certificate::CreateSelfSigned( + scoped_refptr<X509Certificate> cert = + X509Certificate::CreateSelfSigned( private_key.get(), "CN=subject", 0, base::TimeDelta::FromDays(1)); std::string der_cert; |