summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-31 19:40:37 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-31 19:40:37 +0000
commit8ac1a75acadaa2aae065212cb6255d00c789a184 (patch)
tree854eaf66ba8ce7e581bd8e6f1fa75f46d22f4bb7 /net
parent287a019ed5d015185cab41f6c7156dc6c4cbcee7 (diff)
downloadchromium_src-8ac1a75acadaa2aae065212cb6255d00c789a184.zip
chromium_src-8ac1a75acadaa2aae065212cb6255d00c789a184.tar.gz
chromium_src-8ac1a75acadaa2aae065212cb6255d00c789a184.tar.bz2
Move more net classes into the net namespace. Also remove the net_util namespace in favor of the net namespace.
This is a purely mechanical change. There should be no logic changes. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/cookie_monster.cc9
-rw-r--r--net/base/cookie_monster.h4
-rw-r--r--net/base/cookie_monster_perftest.cc8
-rw-r--r--net/base/cookie_monster_unittest.cc219
-rw-r--r--net/base/cookie_policy.cc13
-rw-r--r--net/base/cookie_policy.h4
-rw-r--r--net/base/cookie_policy_unittest.cc14
-rw-r--r--net/base/listen_socket_unittest.h4
-rw-r--r--net/base/net_module.cc4
-rw-r--r--net/base/net_module.h4
-rw-r--r--net/base/net_util.cc4
-rw-r--r--net/base/net_util.h4
-rw-r--r--net/base/net_util_unittest.cc54
-rw-r--r--net/base/registry_controlled_domain.cc16
-rw-r--r--net/base/registry_controlled_domain.h4
-rw-r--r--net/base/registry_controlled_domain_unittest.cc6
-rw-r--r--net/base/winsock_init.cc4
-rw-r--r--net/base/winsock_init.h4
-rw-r--r--net/base/x509_certificate.cc4
-rw-r--r--net/base/x509_certificate.h10
-rw-r--r--net/http/http_transaction_winhttp.cc2
-rw-r--r--net/url_request/mime_sniffer_proxy.h2
-rw-r--r--net/url_request/url_request.h2
-rw-r--r--net/url_request/url_request_context.h10
-rw-r--r--net/url_request/url_request_file_dir_job.cc4
-rw-r--r--net/url_request/url_request_file_job.cc4
-rw-r--r--net/url_request/url_request_ftp_job.cc8
-rw-r--r--net/url_request/url_request_http_job.cc4
-rw-r--r--net/url_request/url_request_unittest.cc8
-rw-r--r--net/url_request/url_request_unittest.h2
30 files changed, 244 insertions, 195 deletions
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc
index 0483acb..b8dd8e7 100644
--- a/net/base/cookie_monster.cc
+++ b/net/base/cookie_monster.cc
@@ -88,7 +88,10 @@
#define COOKIE_DLOG(severity) DLOG_IF(INFO, 0)
#endif
-/*static*/ bool CookieMonster::enable_file_scheme_ = false;
+namespace net {
+
+// static
+bool CookieMonster::enable_file_scheme_ = false;
// static
void CookieMonster::EnableFileScheme() {
@@ -266,7 +269,7 @@ static bool GetCookieDomainKey(const GURL& url,
// domain=.my.domain.com -- for compatibility we do the same here. Firefox
// also treats domain=.....my.domain.com like domain=.my.domain.com, but
// neither IE nor Safari do this, and we don't either.
- std::string cookie_domain(net_util::CanonicalizeHost(pc.Domain(), NULL));
+ std::string cookie_domain(net::CanonicalizeHost(pc.Domain(), NULL));
if (cookie_domain.empty())
return false;
if (cookie_domain[0] != '.')
@@ -1041,3 +1044,5 @@ std::string CookieMonster::CanonicalCookie::DebugString() const {
name_.c_str(), value_.c_str(), path_.c_str(),
creation_date_.ToTimeT());
}
+
+} // namespace
diff --git a/net/base/cookie_monster.h b/net/base/cookie_monster.h
index cf7f2a6..cb76655 100644
--- a/net/base/cookie_monster.h
+++ b/net/base/cookie_monster.h
@@ -43,6 +43,8 @@
class GURL;
+namespace net {
+
// The cookie monster is the system for storing and retrieving cookies. It has
// an in-memory list of all cookies, and synchronizes non-session cookies to an
// optional permanent storage that implements the PersistentCookieStore
@@ -328,4 +330,6 @@ class CookieMonster::PersistentCookieStore {
DISALLOW_EVIL_CONSTRUCTORS(CookieMonster::PersistentCookieStore);
};
+} // namespace net
+
#endif // NET_BASE_COOKIE_MONSTER_H__
diff --git a/net/base/cookie_monster_perftest.cc b/net/base/cookie_monster_perftest.cc
index d5d93a7..83b6ee2 100644
--- a/net/base/cookie_monster_perftest.cc
+++ b/net/base/cookie_monster_perftest.cc
@@ -45,7 +45,7 @@ TEST(ParsedCookieTest, TestParseCookies) {
std::string cookie(kCookieLine);
PerfTimeLogger timer("Parsed_cookie_parse_cookies");
for (int i = 0; i < kNumCookies; ++i) {
- CookieMonster::ParsedCookie pc(cookie);
+ net::CookieMonster::ParsedCookie pc(cookie);
EXPECT_TRUE(pc.IsValid());
}
timer.Done();
@@ -56,7 +56,7 @@ TEST(ParsedCookieTest, TestParseBigCookies) {
cookie += kCookieLine;
PerfTimeLogger timer("Parsed_cookie_parse_big_cookies");
for (int i = 0; i < kNumCookies; ++i) {
- CookieMonster::ParsedCookie pc(cookie);
+ net::CookieMonster::ParsedCookie pc(cookie);
EXPECT_TRUE(pc.IsValid());
}
timer.Done();
@@ -65,7 +65,7 @@ TEST(ParsedCookieTest, TestParseBigCookies) {
static const GURL kUrlGoogle("http://www.google.izzle");
TEST(CookieMonsterTest, TestAddCookiesOnSingleHost) {
- CookieMonster cm;
+ net::CookieMonster cm;
std::vector<std::string> cookies;
for (int i = 0; i < kNumCookies; i++) {
cookies.push_back(StringPrintf("a%03d=b", i));
@@ -92,7 +92,7 @@ TEST(CookieMonsterTest, TestAddCookiesOnSingleHost) {
}
TEST(CookieMonsterTest, TestAddCookieOnManyHosts) {
- CookieMonster cm;
+ net::CookieMonster cm;
std::string cookie(kCookieLine);
std::vector<GURL> gurls; // just wanna have ffffuunnn
for (int i = 0; i < kNumCookies; ++i) {
diff --git a/net/base/cookie_monster_unittest.cc b/net/base/cookie_monster_unittest.cc
index fbe1019..484f661 100644
--- a/net/base/cookie_monster_unittest.cc
+++ b/net/base/cookie_monster_unittest.cc
@@ -46,7 +46,7 @@ namespace {
TEST(ParsedCookieTest, TestBasic) {
- CookieMonster::ParsedCookie pc("a=b");
+ net::CookieMonster::ParsedCookie pc("a=b");
EXPECT_TRUE(pc.IsValid());
EXPECT_FALSE(pc.IsSecure());
EXPECT_EQ(pc.Name(), "a");
@@ -54,7 +54,7 @@ TEST(ParsedCookieTest, TestBasic) {
}
TEST(ParsedCookieTest, TestQuoted) {
- CookieMonster::ParsedCookie pc("a=\"b=;\"; path=\"/\"");
+ net::CookieMonster::ParsedCookie pc("a=\"b=;\"; path=\"/\"");
EXPECT_TRUE(pc.IsValid());
EXPECT_FALSE(pc.IsSecure());
EXPECT_TRUE(pc.HasPath());
@@ -67,7 +67,7 @@ TEST(ParsedCookieTest, TestQuoted) {
}
TEST(ParsedCookieTest, TestNameless) {
- CookieMonster::ParsedCookie pc("BLAHHH; path=/; secure;");
+ net::CookieMonster::ParsedCookie pc("BLAHHH; path=/; secure;");
EXPECT_TRUE(pc.IsValid());
EXPECT_TRUE(pc.IsSecure());
EXPECT_TRUE(pc.HasPath());
@@ -77,7 +77,7 @@ TEST(ParsedCookieTest, TestNameless) {
}
TEST(ParsedCookieTest, TestAttributeCase) {
- CookieMonster::ParsedCookie pc("BLAHHH; Path=/; sECuRe; httpONLY");
+ net::CookieMonster::ParsedCookie pc("BLAHHH; Path=/; sECuRe; httpONLY");
EXPECT_TRUE(pc.IsValid());
EXPECT_TRUE(pc.IsSecure());
EXPECT_TRUE(pc.IsHttpOnly());
@@ -88,7 +88,7 @@ TEST(ParsedCookieTest, TestAttributeCase) {
}
TEST(ParsedCookieTest, TestDoubleQuotedNameless) {
- CookieMonster::ParsedCookie pc("\"BLA\\\"HHH\"; path=/; secure;");
+ net::CookieMonster::ParsedCookie pc("\"BLA\\\"HHH\"; path=/; secure;");
EXPECT_TRUE(pc.IsValid());
EXPECT_TRUE(pc.IsSecure());
EXPECT_TRUE(pc.HasPath());
@@ -98,21 +98,21 @@ TEST(ParsedCookieTest, TestDoubleQuotedNameless) {
}
TEST(ParsedCookieTest, QuoteOffTheEnd) {
- CookieMonster::ParsedCookie pc("a=\"B");
+ net::CookieMonster::ParsedCookie pc("a=\"B");
EXPECT_TRUE(pc.IsValid());
EXPECT_EQ(pc.Name(), "a");
EXPECT_EQ(pc.Value(), "\"B");
}
TEST(ParsedCookieTest, MissingName) {
- CookieMonster::ParsedCookie pc("=ABC");
+ net::CookieMonster::ParsedCookie pc("=ABC");
EXPECT_TRUE(pc.IsValid());
EXPECT_EQ(pc.Name(), "");
EXPECT_EQ(pc.Value(), "ABC");
}
TEST(ParsedCookieTest, MissingValue) {
- CookieMonster::ParsedCookie pc("ABC=; path = /wee");
+ net::CookieMonster::ParsedCookie pc("ABC=; path = /wee");
EXPECT_TRUE(pc.IsValid());
EXPECT_EQ(pc.Name(), "ABC");
EXPECT_EQ(pc.Value(), "");
@@ -121,7 +121,7 @@ TEST(ParsedCookieTest, MissingValue) {
}
TEST(ParsedCookieTest, Whitespace) {
- CookieMonster::ParsedCookie pc(" A = BC ;secure;;; httponly");
+ net::CookieMonster::ParsedCookie pc(" A = BC ;secure;;; httponly");
EXPECT_TRUE(pc.IsValid());
EXPECT_EQ(pc.Name(), "A");
EXPECT_EQ(pc.Value(), "BC");
@@ -131,7 +131,7 @@ TEST(ParsedCookieTest, Whitespace) {
EXPECT_TRUE(pc.IsHttpOnly());
}
TEST(ParsedCookieTest, MultipleEquals) {
- CookieMonster::ParsedCookie pc(" A=== BC ;secure;;; httponly");
+ net::CookieMonster::ParsedCookie pc(" A=== BC ;secure;;; httponly");
EXPECT_TRUE(pc.IsValid());
EXPECT_EQ(pc.Name(), "A");
EXPECT_EQ(pc.Value(), "== BC");
@@ -142,9 +142,9 @@ TEST(ParsedCookieTest, MultipleEquals) {
}
TEST(ParsedCookieTest, TrailingWhitespace) {
- CookieMonster::ParsedCookie pc("ANCUUID=zohNumRKgI0oxyhSsV3Z7D; "
- "expires=Sun, 18-Apr-2027 21:06:29 GMT; "
- "path=/ ; ");
+ net::CookieMonster::ParsedCookie pc("ANCUUID=zohNumRKgI0oxyhSsV3Z7D; "
+ "expires=Sun, 18-Apr-2027 21:06:29 GMT; "
+ "path=/ ; ");
EXPECT_TRUE(pc.IsValid());
EXPECT_EQ(pc.Name(), "ANCUUID");
EXPECT_TRUE(pc.HasExpires());
@@ -156,43 +156,43 @@ TEST(ParsedCookieTest, TrailingWhitespace) {
TEST(ParsedCookieTest, TooManyPairs) {
std::string blankpairs;
- blankpairs.resize(CookieMonster::ParsedCookie::kMaxPairs - 1, ';');
+ blankpairs.resize(net::CookieMonster::ParsedCookie::kMaxPairs - 1, ';');
- CookieMonster::ParsedCookie pc1(blankpairs + "secure");
+ net::CookieMonster::ParsedCookie pc1(blankpairs + "secure");
EXPECT_TRUE(pc1.IsValid());
EXPECT_TRUE(pc1.IsSecure());
- CookieMonster::ParsedCookie pc2(blankpairs + ";secure");
+ net::CookieMonster::ParsedCookie pc2(blankpairs + ";secure");
EXPECT_TRUE(pc2.IsValid());
EXPECT_FALSE(pc2.IsSecure());
}
// TODO some better test cases for invalid cookies.
TEST(ParsedCookieTest, InvalidWhitespace) {
- CookieMonster::ParsedCookie pc(" ");
+ net::CookieMonster::ParsedCookie pc(" ");
EXPECT_FALSE(pc.IsValid());
}
TEST(ParsedCookieTest, InvalidTooLong) {
std::string maxstr;
- maxstr.resize(CookieMonster::ParsedCookie::kMaxCookieSize, 'a');
+ maxstr.resize(net::CookieMonster::ParsedCookie::kMaxCookieSize, 'a');
- CookieMonster::ParsedCookie pc1(maxstr);
+ net::CookieMonster::ParsedCookie pc1(maxstr);
EXPECT_TRUE(pc1.IsValid());
- CookieMonster::ParsedCookie pc2(maxstr + "A");
+ net::CookieMonster::ParsedCookie pc2(maxstr + "A");
EXPECT_FALSE(pc2.IsValid());
}
TEST(ParsedCookieTest, InvalidEmpty) {
- CookieMonster::ParsedCookie pc("");
+ net::CookieMonster::ParsedCookie pc("");
EXPECT_FALSE(pc.IsValid());
}
TEST(ParsedCookieTest, EmbeddedTerminator) {
- CookieMonster::ParsedCookie pc1("AAA=BB\0ZYX");
- CookieMonster::ParsedCookie pc2("AAA=BB\rZYX");
- CookieMonster::ParsedCookie pc3("AAA=BB\nZYX");
+ net::CookieMonster::ParsedCookie pc1("AAA=BB\0ZYX");
+ net::CookieMonster::ParsedCookie pc2("AAA=BB\rZYX");
+ net::CookieMonster::ParsedCookie pc3("AAA=BB\nZYX");
EXPECT_TRUE(pc1.IsValid());
EXPECT_EQ(pc1.Name(), "AAA");
EXPECT_EQ(pc1.Value(), "BB");
@@ -213,7 +213,7 @@ static const char kValidDomainCookieLine[] = "A=B; path=/; domain=google.izzle";
TEST(CookieMonsterTest, DomainTest) {
GURL url_google(kUrlGoogle);
- CookieMonster cm;
+ net::CookieMonster cm;
EXPECT_TRUE(cm.SetCookie(url_google, "A=B"));
EXPECT_EQ(cm.GetCookies(url_google), "A=B");
EXPECT_TRUE(cm.SetCookie(url_google, "C=D; domain=.google.izzle"));
@@ -244,7 +244,7 @@ TEST(CookieMonsterTest, DomainTest) {
// FireFox recognizes domains containing trailing periods as valid.
// IE and Safari do not. Assert the expected policy here.
TEST(CookieMonsterTest, DomainWithTrailingDotTest) {
- CookieMonster cm;
+ net::CookieMonster cm;
GURL url_google("http://www.google.com");
EXPECT_FALSE(cm.SetCookie(url_google, "a=1; domain=.www.google.com."));
@@ -255,7 +255,7 @@ TEST(CookieMonsterTest, DomainWithTrailingDotTest) {
// Test that cookies can bet set on higher level domains.
// http://b/issue?id=896491
TEST(CookieMonsterTest, ValidSubdomainTest) {
- CookieMonster cm;
+ net::CookieMonster cm;
GURL url_abcd("http://a.b.c.d.com");
GURL url_bcd("http://b.c.d.com");
GURL url_cd("http://c.d.com");
@@ -284,7 +284,7 @@ TEST(CookieMonsterTest, ValidSubdomainTest) {
// http://b/issue?id=896472
TEST(CookieMonsterTest, InvalidDomainTest) {
{
- CookieMonster cm;
+ net::CookieMonster cm;
GURL url_foobar("http://foo.bar.com");
// More specific sub-domain than allowed.
@@ -321,7 +321,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.
- CookieMonster cm;
+ net::CookieMonster cm;
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), "");
@@ -333,16 +333,16 @@ TEST(CookieMonsterTest, InvalidDomainTest) {
// http://b/issue?id=889898
TEST(CookieMonsterTest, DomainWithoutLeadingDotTest) {
{ // The omission of dot results in setting a domain cookie.
- CookieMonster cm;
- 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"));
- EXPECT_EQ(cm.GetCookies(url_hosted), "sawAd=1");
- EXPECT_EQ(cm.GetCookies(url_filefront), "sawAd=1");
+ net::CookieMonster cm;
+ 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"));
+ EXPECT_EQ(cm.GetCookies(url_hosted), "sawAd=1");
+ EXPECT_EQ(cm.GetCookies(url_filefront), "sawAd=1");
}
{ // Even when the domains match exactly, don't consider it host cookie.
- CookieMonster cm;
+ net::CookieMonster cm;
GURL url("http://www.google.com");
EXPECT_TRUE(cm.SetCookie(url, "a=1; domain=www.google.com"));
EXPECT_EQ(cm.GetCookies(url), "a=1");
@@ -354,7 +354,7 @@ TEST(CookieMonsterTest, DomainWithoutLeadingDotTest) {
// Test that the domain specified in cookie string is treated case-insensitive
// http://b/issue?id=896475.
TEST(CookieMonsterTest, CaseInsensitiveDomainTest) {
- CookieMonster cm;
+ net::CookieMonster cm;
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"));
@@ -364,83 +364,83 @@ TEST(CookieMonsterTest, CaseInsensitiveDomainTest) {
TEST(CookieMonsterTest, TestIpAddress) {
GURL url_ip("http://1.2.3.4/weee");
{
- CookieMonster cm;
- EXPECT_TRUE(cm.SetCookie(url_ip, kValidCookieLine));
- EXPECT_EQ(cm.GetCookies(url_ip), "A=B");
+ net::CookieMonster cm;
+ EXPECT_TRUE(cm.SetCookie(url_ip, kValidCookieLine));
+ EXPECT_EQ(cm.GetCookies(url_ip), "A=B");
}
{ // IP addresses should not be able to set domain cookies.
- CookieMonster cm;
- 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), "");
+ net::CookieMonster cm;
+ 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), "");
}
}
// Test host cookies, and setting of cookies on TLD.
TEST(CookieMonsterTest, TestNonDottedAndTLD) {
{
- CookieMonster cm;
- GURL url("http://com/");
- // Allow setting on "com", (but only as a host cookie).
- EXPECT_TRUE(cm.SetCookie(url, "a=1"));
- EXPECT_FALSE(cm.SetCookie(url, "b=2; domain=.com"));
- EXPECT_FALSE(cm.SetCookie(url, "c=3; domain=com"));
- EXPECT_EQ(cm.GetCookies(url), "a=1");
- // Make sure it doesn't show up for a normal .com, it should be a host
- // not a domain cookie.
- EXPECT_EQ(cm.GetCookies(GURL("http://hopefully-no-cookies.com/")), "");
- EXPECT_EQ(cm.GetCookies(GURL("http://.com/")), "");
+ net::CookieMonster cm;
+ GURL url("http://com/");
+ // Allow setting on "com", (but only as a host cookie).
+ EXPECT_TRUE(cm.SetCookie(url, "a=1"));
+ EXPECT_FALSE(cm.SetCookie(url, "b=2; domain=.com"));
+ EXPECT_FALSE(cm.SetCookie(url, "c=3; domain=com"));
+ EXPECT_EQ(cm.GetCookies(url), "a=1");
+ // Make sure it doesn't show up for a normal .com, it should be a host
+ // not a domain cookie.
+ EXPECT_EQ(cm.GetCookies(GURL("http://hopefully-no-cookies.com/")), "");
+ EXPECT_EQ(cm.GetCookies(GURL("http://.com/")), "");
}
{ // http://com. should be treated the same as http://com.
- CookieMonster cm;
- GURL url("http://com./index.html");
- EXPECT_TRUE(cm.SetCookie(url, "a=1"));
- EXPECT_EQ(cm.GetCookies(url), "a=1");
- EXPECT_EQ(cm.GetCookies(GURL("http://hopefully-no-cookies.com./")), "");
+ net::CookieMonster cm;
+ GURL url("http://com./index.html");
+ EXPECT_TRUE(cm.SetCookie(url, "a=1"));
+ EXPECT_EQ(cm.GetCookies(url), "a=1");
+ EXPECT_EQ(cm.GetCookies(GURL("http://hopefully-no-cookies.com./")), "");
}
{ // Should not be able to set host cookie from a subdomain.
- CookieMonster cm;
- GURL url("http://a.b");
- EXPECT_FALSE(cm.SetCookie(url, "a=1; domain=.b"));
- EXPECT_FALSE(cm.SetCookie(url, "b=2; domain=b"));
- EXPECT_EQ(cm.GetCookies(url), "");
+ net::CookieMonster cm;
+ GURL url("http://a.b");
+ EXPECT_FALSE(cm.SetCookie(url, "a=1; domain=.b"));
+ EXPECT_FALSE(cm.SetCookie(url, "b=2; domain=b"));
+ EXPECT_EQ(cm.GetCookies(url), "");
}
{ // Same test as above, but explicitly on a known TLD (com).
- CookieMonster cm;
- GURL url("http://google.com");
- EXPECT_FALSE(cm.SetCookie(url, "a=1; domain=.com"));
- EXPECT_FALSE(cm.SetCookie(url, "b=2; domain=com"));
- EXPECT_EQ(cm.GetCookies(url), "");
+ net::CookieMonster cm;
+ GURL url("http://google.com");
+ EXPECT_FALSE(cm.SetCookie(url, "a=1; domain=.com"));
+ EXPECT_FALSE(cm.SetCookie(url, "b=2; domain=com"));
+ EXPECT_EQ(cm.GetCookies(url), "");
}
{ // Make sure can't set cookie on TLD which is dotted.
- CookieMonster cm;
- 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"));
- EXPECT_EQ(cm.GetCookies(url), "");
- EXPECT_EQ(cm.GetCookies(GURL("http://something-else.co.uk")), "");
- EXPECT_EQ(cm.GetCookies(GURL("http://something-else.uk")), "");
+ net::CookieMonster cm;
+ 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"));
+ EXPECT_EQ(cm.GetCookies(url), "");
+ EXPECT_EQ(cm.GetCookies(GURL("http://something-else.co.uk")), "");
+ EXPECT_EQ(cm.GetCookies(GURL("http://something-else.uk")), "");
}
{ // Intranet URLs should only be able to set host cookies.
- CookieMonster cm;
- GURL url("http://b");
- EXPECT_TRUE(cm.SetCookie(url, "a=1"));
- EXPECT_FALSE(cm.SetCookie(url, "b=2; domain=.b"));
- EXPECT_FALSE(cm.SetCookie(url, "c=3; domain=b"));
- EXPECT_EQ(cm.GetCookies(url), "a=1");
+ net::CookieMonster cm;
+ GURL url("http://b");
+ EXPECT_TRUE(cm.SetCookie(url, "a=1"));
+ EXPECT_FALSE(cm.SetCookie(url, "b=2; domain=.b"));
+ EXPECT_FALSE(cm.SetCookie(url, "c=3; domain=b"));
+ EXPECT_EQ(cm.GetCookies(url), "a=1");
}
}
// Test reading/writing cookies when the domain ends with a period,
// as in "www.google.com."
TEST(CookieMonsterTest, TestHostEndsWithDot) {
- CookieMonster cm;
+ net::CookieMonster cm;
GURL url("http://www.google.com");
GURL url_with_dot("http://www.google.com.");
EXPECT_TRUE(cm.SetCookie(url, "a=1"));
@@ -460,19 +460,19 @@ TEST(CookieMonsterTest, TestHostEndsWithDot) {
}
TEST(CookieMonsterTest, InvalidScheme) {
- CookieMonster cm;
+ net::CookieMonster cm;
EXPECT_FALSE(cm.SetCookie(GURL(kUrlFtp), kValidCookieLine));
}
TEST(CookieMonsterTest, InvalidScheme_Read) {
- CookieMonster cm;
+ net::CookieMonster cm;
EXPECT_TRUE(cm.SetCookie(GURL(kUrlGoogle), kValidDomainCookieLine));
EXPECT_EQ(cm.GetCookies(GURL(kUrlFtp)), "");
}
TEST(CookieMonsterTest, PathTest) {
std::string url("http://www.google.izzle");
- CookieMonster cm;
+ net::CookieMonster cm;
EXPECT_TRUE(cm.SetCookie(GURL(url), "A=B; path=/wee"));
EXPECT_EQ(cm.GetCookies(GURL(url + "/wee")), "A=B");
EXPECT_EQ(cm.GetCookies(GURL(url + "/wee/")), "A=B");
@@ -489,11 +489,11 @@ TEST(CookieMonsterTest, PathTest) {
TEST(CookieMonsterTest, HttpOnlyTest) {
GURL url_google(kUrlGoogle);
- CookieMonster cm;
+ net::CookieMonster cm;
EXPECT_TRUE(cm.SetCookie(url_google, "A=B; httponly"));
EXPECT_EQ(cm.GetCookies(url_google), "");
- EXPECT_EQ(cm.GetCookiesWithOptions(url_google,
- CookieMonster::INCLUDE_HTTPONLY), "A=B");
+ EXPECT_EQ(cm.GetCookiesWithOptions(
+ url_google, net::CookieMonster::INCLUDE_HTTPONLY), "A=B");
}
// From: http://support.microsoft.com/kb/167296.
@@ -506,12 +506,12 @@ static void UnixTimeToFileTime(time_t t, LPFILETIME pft) {
}
static uint64 UnixTimeToUTC(time_t t) {
- FILETIME ftime;
- LARGE_INTEGER li;
- UnixTimeToFileTime(t, &ftime);
- li.LowPart = ftime.dwLowDateTime;
- li.HighPart = ftime.dwHighDateTime;
- return li.QuadPart;
+ FILETIME ftime;
+ LARGE_INTEGER li;
+ UnixTimeToFileTime(t, &ftime);
+ li.LowPart = ftime.dwLowDateTime;
+ li.HighPart = ftime.dwHighDateTime;
+ return li.QuadPart;
}
TEST(CookieMonsterTest, TestCookieDateParsing) {
@@ -592,7 +592,7 @@ TEST(CookieMonsterTest, TestCookieDateParsing) {
Time parsed_time;
for (int i = 0; i < arraysize(tests); ++i) {
- parsed_time = CookieMonster::ParseCookieTime(tests[i].str);
+ parsed_time = net::CookieMonster::ParseCookieTime(tests[i].str);
if (!tests[i].valid) {
EXPECT_FALSE(!parsed_time.is_null()) << tests[i].str;
continue;
@@ -604,7 +604,7 @@ TEST(CookieMonsterTest, TestCookieDateParsing) {
TEST(CookieMonsterTest, TestCookieDeletion) {
GURL url_google(kUrlGoogle);
- CookieMonster cm;
+ net::CookieMonster cm;
// Create a session cookie.
EXPECT_TRUE(cm.SetCookie(url_google, kValidCookieLine));
@@ -647,7 +647,7 @@ TEST(CookieMonsterTest, TestCookieDeletion) {
TEST(CookieMonsterTest, TestCookieDeleteAll) {
GURL url_google(kUrlGoogle);
- CookieMonster cm;
+ net::CookieMonster cm;
EXPECT_TRUE(cm.SetCookie(url_google, kValidCookieLine));
EXPECT_EQ(cm.GetCookies(url_google), "A=B");
@@ -661,7 +661,7 @@ TEST(CookieMonsterTest, TestCookieDeleteAll) {
TEST(CookieMonsterTest, TestCookieDeleteAllCreatedAfterTimestamp) {
GURL url_google(kUrlGoogle);
- CookieMonster cm;
+ net::CookieMonster cm;
Time now = Time::Now();
// Nothing has been added so nothing should be deleted.
@@ -689,7 +689,7 @@ TEST(CookieMonsterTest, TestCookieDeleteAllCreatedAfterTimestamp) {
TEST(CookieMonsterTest, TestCookieDeleteAllCreatedBetweenTimestamps) {
GURL url_google(kUrlGoogle);
- CookieMonster cm;
+ net::CookieMonster cm;
Time now = Time::Now();
// Nothing has been added so nothing should be deleted.
@@ -732,7 +732,7 @@ TEST(CookieMonsterTest, TestCookieDeleteAllCreatedBetweenTimestamps) {
TEST(CookieMonsterTest, TestSecure) {
GURL url_google(kUrlGoogle);
GURL url_google_secure(kUrlGoogleSecure);
- CookieMonster cm;
+ net::CookieMonster cm;
EXPECT_TRUE(cm.SetCookie(url_google, "A=B"));
EXPECT_EQ(cm.GetCookies(url_google), "A=B");
@@ -765,7 +765,7 @@ static int CountInString(const std::string& str, char c) {
TEST(CookieMonsterTest, TestHostGarbageCollection) {
GURL url_google(kUrlGoogle);
- CookieMonster cm;
+ net::CookieMonster cm;
// Add a bunch of cookies on a single host, should purge them.
for (int i = 0; i < 101; i++) {
std::string cookie = StringPrintf("a%03d=b", i);
@@ -779,7 +779,7 @@ TEST(CookieMonsterTest, TestHostGarbageCollection) {
}
TEST(CookieMonsterTest, TestTotalGarbageCollection) {
- CookieMonster cm;
+ net::CookieMonster cm;
// Add a bunch of cookies on a bunch of host, some should get purged.
for (int i = 0; i < 2000; ++i) {
GURL url(StringPrintf("http://a%04d.izzle", i));
@@ -804,7 +804,7 @@ TEST(CookieMonsterTest, TestTotalGarbageCollection) {
TEST(CookieMonsterTest, NetUtilCookieTest) {
const GURL test_url(L"http://mojo.jojo.google.izzle/");
- CookieMonster cm;
+ net::CookieMonster cm;
EXPECT_TRUE(cm.SetCookie(test_url, "foo=bar"));
std::string value = cm.GetCookies(test_url);
@@ -820,10 +820,11 @@ TEST(CookieMonsterTest, NetUtilCookieTest) {
EXPECT_TRUE(result.find("y=2") != std::string::npos) << result;
}
-static bool FindAndDeleteCookie(CookieMonster& cm, const std::string& domain,
+static bool FindAndDeleteCookie(net::CookieMonster& cm,
+ const std::string& domain,
const std::string& name) {
- CookieMonster::CookieList cookies = cm.GetAllCookies();
- for (CookieMonster::CookieList::iterator it = cookies.begin();
+ net::CookieMonster::CookieList cookies = cm.GetAllCookies();
+ for (net::CookieMonster::CookieList::iterator it = cookies.begin();
it != cookies.end(); ++it)
if (it->first == domain && it->second.Name() == name)
return cm.DeleteCookie(domain, it->second, false);
@@ -833,7 +834,7 @@ static bool FindAndDeleteCookie(CookieMonster& cm, const std::string& domain,
TEST(CookieMonsterTest, TestDeleteSingleCookie) {
GURL url_google(kUrlGoogle);
- CookieMonster cm;
+ net::CookieMonster cm;
EXPECT_TRUE(cm.SetCookie(url_google, "A=B"));
EXPECT_TRUE(cm.SetCookie(url_google, "C=D"));
EXPECT_TRUE(cm.SetCookie(url_google, "E=F"));
diff --git a/net/base/cookie_policy.cc b/net/base/cookie_policy.cc
index f0b2199e..da859ee 100644
--- a/net/base/cookie_policy.cc
+++ b/net/base/cookie_policy.cc
@@ -27,10 +27,13 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include "base/logging.h"
#include "net/base/cookie_policy.h"
+
+#include "base/logging.h"
#include "net/base/registry_controlled_domain.h"
+namespace net {
+
bool CookiePolicy::CanGetCookies(const GURL& url, const GURL& policy_url) {
switch (type_) {
case CookiePolicy::ALLOW_ALL_COOKIES:
@@ -53,7 +56,7 @@ bool CookiePolicy::CanSetCookie(const GURL& url, const GURL& policy_url) {
if (policy_url.is_empty())
return true; // Empty policy URL should indicate a first-party request
- return RegistryControlledDomainService::SameDomainOrHost(url, policy_url);
+ return net::RegistryControlledDomainService::SameDomainOrHost(url, policy_url);
case CookiePolicy::BLOCK_ALL_COOKIES:
return false;
default:
@@ -62,5 +65,7 @@ bool CookiePolicy::CanSetCookie(const GURL& url, const GURL& policy_url) {
}
}
-CookiePolicy::CookiePolicy()
- : type_(CookiePolicy::ALLOW_ALL_COOKIES) { } \ No newline at end of file
+CookiePolicy::CookiePolicy() : type_(CookiePolicy::ALLOW_ALL_COOKIES) {
+}
+
+} // namespace net
diff --git a/net/base/cookie_policy.h b/net/base/cookie_policy.h
index 0523c95..6c7b0e6 100644
--- a/net/base/cookie_policy.h
+++ b/net/base/cookie_policy.h
@@ -32,6 +32,8 @@
#include "googleurl/src/gurl.h"
+namespace net {
+
// The CookiePolicy class implements third-party cookie blocking.
class CookiePolicy {
public:
@@ -69,4 +71,6 @@ class CookiePolicy {
DISALLOW_EVIL_CONSTRUCTORS(CookiePolicy);
};
+} // namespace net
+
#endif // NET_BASE_COOKIE_POLICY_H__
diff --git a/net/base/cookie_policy_unittest.cc b/net/base/cookie_policy_unittest.cc
index e63ec24..7d2ce8e 100644
--- a/net/base/cookie_policy_unittest.cc
+++ b/net/base/cookie_policy_unittest.cc
@@ -49,7 +49,7 @@ class CookiePolicyTest : public testing::Test {
} // namespace
TEST_F(CookiePolicyTest, DefaultPolicyTest) {
- CookiePolicy cp;
+ net::CookiePolicy cp;
EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_));
EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_secure_));
EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_mail_));
@@ -64,8 +64,8 @@ TEST_F(CookiePolicyTest, DefaultPolicyTest) {
}
TEST_F(CookiePolicyTest, AllowAllCookiesTest) {
- CookiePolicy cp;
- cp.SetType(CookiePolicy::ALLOW_ALL_COOKIES);
+ net::CookiePolicy cp;
+ cp.SetType(net::CookiePolicy::ALLOW_ALL_COOKIES);
EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_));
EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_secure_));
@@ -81,8 +81,8 @@ TEST_F(CookiePolicyTest, AllowAllCookiesTest) {
}
TEST_F(CookiePolicyTest, BlockThirdPartyCookiesTest) {
- CookiePolicy cp;
- cp.SetType(CookiePolicy::BLOCK_THIRD_PARTY_COOKIES);
+ net::CookiePolicy cp;
+ cp.SetType(net::CookiePolicy::BLOCK_THIRD_PARTY_COOKIES);
EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_));
EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_secure_));
@@ -98,8 +98,8 @@ TEST_F(CookiePolicyTest, BlockThirdPartyCookiesTest) {
}
TEST_F(CookiePolicyTest, BlockAllCookiesTest) {
- CookiePolicy cp;
- cp.SetType(CookiePolicy::BLOCK_ALL_COOKIES);
+ net::CookiePolicy cp;
+ cp.SetType(net::CookiePolicy::BLOCK_ALL_COOKIES);
EXPECT_FALSE(cp.CanGetCookies(url_google_, url_google_));
EXPECT_FALSE(cp.CanGetCookies(url_google_, url_google_secure_));
diff --git a/net/base/listen_socket_unittest.h b/net/base/listen_socket_unittest.h
index 8160ade..243696c 100644
--- a/net/base/listen_socket_unittest.h
+++ b/net/base/listen_socket_unittest.h
@@ -99,7 +99,7 @@ class ListenSocketTester :
InitializeCriticalSection(&lock_);
semaphore_ = CreateSemaphore(NULL, 0, MAX_QUEUE_SIZE, NULL);
server_ = NULL;
- WinsockInit::Init();
+ net::WinsockInit::Init();
thread_.reset(new Thread("socketio_test"));
thread_->Start();
@@ -148,7 +148,7 @@ class ListenSocketTester :
}
thread_.reset();
loop_ = NULL;
- WinsockInit::Cleanup();
+ net::WinsockInit::Cleanup();
}
void ReportAction(const ListenSocketTestAction& action) {
diff --git a/net/base/net_module.cc b/net/base/net_module.cc
index 7fa21f2..df5b883 100644
--- a/net/base/net_module.cc
+++ b/net/base/net_module.cc
@@ -29,6 +29,8 @@
#include "net/base/net_module.h"
+namespace net {
+
static NetModule::ResourceProvider resource_provider;
// static
@@ -42,3 +44,5 @@ std::string NetModule::GetResource(int key) {
ResourceProvider func = resource_provider;
return func ? func(key) : std::string();
}
+
+} // namespace net
diff --git a/net/base/net_module.h b/net/base/net_module.h
index 37698cc..2ae3774 100644
--- a/net/base/net_module.h
+++ b/net/base/net_module.h
@@ -34,6 +34,8 @@
#include "base/basictypes.h"
+namespace net {
+
// Defines global initializers and associated methods for the net module.
//
// The network module does not have direct access to the way application
@@ -57,4 +59,6 @@ class NetModule {
DISALLOW_IMPLICIT_CONSTRUCTORS(NetModule);
};
+} // namespace net
+
#endif // NET_BASE_NET_MODULE_H__
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index 61b5f87..e339838 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -660,7 +660,7 @@ std::wstring LocalizedDateTime(const FILETIME* filetime) {
} // namespace
-namespace net_util {
+namespace net {
GURL FilePathToFileURL(const std::wstring& file_path) {
// Produce a URL like "file:///C:/foo" for a regular file, or
@@ -992,4 +992,4 @@ bool IsPortAllowedByFtp(int port) {
return IsPortAllowedByDefault(port);
}
-} // namespace net_util
+} // namespace net
diff --git a/net/base/net_util.h b/net/base/net_util.h
index d0955a1..ab89182 100644
--- a/net/base/net_util.h
+++ b/net/base/net_util.h
@@ -39,7 +39,7 @@
class GURL;
-namespace net_util {
+namespace net {
// Given the full path to a file name, creates a file: URL. The returned URL
// may not be valid if the input is malformed.
@@ -148,6 +148,6 @@ bool IsPortAllowedByDefault(int port);
// restricted.
bool IsPortAllowedByFtp(int port);
-} // namespace net_util
+} // namespace net
#endif // NET_BASE_NET_UTIL_H__
diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc
index c0b1f7c..4c49c37 100644
--- a/net/base/net_util_unittest.cc
+++ b/net/base/net_util_unittest.cc
@@ -55,12 +55,12 @@ TEST(NetUtilTest, FileURLConversion) {
std::wstring output;
for (int i = 0; i < arraysize(round_trip_cases); i++) {
// convert to the file URL
- GURL file_url(net_util::FilePathToFileURL(round_trip_cases[i].file));
+ GURL file_url(net::FilePathToFileURL(round_trip_cases[i].file));
EXPECT_EQ(std::wstring(round_trip_cases[i].url),
UTF8ToWide(file_url.spec()));
// Back to the filename.
- EXPECT_TRUE(net_util::FileURLToFilePath(file_url, &output));
+ EXPECT_TRUE(net::FileURLToFilePath(file_url, &output));
EXPECT_EQ(std::wstring(round_trip_cases[i].file), output);
}
@@ -76,7 +76,7 @@ TEST(NetUtilTest, FileURLConversion) {
{L"C:\\foo\\bar.txt", L"file:\\\\\\c:/foo/bar.txt"},
};
for (int i = 0; i < arraysize(url_cases); i++) {
- net_util::FileURLToFilePath(GURL(url_cases[i].url), &output);
+ net::FileURLToFilePath(GURL(url_cases[i].url), &output);
EXPECT_EQ(std::wstring(url_cases[i].file), output);
}
@@ -84,7 +84,7 @@ TEST(NetUtilTest, FileURLConversion) {
// they might be stored with wide characters
const wchar_t utf8[] = L"file:///d:/Chinese/\xe6\x89\x80\xe6\x9c\x89\xe4\xb8\xad\xe6\x96\x87\xe7\xbd\x91\xe9\xa1\xb5.doc";
const wchar_t wide[] = L"D:\\Chinese\\\x6240\x6709\x4e2d\x6587\x7f51\x9875.doc";
- EXPECT_TRUE(net_util::FileURLToFilePath(GURL(utf8), &output));
+ EXPECT_TRUE(net::FileURLToFilePath(GURL(utf8), &output));
EXPECT_EQ(std::wstring(wide), output);
// Unfortunately, UTF8ToWide discards invalid UTF8 input.
@@ -93,13 +93,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_util::FileURLToFilePath(
+ EXPECT_TRUE(net::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_util::FileURLToFilePath(GURL("filefoobar"), &output));
+ EXPECT_FALSE(net::FileURLToFilePath(GURL("filefoobar"), &output));
}
// Just a bunch of fake headers.
@@ -138,14 +138,14 @@ TEST(NetUtilTest, GetSpecificHeader) {
// Test first with google_headers.
for (size_t i = 0; i < arraysize(tests); ++i) {
- std::wstring result = net_util::GetSpecificHeader(google_headers,
- tests[i].header_name);
+ std::wstring result = net::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(tests); ++i) {
- std::wstring result = net_util::GetSpecificHeader(L"", tests[i].header_name);
+ std::wstring result = net::GetSpecificHeader(L"", tests[i].header_name);
EXPECT_EQ(result, std::wstring());
}
}
@@ -171,18 +171,18 @@ TEST(NetUtilTest, GetHeaderParamValue) {
// TODO(mpcomplete): add tests for other formats of headers.
for (size_t i = 0; i < arraysize(tests); ++i) {
- std::wstring header_value = net_util::GetSpecificHeader(google_headers,
- tests[i].header_name);
- std::wstring result = net_util::GetHeaderParamValue(header_value,
- tests[i].param_name);
+ std::wstring header_value =
+ net::GetSpecificHeader(google_headers, tests[i].header_name);
+ std::wstring result =
+ net::GetHeaderParamValue(header_value, tests[i].param_name);
EXPECT_EQ(result, tests[i].expected);
}
for (size_t i = 0; i < arraysize(tests); ++i) {
- std::wstring header_value = net_util::GetSpecificHeader(L"",
- tests[i].header_name);
- std::wstring result = net_util::GetHeaderParamValue(header_value,
- tests[i].param_name);
+ std::wstring header_value =
+ net::GetSpecificHeader(L"", tests[i].header_name);
+ std::wstring result =
+ net::GetHeaderParamValue(header_value, tests[i].param_name);
EXPECT_EQ(result, std::wstring());
}
}
@@ -260,7 +260,7 @@ TEST(NetUtilTest, GetFileNameFromCD) {
};
for (size_t i = 0; i < arraysize(tests); ++i) {
EXPECT_EQ(tests[i].expected,
- net_util::GetFileNameFromCD(tests[i].header_field));
+ net::GetFileNameFromCD(tests[i].header_field));
}
}
@@ -548,10 +548,10 @@ TEST(NetUtilTest, IDNToUnicode) {
for (int i = 0; i < arraysize(idn_cases); i++) {
for (int j = 0; j < arraysize(languages); j++) {
std::wstring output;
- net_util::IDNToUnicode(idn_cases[i].input,
- static_cast<int>(strlen(idn_cases[i].input)),
- languages[j],
- &output);
+ net::IDNToUnicode(idn_cases[i].input,
+ static_cast<int>(strlen(idn_cases[i].input)),
+ languages[j],
+ &output);
std::wstring expected(idn_cases[i].unicode_allowed[j] ?
idn_cases[i].unicode_output :
ASCIIToWide(idn_cases[i].input));
@@ -561,10 +561,10 @@ TEST(NetUtilTest, IDNToUnicode) {
}
TEST(NetUtilTest, StripWWW) {
- EXPECT_EQ(L"", net_util::StripWWW(L""));
- EXPECT_EQ(L"", net_util::StripWWW(L"www."));
- EXPECT_EQ(L"blah", net_util::StripWWW(L"www.blah"));
- EXPECT_EQ(L"blah", net_util::StripWWW(L"blah"));
+ EXPECT_EQ(L"", net::StripWWW(L""));
+ EXPECT_EQ(L"", net::StripWWW(L"www."));
+ EXPECT_EQ(L"blah", net::StripWWW(L"www.blah"));
+ EXPECT_EQ(L"blah", net::StripWWW(L"blah"));
}
TEST(NetUtilTest, GetSuggestedFilename) {
@@ -663,7 +663,7 @@ TEST(NetUtilTest, GetSuggestedFilename) {
L"test.html"},
};
for (int i = 0; i < arraysize(test_cases); ++i) {
- std::wstring filename = net_util::GetSuggestedFilename(
+ std::wstring filename = net::GetSuggestedFilename(
GURL(test_cases[i].url), test_cases[i].content_disp_header,
test_cases[i].default_filename);
EXPECT_EQ(std::wstring(test_cases[i].expected_filename), filename);
diff --git a/net/base/registry_controlled_domain.cc b/net/base/registry_controlled_domain.cc
index b573d17..f0aad4c 100644
--- a/net/base/registry_controlled_domain.cc
+++ b/net/base/registry_controlled_domain.cc
@@ -48,6 +48,8 @@
#include "net/base/net_util.h"
#include "net/base/registry_controlled_domain.h"
+namespace net {
+
// This list of rules is used by unit tests and any other time that the main
// resource file is not available. It should be kept exceedingly short to
// avoid impacting unit test performance.
@@ -73,8 +75,7 @@ std::string RegistryControlledDomainService::GetDomainAndRegistry(
std::string RegistryControlledDomainService::GetDomainAndRegistry(
const std::string& host) {
bool is_ip_address;
- const std::string canon_host(net_util::CanonicalizeHost(host,
- &is_ip_address));
+ const std::string canon_host(net::CanonicalizeHost(host, &is_ip_address));
if (canon_host.empty() || is_ip_address)
return std::string();
return GetDomainAndRegistryImpl(canon_host);
@@ -84,8 +85,7 @@ std::string RegistryControlledDomainService::GetDomainAndRegistry(
std::string RegistryControlledDomainService::GetDomainAndRegistry(
const std::wstring& host) {
bool is_ip_address;
- const std::string canon_host(net_util::CanonicalizeHost(host,
- &is_ip_address));
+ const std::string canon_host(net::CanonicalizeHost(host, &is_ip_address));
if (canon_host.empty() || is_ip_address)
return std::string();
return GetDomainAndRegistryImpl(canon_host);
@@ -133,8 +133,7 @@ size_t RegistryControlledDomainService::GetRegistryLength(
const std::string& host,
bool allow_unknown_registries) {
bool is_ip_address;
- const std::string canon_host(net_util::CanonicalizeHost(host,
- &is_ip_address));
+ const std::string canon_host(net::CanonicalizeHost(host, &is_ip_address));
if (canon_host.empty())
return std::string::npos;
if (is_ip_address)
@@ -148,8 +147,7 @@ size_t RegistryControlledDomainService::GetRegistryLength(
const std::wstring& host,
bool allow_unknown_registries) {
bool is_ip_address;
- const std::string canon_host(net_util::CanonicalizeHost(host,
- &is_ip_address));
+ const std::string canon_host(net::CanonicalizeHost(host, &is_ip_address));
if (canon_host.empty())
return std::string::npos;
if (is_ip_address)
@@ -349,3 +347,5 @@ bool RegistryControlledDomainService::StringSegment::operator<(
}
return (len_ < other.len_);
}
+
+} // namespace net
diff --git a/net/base/registry_controlled_domain.h b/net/base/registry_controlled_domain.h
index 6b5adbc..72d7512 100644
--- a/net/base/registry_controlled_domain.h
+++ b/net/base/registry_controlled_domain.h
@@ -117,6 +117,8 @@
class GURL;
+namespace net {
+
// This class is a singleton.
class RegistryControlledDomainService {
public:
@@ -295,4 +297,6 @@ class RegistryControlledDomainService {
DISALLOW_EVIL_CONSTRUCTORS(RegistryControlledDomainService);
};
+} // namespace net
+
#endif // NET_BASE_REGISTRY_CONTROLLED_DOMAIN_H__
diff --git a/net/base/registry_controlled_domain_unittest.cc b/net/base/registry_controlled_domain_unittest.cc
index cd74fc5..590f17b 100644
--- a/net/base/registry_controlled_domain_unittest.cc
+++ b/net/base/registry_controlled_domain_unittest.cc
@@ -37,17 +37,17 @@ class TestRegistryControlledDomainService;
static TestRegistryControlledDomainService* test_instance_;
class TestRegistryControlledDomainService :
- public RegistryControlledDomainService {
+ public net::RegistryControlledDomainService {
public:
// Deletes the instance so a new one will be created.
static void ResetInstance() {
- RegistryControlledDomainService::ResetInstance();
+ net::RegistryControlledDomainService::ResetInstance();
}
// Sets and parses the given data.
static void UseDomainData(const std::string& data) {
- RegistryControlledDomainService::UseDomainData(data);
+ net::RegistryControlledDomainService::UseDomainData(data);
}
private:
diff --git a/net/base/winsock_init.cc b/net/base/winsock_init.cc
index e164b92..0bef93a 100644
--- a/net/base/winsock_init.cc
+++ b/net/base/winsock_init.cc
@@ -33,6 +33,8 @@
#include "base/singleton.h"
+namespace net {
+
WinsockInit::WinsockInit() : did_init_(false) {
did_init_ = Init();
}
@@ -55,3 +57,5 @@ WinsockInit::~WinsockInit() {
void EnsureWinsockInit() {
Singleton<WinsockInit>::get();
}
+
+} // namespace net
diff --git a/net/base/winsock_init.h b/net/base/winsock_init.h
index 40d0557..6415bef 100644
--- a/net/base/winsock_init.h
+++ b/net/base/winsock_init.h
@@ -37,6 +37,8 @@
#ifndef NET_BASE_WINSOCK_INIT_H_
#define NET_BASE_WINSOCK_INIT_H_
+namespace net {
+
class WinsockInit {
public:
WinsockInit();
@@ -53,4 +55,6 @@ class WinsockInit {
// destroyed at application exit. This may be called multiple times.
void EnsureWinsockInit();
+} // namespace net
+
#endif // NET_BASE_WINSOCK_INIT_H_
diff --git a/net/base/x509_certificate.cc b/net/base/x509_certificate.cc
index 445f128..e82f245 100644
--- a/net/base/x509_certificate.cc
+++ b/net/base/x509_certificate.cc
@@ -42,6 +42,8 @@
#pragma comment(lib, "crypt32.lib")
+namespace net {
+
namespace {
// Returns true if this cert fingerprint is the null (all zero) fingerprint.
@@ -567,3 +569,5 @@ void X509Certificate::Policy::Deny(X509Certificate* cert) {
allowed_.erase(cert->fingerprint());
denied_.insert(cert->fingerprint());
}
+
+} // namespace net
diff --git a/net/base/x509_certificate.h b/net/base/x509_certificate.h
index 217b331..3d0f779 100644
--- a/net/base/x509_certificate.h
+++ b/net/base/x509_certificate.h
@@ -27,8 +27,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#ifndef CHROME_COMMON_NET_X509_CERTIFICATE_H__
-#define CHROME_COMMON_NET_X509_CERTIFICATE_H__
+#ifndef NET_BASE_X509_CERTIFICATE_H_
+#define NET_BASE_X509_CERTIFICATE_H_
#include <windows.h>
#include <wincrypt.h>
@@ -42,6 +42,8 @@
class Pickle;
+namespace net {
+
// X509Certificate represents an X.509 certificate used by SSL.
class X509Certificate : public base::RefCountedThreadSafe<X509Certificate> {
public:
@@ -210,4 +212,6 @@ class X509Certificate : public base::RefCountedThreadSafe<X509Certificate> {
DISALLOW_EVIL_CONSTRUCTORS(X509Certificate);
};
-#endif // CHROME_COMMON_NET_X509_CERTIFICATE_H__
+} // namespace net
+
+#endif // NET_BASE_X509_CERTIFICATE_H_
diff --git a/net/http/http_transaction_winhttp.cc b/net/http/http_transaction_winhttp.cc
index 6570b0d..1c0914b 100644
--- a/net/http/http_transaction_winhttp.cc
+++ b/net/http/http_transaction_winhttp.cc
@@ -1549,7 +1549,7 @@ void HttpTransactionWinHttp::PopulateAuthChallenge() {
std::wstring::const_iterator space = find(auth_header.begin(),
auth_header.end(), ' ');
auth_info->scheme.assign(auth_header.begin(), space);
- auth_info->realm = net_util::GetHeaderParamValue(auth_header, L"realm");
+ auth_info->realm = GetHeaderParamValue(auth_header, L"realm");
// Now auth_info has been fully populated. Before we swap it with
// response_.auth_challenge, update the auth cache key and remove any
diff --git a/net/url_request/mime_sniffer_proxy.h b/net/url_request/mime_sniffer_proxy.h
index af02dfd..9263863 100644
--- a/net/url_request/mime_sniffer_proxy.h
+++ b/net/url_request/mime_sniffer_proxy.h
@@ -68,7 +68,7 @@ class MimeSnifferProxy : public URLRequest::Delegate {
}
virtual void OnSSLCertificateError(URLRequest* request,
int cert_error,
- X509Certificate* cert) {
+ net::X509Certificate* cert) {
delegate_->OnSSLCertificateError(request, cert_error, cert);
}
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h
index 6740975..ed0eac1 100644
--- a/net/url_request/url_request.h
+++ b/net/url_request/url_request.h
@@ -144,7 +144,7 @@ class URLRequest {
// indicating what's wrong with the certificate.
virtual void OnSSLCertificateError(URLRequest* request,
int cert_error,
- X509Certificate* cert) {
+ net::X509Certificate* cert) {
request->Cancel();
}
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h
index 63b8f45..e23a6ba 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -44,7 +44,9 @@
#include "net/base/cookie_policy.h"
#include "net/http/http_transaction_factory.h"
+namespace net {
class CookieMonster;
+}
// Subclass to provide application-specific context for URLRequest instances.
class URLRequestContext :
@@ -62,10 +64,10 @@ class URLRequestContext :
}
// Gets the cookie store for this context.
- CookieMonster* cookie_store() { return cookie_store_; }
+ net::CookieMonster* cookie_store() { return cookie_store_; }
// Gets the cookie policy for this context.
- CookiePolicy* cookie_policy() { return &cookie_policy_; }
+ net::CookiePolicy* cookie_policy() { return &cookie_policy_; }
// Gets the FTP realm authentication cache for this context.
net::AuthCache* ftp_auth_cache() { return &ftp_auth_cache_; }
@@ -90,8 +92,8 @@ class URLRequestContext :
// The following members are expected to be initialized and owned by
// subclasses.
net::HttpTransactionFactory* http_transaction_factory_;
- CookieMonster* cookie_store_;
- CookiePolicy cookie_policy_;
+ net::CookieMonster* cookie_store_;
+ net::CookiePolicy cookie_policy_;
net::AuthCache ftp_auth_cache_;
std::string user_agent_;
bool is_off_the_record_;
diff --git a/net/url_request/url_request_file_dir_job.cc b/net/url_request/url_request_file_dir_job.cc
index 5845abf..a0fcf7a 100644
--- a/net/url_request/url_request_file_dir_job.cc
+++ b/net/url_request/url_request_file_dir_job.cc
@@ -131,11 +131,11 @@ void URLRequestFileDirJob::OnListFile(const WIN32_FIND_DATA& data) {
// We wait to write out the header until we get the first file, so that we
// can catch errors from DirectoryLister and show an error page.
if (!wrote_header_) {
- data_.append(net_util::GetDirectoryListingHeader(WideToUTF8(dir_path_)));
+ data_.append(net::GetDirectoryListingHeader(WideToUTF8(dir_path_)));
wrote_header_ = true;
}
- data_.append(net_util::GetDirectoryListingEntry(
+ data_.append(net::GetDirectoryListingEntry(
WideToUTF8(data.cFileName), data.dwFileAttributes, size, &local_time));
// TODO(darin): coalesce more?
diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc
index e469047..a738b3a 100644
--- a/net/url_request/url_request_file_job.cc
+++ b/net/url_request/url_request_file_job.cc
@@ -75,7 +75,7 @@ DWORD WINAPI NetworkFileThread(LPVOID param) {
URLRequestJob* URLRequestFileJob::Factory(URLRequest* request,
const std::string& scheme) {
std::wstring file_path;
- if (net_util::FileURLToFilePath(request->url(), &file_path)) {
+ if (net::FileURLToFilePath(request->url(), &file_path)) {
if (file_path[file_path.size() - 1] == file_util::kPathSeparator) {
// Only directories have trailing slashes.
return new URLRequestFileDirJob(request, file_path);
@@ -343,7 +343,7 @@ bool URLRequestFileJob::IsRedirectResponse(GURL* location,
if (!resolved)
return false;
- *location = net_util::FilePathToFileURL(new_path);
+ *location = net::FilePathToFileURL(new_path);
*http_status_code = 301;
return true;
}
diff --git a/net/url_request/url_request_ftp_job.cc b/net/url_request/url_request_ftp_job.cc
index 7c9b5e8..23a726d 100644
--- a/net/url_request/url_request_ftp_job.cc
+++ b/net/url_request/url_request_ftp_job.cc
@@ -79,7 +79,7 @@ URLRequestJob* URLRequestFtpJob::Factory(URLRequest* request,
DCHECK(scheme == "ftp");
if (request->url().has_port() &&
- !net_util::IsPortAllowedByFtp(request->url().IntPort()))
+ !net::IsPortAllowedByFtp(request->url().IntPort()))
return new URLRequestErrorJob(request, net::ERR_UNSAFE_PORT);
return new URLRequestFtpJob(request);
@@ -396,7 +396,7 @@ void URLRequestFtpJob::OnFindFile(DWORD last_error) {
// We don't know the encoding, and can't assume utf8, so pass the 8bit
// directly to the browser for it to decide.
- string file_entry = net_util::GetDirectoryListingEntry(
+ string file_entry = net::GetDirectoryListingEntry(
find_data_.cFileName, find_data_.dwFileAttributes, size,
&find_data_.ftLastWriteTime);
WriteData(&file_entry, true);
@@ -413,14 +413,14 @@ void URLRequestFtpJob::OnStartDirectoryTraversal() {
state_ = GETTING_DIRECTORY;
// Unescape the URL path and pass the raw 8bit directly to the browser.
- string html = net_util::GetDirectoryListingHeader(
+ string html = net::GetDirectoryListingHeader(
UnescapeURLComponent(request_->url().path(),
UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS));
// If this isn't top level directory (i.e. the path isn't "/",) add a link to
// the parent directory.
if (request_->url().path().length() > 1)
- html.append(net_util::GetDirectoryListingEntry("..", 0, 0, NULL));
+ html.append(net::GetDirectoryListingEntry("..", 0, 0, NULL));
WriteData(&html, true);
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index b0d2b8c..9e89faa 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -49,7 +49,7 @@ URLRequestJob* URLRequestHttpJob::Factory(URLRequest* request,
const std::string& scheme) {
DCHECK(scheme == "http" || scheme == "https");
- if (!net_util::IsPortAllowedByDefault(request->url().IntPort()))
+ if (!net::IsPortAllowedByDefault(request->url().IntPort()))
return new URLRequestErrorJob(request, net::ERR_UNSAFE_PORT);
if (!request->context() ||
@@ -486,7 +486,7 @@ void URLRequestHttpJob::AddExtraHeaders() {
request_->policy_url())) {
std::string cookies = request_->context()->cookie_store()->
GetCookiesWithOptions(request_->url(),
- CookieMonster::INCLUDE_HTTPONLY);
+ net::CookieMonster::INCLUDE_HTTPONLY);
if (!cookies.empty())
request_info_.extra_headers += "Cookie: " + cookies + "\r\n";
}
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index 6f842bb..0ce504b 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -571,7 +571,7 @@ TEST(URLRequestTest, ResolveShortcutTest) {
TestDelegate d;
{
- TestURLRequest r(net_util::FilePathToFileURL(lnk_path), &d);
+ TestURLRequest r(net::FilePathToFileURL(lnk_path), &d);
r.Start();
EXPECT_TRUE(r.is_pending());
@@ -626,7 +626,7 @@ TEST(URLRequestTest, ContentTypeNormalizationTest) {
TEST(URLRequestTest, FileDirCancelTest) {
// Put in mock resource provider.
- NetModule::SetResourceProvider(TestNetResourceProvider);
+ net::NetModule::SetResourceProvider(TestNetResourceProvider);
TestDelegate d;
{
@@ -636,7 +636,7 @@ TEST(URLRequestTest, FileDirCancelTest) {
file_util::AppendToPath(&file_path, L"data");
file_util::AppendToPath(&file_path, L"");
- TestURLRequest req(net_util::FilePathToFileURL(file_path), &d);
+ TestURLRequest req(net::FilePathToFileURL(file_path), &d);
req.Start();
EXPECT_TRUE(req.is_pending());
@@ -649,7 +649,7 @@ TEST(URLRequestTest, FileDirCancelTest) {
#endif
// Take out mock resource provider.
- NetModule::SetResourceProvider(NULL);
+ net::NetModule::SetResourceProvider(NULL);
}
TEST(URLRequestTest, RestrictRedirects) {
diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h
index 0ee0043..d8a8809 100644
--- a/net/url_request/url_request_unittest.h
+++ b/net/url_request/url_request_unittest.h
@@ -153,7 +153,7 @@ class TestDelegate : public URLRequest::Delegate {
virtual void OnSSLCertificateError(URLRequest* request,
int cert_error,
- X509Certificate* cert) {
+ net::X509Certificate* cert) {
// Ignore SSL errors, we test the server is started and shut it down by
// performing GETs, no security restrictions should apply as we always want
// these GETs to go through.