summaryrefslogtreecommitdiffstats
path: root/net/base
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-30 16:40:10 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-30 16:40:10 +0000
commita9bb6f69b32018c245e05a79011114653fe8f5e0 (patch)
treec4fe6b5db0e508f860c82feb44245bf549d608ff /net/base
parentf23423a1245dffc2a368708fafd2867d2cf3e0f8 (diff)
downloadchromium_src-a9bb6f69b32018c245e05a79011114653fe8f5e0.zip
chromium_src-a9bb6f69b32018c245e05a79011114653fe8f5e0.tar.gz
chromium_src-a9bb6f69b32018c245e05a79011114653fe8f5e0.tar.bz2
Move some more classes from net/base into the net:: namespace.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r--net/base/auth.h4
-rw-r--r--net/base/auth_cache.cc4
-rw-r--r--net/base/auth_cache.h4
-rw-r--r--net/base/auth_cache_unittest.cc4
-rw-r--r--net/base/base64.cc4
-rw-r--r--net/base/base64.h4
-rw-r--r--net/base/base64_unittest.cc4
-rw-r--r--net/base/data_url.cc6
-rw-r--r--net/base/data_url.h4
-rw-r--r--net/base/data_url_unittest.cc9
-rw-r--r--net/base/directory_lister.cc4
-rw-r--r--net/base/directory_lister.h4
-rw-r--r--net/base/directory_lister_unittest.cc16
-rw-r--r--net/base/dns_resolution_observer.cc1
-rw-r--r--net/base/dns_resolution_observer.h2
-rw-r--r--net/base/mime_sniffer.cc4
-rw-r--r--net/base/mime_sniffer.h4
-rw-r--r--net/base/mime_sniffer_unittest.cc20
-rw-r--r--net/base/mime_util.cc8
-rw-r--r--net/base/mime_util.h4
-rw-r--r--net/base/mime_util_unittest.cc40
-rw-r--r--net/base/net_util.cc2
22 files changed, 99 insertions, 57 deletions
diff --git a/net/base/auth.h b/net/base/auth.h
index 92bc315..2cff79d 100644
--- a/net/base/auth.h
+++ b/net/base/auth.h
@@ -34,6 +34,8 @@
#include "base/ref_counted.h"
+namespace net {
+
// Holds info about an authentication challenge that we may want to display
// to the user.
class AuthChallengeInfo :
@@ -73,4 +75,6 @@ class AuthData : public base::RefCountedThreadSafe<AuthData> {
~AuthData() {}
};
+} // namespace net
+
#endif // NET_BASE_AUTH_H__
diff --git a/net/base/auth_cache.cc b/net/base/auth_cache.cc
index daa3afc..645d831 100644
--- a/net/base/auth_cache.cc
+++ b/net/base/auth_cache.cc
@@ -32,6 +32,8 @@
#include "base/string_util.h"
#include "googleurl/src/gurl.h"
+namespace net {
+
// Create an AuthCacheKey from url and auth_info.
//
// The cache key is made up of two components, separated by a slash /.
@@ -67,3 +69,5 @@ AuthData* AuthCache::Lookup(const AuthCacheKey& key) {
AuthCacheMap::iterator iter = cache_.find(key);
return (iter == cache_.end()) ? NULL : iter->second;
}
+
+} // namespace net
diff --git a/net/base/auth_cache.h b/net/base/auth_cache.h
index d4357f6..555bcfd 100644
--- a/net/base/auth_cache.h
+++ b/net/base/auth_cache.h
@@ -37,7 +37,7 @@
class GURL;
-// TODO(wtc): move AuthCache into the net namespace.
+namespace net {
// The AuthCache class is a simple cache structure to store authentication
// information for ftp or http/https sites. Provides lookup, addition, and
@@ -81,4 +81,6 @@ class AuthCache {
AuthCacheMap cache_;
};
+} // namespace net
+
#endif // NET_BASE_AUTH_CACHE_H__
diff --git a/net/base/auth_cache_unittest.cc b/net/base/auth_cache_unittest.cc
index b43b9ce..1989e07 100644
--- a/net/base/auth_cache_unittest.cc
+++ b/net/base/auth_cache_unittest.cc
@@ -39,7 +39,7 @@ class AuthCacheTest : public testing::Test {
} // namespace
TEST(AuthCacheTest, HttpKey) {
- scoped_refptr<AuthChallengeInfo> auth_info = new AuthChallengeInfo;
+ scoped_refptr<net::AuthChallengeInfo> auth_info = new net::AuthChallengeInfo;
auth_info->is_proxy = false; // server auth
// auth_info->host is intentionally left empty.
auth_info->scheme = L"Basic";
@@ -66,7 +66,7 @@ TEST(AuthCacheTest, HttpKey) {
};
for (int i = 0; i < arraysize(url); i++) {
- std::string key = AuthCache::HttpKey(GURL(url[i]), *auth_info);
+ std::string key = net::AuthCache::HttpKey(GURL(url[i]), *auth_info);
EXPECT_EQ(expected[i], key);
}
}
diff --git a/net/base/base64.cc b/net/base/base64.cc
index dcb5781..05716f5b 100644
--- a/net/base/base64.cc
+++ b/net/base/base64.cc
@@ -34,6 +34,8 @@
#include "third_party/modp_b64/modp_b64.h"
#pragma warning(pop)
+namespace net {
+
bool Base64Encode(const std::string& input, std::string* output) {
std::string temp;
temp.resize(modp_b64_encode_len(input.size())); // makes room for null byte
@@ -63,3 +65,5 @@ bool Base64Decode(const std::string& input, std::string* output) {
output->swap(temp);
return true;
}
+
+} // namespace net
diff --git a/net/base/base64.h b/net/base/base64.h
index 83511d8..f2452d1 100644
--- a/net/base/base64.h
+++ b/net/base/base64.h
@@ -32,6 +32,8 @@
#include <string>
+namespace net {
+
// Encodes the input string in base64. Returns true if successful and false
// otherwise. The output string is only modified if successful.
bool Base64Encode(const std::string& input, std::string* output);
@@ -40,4 +42,6 @@ bool Base64Encode(const std::string& input, std::string* output);
// otherwise. The output string is only modified if successful.
bool Base64Decode(const std::string& input, std::string* output);
+} // namespace net
+
#endif // NET_BASE_BASE64_H__
diff --git a/net/base/base64_unittest.cc b/net/base/base64_unittest.cc
index 58b3d26..40296c2 100644
--- a/net/base/base64_unittest.cc
+++ b/net/base/base64_unittest.cc
@@ -44,11 +44,11 @@ TEST(Base64Test, Basic) {
std::string encoded, decoded;
bool ok;
- ok = Base64Encode(kText, &encoded);
+ ok = net::Base64Encode(kText, &encoded);
EXPECT_TRUE(ok);
EXPECT_EQ(kBase64Text, encoded);
- ok = Base64Decode(encoded, &decoded);
+ ok = net::Base64Decode(encoded, &decoded);
EXPECT_TRUE(ok);
EXPECT_EQ(kText, decoded);
}
diff --git a/net/base/data_url.cc b/net/base/data_url.cc
index cf8e239..4040a66 100644
--- a/net/base/data_url.cc
+++ b/net/base/data_url.cc
@@ -38,7 +38,9 @@
#include "net/base/base64.h"
#include "net/base/escape.h"
-/*static*/
+namespace net {
+
+// static
bool DataURL::Parse(const GURL& url, std::string* mime_type,
std::string* charset, std::string* data) {
std::string::const_iterator begin = url.spec().begin();
@@ -119,3 +121,5 @@ bool DataURL::Parse(const GURL& url, std::string* mime_type,
temp_data.swap(*data);
return true;
}
+
+} // namespace net
diff --git a/net/base/data_url.h b/net/base/data_url.h
index 06c3ab1..b9b6f63 100644
--- a/net/base/data_url.h
+++ b/net/base/data_url.h
@@ -31,6 +31,8 @@
class GURL;
+namespace net {
+
// See RFC 2397 for a complete description of the 'data' URL scheme.
//
// Briefly, a 'data' URL has the form:
@@ -61,3 +63,5 @@ class DataURL {
std::string* charset,
std::string* data);
};
+
+} // namespace net
diff --git a/net/base/data_url_unittest.cc b/net/base/data_url_unittest.cc
index 99865df..3eae2d5 100644
--- a/net/base/data_url_unittest.cc
+++ b/net/base/data_url_unittest.cc
@@ -33,8 +33,10 @@
#include "testing/gtest/include/gtest/gtest.h"
namespace {
- class DataURLTest : public testing::Test {
- };
+
+class DataURLTest : public testing::Test {
+};
+
}
TEST(DataURLTest, Parse) {
@@ -165,7 +167,8 @@ TEST(DataURLTest, Parse) {
std::string mime_type;
std::string charset;
std::string data;
- bool ok = DataURL::Parse(GURL(tests[i].url), &mime_type, &charset, &data);
+ bool ok =
+ net::DataURL::Parse(GURL(tests[i].url), &mime_type, &charset, &data);
EXPECT_EQ(ok, tests[i].is_valid);
if (tests[i].is_valid) {
EXPECT_EQ(tests[i].mime_type, mime_type);
diff --git a/net/base/directory_lister.cc b/net/base/directory_lister.cc
index 44dd251..87f820d 100644
--- a/net/base/directory_lister.cc
+++ b/net/base/directory_lister.cc
@@ -33,6 +33,8 @@
#include "base/message_loop.h"
+namespace net {
+
static const int kFilesPerEvent = 8;
class DirectoryDataEvent : public Task {
@@ -161,3 +163,5 @@ void DirectoryLister::OnDone(int error) {
if (delegate_)
delegate_->OnListDone(error);
}
+
+} // namespace net
diff --git a/net/base/directory_lister.h b/net/base/directory_lister.h
index b3b0949..c640c99 100644
--- a/net/base/directory_lister.h
+++ b/net/base/directory_lister.h
@@ -37,6 +37,8 @@
class MessageLoop;
+namespace net {
+
//
// This class provides an API for listing the contents of a directory on the
// filesystem asynchronously. It spawns a background thread, and enumerates
@@ -89,4 +91,6 @@ class DirectoryLister : public base::RefCountedThreadSafe<DirectoryLister> {
bool canceled_;
};
+} // namespace net
+
#endif // NET_BASE_DIRECTORY_LISTER_H__
diff --git a/net/base/directory_lister_unittest.cc b/net/base/directory_lister_unittest.cc
index b1cbc4a..f93e27a 100644
--- a/net/base/directory_lister_unittest.cc
+++ b/net/base/directory_lister_unittest.cc
@@ -33,11 +33,13 @@
#include "testing/gtest/include/gtest/gtest.h"
namespace {
- class DirectoryListerTest : public testing::Test {
- };
+
+class DirectoryListerTest : public testing::Test {
+};
+
}
-class DirectoryListerDelegate : public DirectoryLister::Delegate {
+class DirectoryListerDelegate : public net::DirectoryLister::Delegate {
public:
DirectoryListerDelegate() : error_(-1) {
}
@@ -57,8 +59,8 @@ TEST(DirectoryListerTest, BigDirTest) {
ASSERT_TRUE(PathService::Get(base::DIR_WINDOWS, &windows_path));
DirectoryListerDelegate delegate;
- scoped_refptr<DirectoryLister> lister =
- new DirectoryLister(windows_path, &delegate);
+ scoped_refptr<net::DirectoryLister> lister =
+ new net::DirectoryLister(windows_path, &delegate);
lister->Start();
@@ -72,8 +74,8 @@ TEST(DirectoryListerTest, CancelTest) {
ASSERT_TRUE(PathService::Get(base::DIR_WINDOWS, &windows_path));
DirectoryListerDelegate delegate;
- scoped_refptr<DirectoryLister> lister =
- new DirectoryLister(windows_path, &delegate);
+ scoped_refptr<net::DirectoryLister> lister =
+ new net::DirectoryLister(windows_path, &delegate);
lister->Start();
lister->Cancel();
diff --git a/net/base/dns_resolution_observer.cc b/net/base/dns_resolution_observer.cc
index c66be8f..c9c9933 100644
--- a/net/base/dns_resolution_observer.cc
+++ b/net/base/dns_resolution_observer.cc
@@ -82,4 +82,5 @@ void DidFinishDnsResolutionWithStatus(bool was_resolved, void* context) {
current_observer->OnFinishResolutionWithStatus(was_resolved, context);
}
}
+
} // namspace net
diff --git a/net/base/dns_resolution_observer.h b/net/base/dns_resolution_observer.h
index 08ef6bf..f36172b 100644
--- a/net/base/dns_resolution_observer.h
+++ b/net/base/dns_resolution_observer.h
@@ -76,5 +76,7 @@ DnsResolutionObserver* RemoveDnsResolutionObserver();
// to any registered observer.
void DidStartDnsResolution(const std::string& name, void* context);
void DidFinishDnsResolutionWithStatus(bool was_resolved, void* context);
+
} // namspace net
+
#endif // NET_BASE_DNS_RESOLUTION_OBSERVER_H__
diff --git a/net/base/mime_sniffer.cc b/net/base/mime_sniffer.cc
index 12aec1d..b5d37dc 100644
--- a/net/base/mime_sniffer.cc
+++ b/net/base/mime_sniffer.cc
@@ -137,7 +137,7 @@ class SnifferHistogram : public LinearHistogram {
} // namespace
-namespace mime_util {
+namespace net {
// We aren't interested in looking at more than 512 bytes of content
static const size_t kMaxBytesToSniff = 512;
@@ -620,4 +620,4 @@ bool SniffMimeType(const char* content, size_t content_size,
return have_enough_content;
}
-} // namespace mime_util
+} // namespace net
diff --git a/net/base/mime_sniffer.h b/net/base/mime_sniffer.h
index 352343c..39a419b 100644
--- a/net/base/mime_sniffer.h
+++ b/net/base/mime_sniffer.h
@@ -34,7 +34,7 @@
class GURL;
-namespace mime_util {
+namespace net {
// Examine the URL and the mime_type and decide whether we should sniff a
// replacement mime type from the content.
@@ -57,6 +57,6 @@ bool SniffMimeType(const char* content, size_t content_size,
const GURL& url, const std::string& type_hint,
std::string* result);
-} // namespace mime_util
+} // namespace net
#endif // NET_BASE_MIME_SNIFFER_H__
diff --git a/net/base/mime_sniffer_unittest.cc b/net/base/mime_sniffer_unittest.cc
index 0d1011f..786a5a0 100644
--- a/net/base/mime_sniffer_unittest.cc
+++ b/net/base/mime_sniffer_unittest.cc
@@ -49,11 +49,11 @@ static void TestArray(SnifferTest* tests, size_t count) {
std::string mime_type;
for (size_t i = 0; i < count; ++i) {
- mime_util::SniffMimeType(tests[i].content,
- tests[i].content_len,
- GURL(tests[i].url),
- tests[i].type_hint,
- &mime_type);
+ net::SniffMimeType(tests[i].content,
+ tests[i].content_len,
+ GURL(tests[i].url),
+ tests[i].type_hint,
+ &mime_type);
EXPECT_EQ(tests[i].mime_type, mime_type);
}
}
@@ -64,8 +64,8 @@ static std::string SniffMimeType(const std::string& content,
const std::string& url,
const std::string& mime_type_hint) {
std::string mime_type;
- mime_util::SniffMimeType(content.data(), content.size(), GURL(url),
- mime_type_hint, &mime_type);
+ net::SniffMimeType(content.data(), content.size(), GURL(url),
+ mime_type_hint, &mime_type);
return mime_type;
}
@@ -79,11 +79,11 @@ TEST(MimeSnifferTest, BoundaryConditionsTest) {
GURL url;
- mime_util::SniffMimeType(buf, 0, url, type_hint, &mime_type);
+ net::SniffMimeType(buf, 0, url, type_hint, &mime_type);
EXPECT_EQ("text/plain", mime_type);
- mime_util::SniffMimeType(buf, 1, url, type_hint, &mime_type);
+ net::SniffMimeType(buf, 1, url, type_hint, &mime_type);
EXPECT_EQ("text/plain", mime_type);
- mime_util::SniffMimeType(buf, 2, url, type_hint, &mime_type);
+ net::SniffMimeType(buf, 2, url, type_hint, &mime_type);
EXPECT_EQ("application/octet-stream", mime_type);
}
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc
index 71421f9..8595311 100644
--- a/net/base/mime_util.cc
+++ b/net/base/mime_util.cc
@@ -40,7 +40,7 @@
using std::string;
using std::wstring;
-namespace mime_util {
+namespace net {
struct MimeInfo {
const char* mime_type;
@@ -259,8 +259,8 @@ bool IsViewSourceMimeType(const char* mime_type) {
bool IsSupportedMimeType(const std::string& mime_type) {
if (mime_type.compare(0, 5, "text/") == 0 ||
(mime_type.compare(0, 6, "image/") == 0 &&
- mime_util::IsSupportedImageMimeType(mime_type.c_str())) ||
- mime_util::IsSupportedNonImageMimeType(mime_type.c_str()))
+ IsSupportedImageMimeType(mime_type.c_str())) ||
+ IsSupportedNonImageMimeType(mime_type.c_str()))
return true;
return false;
}
@@ -302,4 +302,4 @@ bool MatchesMimeType(const std::string &mime_type_pattern,
return true;
}
-} // namespace mime_util
+} // namespace net
diff --git a/net/base/mime_util.h b/net/base/mime_util.h
index 047e79c..40d8b22 100644
--- a/net/base/mime_util.h
+++ b/net/base/mime_util.h
@@ -32,7 +32,7 @@
#include <string>
-namespace mime_util {
+namespace net {
// Get the mime type (if any) that is associated with the given file extension.
// Returns true if a corresponding mime type exists.
@@ -66,6 +66,6 @@ bool IsSupportedMimeType(const std::string& mime_type);
bool MatchesMimeType(const std::string &mime_type_pattern,
const std::string &mime_type);
-} // namespace mime_util
+} // namespace net
#endif // NET_BASE_MIME_UTIL_H__
diff --git a/net/base/mime_util_unittest.cc b/net/base/mime_util_unittest.cc
index 3031d1b..468e2c7 100644
--- a/net/base/mime_util_unittest.cc
+++ b/net/base/mime_util_unittest.cc
@@ -53,7 +53,7 @@ TEST(MimeUtilTest, ExtensionTest) {
bool rv;
for (size_t i = 0; i < arraysize(tests); ++i) {
- rv = mime_util::GetMimeTypeFromExtension(tests[i].extension, &mime_type);
+ rv = net::GetMimeTypeFromExtension(tests[i].extension, &mime_type);
EXPECT_EQ(rv, tests[i].valid);
if (rv)
EXPECT_EQ(mime_type, tests[i].mime_type);
@@ -75,7 +75,7 @@ TEST(MimeUtilTest, FileTest) {
bool rv;
for (size_t i = 0; i < arraysize(tests); ++i) {
- rv = mime_util::GetMimeTypeFromFile(tests[i].file_path, &mime_type);
+ rv = net::GetMimeTypeFromFile(tests[i].file_path, &mime_type);
EXPECT_EQ(rv, tests[i].valid);
if (rv)
EXPECT_EQ(mime_type, tests[i].mime_type);
@@ -83,32 +83,32 @@ TEST(MimeUtilTest, FileTest) {
}
TEST(MimeUtilTest, LookupTypes) {
- EXPECT_EQ(true, mime_util::IsSupportedImageMimeType("image/jpeg"));
- EXPECT_EQ(false, mime_util::IsSupportedImageMimeType("image/lolcat"));
- EXPECT_EQ(true, mime_util::IsSupportedNonImageMimeType("text/html"));
- EXPECT_EQ(false, mime_util::IsSupportedNonImageMimeType("text/virus"));
+ EXPECT_EQ(true, net::IsSupportedImageMimeType("image/jpeg"));
+ EXPECT_EQ(false, net::IsSupportedImageMimeType("image/lolcat"));
+ EXPECT_EQ(true, net::IsSupportedNonImageMimeType("text/html"));
+ EXPECT_EQ(false, net::IsSupportedNonImageMimeType("text/virus"));
}
TEST(MimeUtilTest, MatchesMimeType) {
- EXPECT_EQ(true, mime_util::MatchesMimeType("*", "video/x-mpeg"));
- EXPECT_EQ(true, mime_util::MatchesMimeType("video/*", "video/x-mpeg"));
- EXPECT_EQ(true, mime_util::MatchesMimeType("video/x-mpeg", "video/x-mpeg"));
- EXPECT_EQ(true, mime_util::MatchesMimeType("application/*+xml",
+ EXPECT_EQ(true, net::MatchesMimeType("*", "video/x-mpeg"));
+ EXPECT_EQ(true, net::MatchesMimeType("video/*", "video/x-mpeg"));
+ EXPECT_EQ(true, net::MatchesMimeType("video/x-mpeg", "video/x-mpeg"));
+ EXPECT_EQ(true, net::MatchesMimeType("application/*+xml",
"application/html+xml"));
- EXPECT_EQ(true, mime_util::MatchesMimeType("application/*+xml",
+ EXPECT_EQ(true, net::MatchesMimeType("application/*+xml",
"application/+xml"));
- EXPECT_EQ(true, mime_util::MatchesMimeType("aaa*aaa",
+ EXPECT_EQ(true, net::MatchesMimeType("aaa*aaa",
"aaaaaa"));
- EXPECT_EQ(false, mime_util::MatchesMimeType("video/", "video/x-mpeg"));
- EXPECT_EQ(false, mime_util::MatchesMimeType("", "video/x-mpeg"));
- EXPECT_EQ(false, mime_util::MatchesMimeType("", ""));
- EXPECT_EQ(false, mime_util::MatchesMimeType("video/x-mpeg", ""));
- EXPECT_EQ(false, mime_util::MatchesMimeType("application/*+xml",
+ EXPECT_EQ(false, net::MatchesMimeType("video/", "video/x-mpeg"));
+ EXPECT_EQ(false, net::MatchesMimeType("", "video/x-mpeg"));
+ EXPECT_EQ(false, net::MatchesMimeType("", ""));
+ EXPECT_EQ(false, net::MatchesMimeType("video/x-mpeg", ""));
+ EXPECT_EQ(false, net::MatchesMimeType("application/*+xml",
"application/xml"));
- EXPECT_EQ(false, mime_util::MatchesMimeType("application/*+xml",
+ EXPECT_EQ(false, net::MatchesMimeType("application/*+xml",
"application/html+xmlz"));
- EXPECT_EQ(false, mime_util::MatchesMimeType("application/*+xml",
+ EXPECT_EQ(false, net::MatchesMimeType("application/*+xml",
"applcation/html+xml"));
- EXPECT_EQ(false, mime_util::MatchesMimeType("aaa*aaa",
+ EXPECT_EQ(false, net::MatchesMimeType("aaa*aaa",
"aaaaa"));
}
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index 416252c..8996182 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -219,7 +219,7 @@ bool DecodeBQEncoding(const std::string& part, RFC2047EncodingType enc_type,
const std::string& charset, std::string* output) {
std::string decoded;
if (enc_type == B_ENCODING) {
- if (!Base64Decode(part, &decoded)) {
+ if (!net::Base64Decode(part, &decoded)) {
return false;
}
} else {