diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-30 16:40:10 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-30 16:40:10 +0000 |
commit | a9bb6f69b32018c245e05a79011114653fe8f5e0 (patch) | |
tree | c4fe6b5db0e508f860c82feb44245bf549d608ff | |
parent | f23423a1245dffc2a368708fafd2867d2cf3e0f8 (diff) | |
download | chromium_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
62 files changed, 232 insertions, 188 deletions
diff --git a/chrome/browser/download_manager.cc b/chrome/browser/download_manager.cc index 06759c9..17851ac 100644 --- a/chrome/browser/download_manager.cc +++ b/chrome/browser/download_manager.cc @@ -866,7 +866,7 @@ void DownloadManager::GenerateExtension(const std::wstring& file_name, extension.assign(default_extension); std::string mime_type_from_extension; - mime_util::GetMimeTypeFromFile(file_name, &mime_type_from_extension); + net::GetMimeTypeFromFile(file_name, &mime_type_from_extension); if (mime_type == mime_type_from_extension) { // The hinted extension matches the mime type. It looks like a winner. generated_extension->swap(extension); @@ -877,7 +877,7 @@ void DownloadManager::GenerateExtension(const std::wstring& file_name, // We want to be careful about executable extensions. The worry here is // that a trusted web site could be tricked into dropping an executable file // on the user's filesystem. - if (!mime_util::GetPreferredExtensionForMimeType(mime_type, &extension)) { + if (!net::GetPreferredExtensionForMimeType(mime_type, &extension)) { // We couldn't find a good extension for this content type. Use a dummy // extension instead. extension.assign(default_extension); @@ -885,7 +885,7 @@ void DownloadManager::GenerateExtension(const std::wstring& file_name, } if (extension.empty()) { - mime_util::GetPreferredExtensionForMimeType(mime_type, &extension); + net::GetPreferredExtensionForMimeType(mime_type, &extension); } else { // Append entension generated from the mime type if: // 1. New extension is not ".txt" @@ -895,8 +895,7 @@ void DownloadManager::GenerateExtension(const std::wstring& file_name, // E.g. my-cat.jpg becomes my-cat.jpg.js if content type is // application/x-javascript. std::wstring append_extension; - if (mime_util::GetPreferredExtensionForMimeType(mime_type, - &append_extension)) { + if (net::GetPreferredExtensionForMimeType(mime_type, &append_extension)) { if (append_extension != L".txt" && append_extension != extension && !IsExecutable(append_extension)) extension += append_extension; @@ -973,19 +972,19 @@ bool DownloadManager::ShouldOpenFileExtension(const std::wstring& extension) { // static bool DownloadManager::IsExecutableMimeType(const std::string& mime_type) { // JavaScript is just as powerful as EXE. - if (mime_util::MatchesMimeType("text/javascript", mime_type)) + if (net::MatchesMimeType("text/javascript", mime_type)) return true; - if (mime_util::MatchesMimeType("text/javascript;version=*", mime_type)) + if (net::MatchesMimeType("text/javascript;version=*", mime_type)) return true; // We don't consider other non-application types to be executable. - if (!mime_util::MatchesMimeType("application/*", mime_type)) + if (!net::MatchesMimeType("application/*", mime_type)) return false; // These application types are not executable. - if (mime_util::MatchesMimeType("application/*+xml", mime_type)) + if (net::MatchesMimeType("application/*+xml", mime_type)) return false; - if (mime_util::MatchesMimeType("application/xml", mime_type)) + if (net::MatchesMimeType("application/xml", mime_type)) return false; return true; diff --git a/chrome/browser/firefox2_importer.cc b/chrome/browser/firefox2_importer.cc index a04f380..36b3555 100644 --- a/chrome/browser/firefox2_importer.cc +++ b/chrome/browser/firefox2_importer.cc @@ -519,7 +519,7 @@ void Firefox2Importer::DataURLToFaviconUsage( // Parse the data URL. std::string mime_type, char_set, data; - if (!DataURL::Parse(favicon_data, &mime_type, &char_set, &data) || + if (!net::DataURL::Parse(favicon_data, &mime_type, &char_set, &data) || data.empty()) return; diff --git a/chrome/browser/firefox_importer_utils.cc b/chrome/browser/firefox_importer_utils.cc index 35425da..96b6d8c 100644 --- a/chrome/browser/firefox_importer_utils.cc +++ b/chrome/browser/firefox_importer_utils.cc @@ -592,7 +592,7 @@ std::wstring NSSDecryptor::Decrypt(const std::string& crypt) const { // by a leading '~'. Otherwise, we should decrypt the text. if (crypt[0] != '~') { std::string decoded_data; - Base64Decode(crypt, &decoded_data); + net::Base64Decode(crypt, &decoded_data); PK11SlotInfo* slot = NULL; slot = PK11_GetInternalKeySlot(); SECStatus result = PK11_Authenticate(slot, PR_TRUE, NULL); @@ -616,7 +616,7 @@ std::wstring NSSDecryptor::Decrypt(const std::string& crypt) const { PK11_FreeSlot(slot); } else { // Deletes the leading '~' before decoding. - Base64Decode(crypt.substr(1), &plain); + net::Base64Decode(crypt.substr(1), &plain); } return UTF8ToWide(plain); diff --git a/chrome/browser/gears_integration.cc b/chrome/browser/gears_integration.cc index d236272..e13a7a3 100644 --- a/chrome/browser/gears_integration.cc +++ b/chrome/browser/gears_integration.cc @@ -154,7 +154,7 @@ static GURL ConvertSkBitmapToDataURL(const SkBitmap& icon) { std::string icon_data_str(reinterpret_cast<char*>(&icon_data[0]), icon_data.size()); std::string icon_base64_encoded; - Base64Encode(icon_data_str, &icon_base64_encoded); + net::Base64Encode(icon_data_str, &icon_base64_encoded); GURL icon_url("data:image/png;base64," + icon_base64_encoded); return icon_url; diff --git a/chrome/browser/login_prompt.cc b/chrome/browser/login_prompt.cc index ec10fb9..650c1cf 100644 --- a/chrome/browser/login_prompt.cc +++ b/chrome/browser/login_prompt.cc @@ -323,7 +323,7 @@ class LoginHandlerImpl : public LoginHandler, // which then routes it to the URLRequest on the I/O thread. class LoginDialogTask : public Task { public: - LoginDialogTask(AuthChallengeInfo* auth_info, LoginHandlerImpl* handler) + LoginDialogTask(net::AuthChallengeInfo* auth_info, LoginHandlerImpl* handler) : auth_info_(auth_info), handler_(handler) { } virtual ~LoginDialogTask() { @@ -380,15 +380,15 @@ class LoginDialogTask : public Task { // TODO(timsteele): Shouldn't depend on HttpKey since a change to the // format would result in not being able to retrieve existing logins // for a site. Refactor HttpKey behavior to be more reusable. - dialog_form.signon_realm = AuthCache::HttpKey(dialog_form.origin, - *auth_info_); + dialog_form.signon_realm = + net::AuthCache::HttpKey(dialog_form.origin, *auth_info_); password_manager_input->push_back(dialog_form); // Set the password form for the handler (by copy). handler_->set_password_form(dialog_form); } // Info about who/where/what is asking for authentication. - scoped_refptr<AuthChallengeInfo> auth_info_; + scoped_refptr<net::AuthChallengeInfo> auth_info_; // Where to send the authentication when obtained. // This is owned by the ResourceDispatcherHost that invoked us. @@ -400,7 +400,7 @@ class LoginDialogTask : public Task { // ---------------------------------------------------------------------------- // Public API -LoginHandler* CreateLoginPrompt(AuthChallengeInfo* auth_info, +LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, URLRequest* request, MessageLoop* ui_loop) { LoginHandlerImpl* handler = new LoginHandlerImpl(request, ui_loop); diff --git a/chrome/browser/login_prompt.h b/chrome/browser/login_prompt.h index 3c4d5f6..eacd165 100644 --- a/chrome/browser/login_prompt.h +++ b/chrome/browser/login_prompt.h @@ -34,7 +34,10 @@ #include "base/basictypes.h" +namespace net { class AuthChallengeInfo; +} + class URLRequest; class MessageLoop; class TabContents; @@ -83,7 +86,7 @@ private: // which can be used to set or cancel authentication programmatically. The // caller must invoke OnRequestCancelled() on this LoginHandler before // destroying the URLRequest. -LoginHandler* CreateLoginPrompt(AuthChallengeInfo* auth_info, +LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, URLRequest* request, MessageLoop* ui_loop); diff --git a/chrome/browser/metrics_log.cc b/chrome/browser/metrics_log.cc index 06daa76..a563ed5 100644 --- a/chrome/browser/metrics_log.cc +++ b/chrome/browser/metrics_log.cc @@ -136,12 +136,11 @@ std::string MetricsLog::CreateHash(const std::string& value) { std::string MetricsLog::CreateBase64Hash(const std::string& string) { std::string encoded_digest; - if (Base64Encode(CreateHash(string), &encoded_digest)) { + if (net::Base64Encode(CreateHash(string), &encoded_digest)) { DLOG(INFO) << "Metrics: Hash [" << encoded_digest << "]=[" << string << "]"; return encoded_digest; - } else { - return std::string(); } + return std::string(); } void MetricsLog::RecordUserAction(const wchar_t* key) { diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc index 328d1dc..2240c6f 100644 --- a/chrome/browser/plugin_process_host.cc +++ b/chrome/browser/plugin_process_host.cc @@ -130,7 +130,7 @@ class PluginDownloadUrlHelper : public URLRequest::Delegate { virtual void OnReceivedRedirect(URLRequest* request, const GURL& new_url); virtual void OnAuthRequired(URLRequest* request, - AuthChallengeInfo* auth_info); + net::AuthChallengeInfo* auth_info); virtual void OnSSLCertificateError(URLRequest* request, int cert_error, X509Certificate* cert); @@ -195,8 +195,9 @@ void PluginDownloadUrlHelper::OnReceivedRedirect(URLRequest* request, const GURL& new_url) { } -void PluginDownloadUrlHelper::OnAuthRequired(URLRequest* request, - AuthChallengeInfo* auth_info) { +void PluginDownloadUrlHelper::OnAuthRequired( + URLRequest* request, + net::AuthChallengeInfo* auth_info) { URLRequest::Delegate::OnAuthRequired(request, auth_info); DownloadCompletedHelper(false); } diff --git a/chrome/browser/resource_dispatcher_host.cc b/chrome/browser/resource_dispatcher_host.cc index 3104151..87f504f 100644 --- a/chrome/browser/resource_dispatcher_host.cc +++ b/chrome/browser/resource_dispatcher_host.cc @@ -974,7 +974,7 @@ bool ResourceDispatcherHost::BufferedEventHandler::DelayResponse() { std::string mime_type; request_->GetMimeType(&mime_type); - if (mime_util::ShouldSniffMimeType(request_->url(), mime_type)) { + if (net::ShouldSniffMimeType(request_->url(), mime_type)) { // We're going to look at the data before deciding what the content type // is. That means we need to delay sending the ResponseStarted message // over the IPC channel. @@ -1019,8 +1019,8 @@ bool ResourceDispatcherHost::BufferedEventHandler::KeepBuffering( std::string type_hint, new_type; request_->GetMimeType(&type_hint); - if (!mime_util::SniffMimeType(read_buffer_, bytes_read_, request_->url(), - type_hint, &new_type)) { + if (!net::SniffMimeType(read_buffer_, bytes_read_, request_->url(), + type_hint, &new_type)) { // SniffMimeType() returns false if there is not enough data to determine // the mime type. However, even if it returns false, it returns a new type // that is probably better than the current one. @@ -1804,8 +1804,9 @@ void ResourceDispatcherHost::OnReceivedRedirect(URLRequest* request, CancelRequest(info->render_process_host_id, info->request_id, false); } -void ResourceDispatcherHost::OnAuthRequired(URLRequest* request, - AuthChallengeInfo* auth_info) { +void ResourceDispatcherHost::OnAuthRequired( + URLRequest* request, + net::AuthChallengeInfo* auth_info) { // Create a login dialog on the UI thread to get authentication data, // or pull from cache and continue on the IO thread. // TODO(mpcomplete): We should block the parent tab while waiting for @@ -1961,7 +1962,7 @@ bool ResourceDispatcherHost::ShouldDownload( } // MIME type checking. - if (mime_util::IsSupportedMimeType(type)) + if (net::IsSupportedMimeType(type)) return false; // Finally, check the plugin service. diff --git a/chrome/browser/resource_dispatcher_host.h b/chrome/browser/resource_dispatcher_host.h index 52c876b..9614e08 100644 --- a/chrome/browser/resource_dispatcher_host.h +++ b/chrome/browser/resource_dispatcher_host.h @@ -347,7 +347,7 @@ class ResourceDispatcherHost : public URLRequest::Delegate { virtual void OnReceivedRedirect(URLRequest* request, const GURL& new_url); virtual void OnAuthRequired(URLRequest* request, - AuthChallengeInfo* auth_info); + net::AuthChallengeInfo* auth_info); virtual void OnSSLCertificateError(URLRequest* request, int cert_error, X509Certificate* cert); diff --git a/chrome/browser/resource_message_filter.cc b/chrome/browser/resource_message_filter.cc index a1f7a2f..20007dc 100644 --- a/chrome/browser/resource_message_filter.cc +++ b/chrome/browser/resource_message_filter.cc @@ -449,17 +449,17 @@ void ResourceMessageFilter::OnGetWindowRect(HWND window, gfx::Rect *rect) { void ResourceMessageFilter::OnGetMimeTypeFromExtension( const std::wstring& ext, std::string* mime_type) { - mime_util::GetMimeTypeFromExtension(ext, mime_type); + net::GetMimeTypeFromExtension(ext, mime_type); } void ResourceMessageFilter::OnGetMimeTypeFromFile( const std::wstring& file_path, std::string* mime_type) { - mime_util::GetMimeTypeFromFile(file_path, mime_type); + net::GetMimeTypeFromFile(file_path, mime_type); } void ResourceMessageFilter::OnGetPreferredExtensionForMimeType( const std::string& mime_type, std::wstring* ext) { - mime_util::GetPreferredExtensionForMimeType(mime_type, ext); + net::GetPreferredExtensionForMimeType(mime_type, ext); } void ResourceMessageFilter::OnGetCPBrowsingContext(uint32* context) { diff --git a/chrome/browser/safe_browsing/protocol_manager.cc b/chrome/browser/safe_browsing/protocol_manager.cc index 086ceb9..9307cd3 100644 --- a/chrome/browser/safe_browsing/protocol_manager.cc +++ b/chrome/browser/safe_browsing/protocol_manager.cc @@ -364,7 +364,7 @@ bool SafeBrowsingProtocolManager::HandleServiceResponse(const GURL& url, std::string data_str; data_str.assign(data, length); std::string encoded_chunk; - Base64Encode(data, &encoded_chunk); + net::Base64Encode(data, &encoded_chunk); SB_DLOG(INFO) << "ParseChunk error for chunk: " << chunk_url.url << ", client_key: " << client_key_ << ", wrapped_key: " << wrapped_key_ diff --git a/chrome/browser/safe_browsing/safe_browsing_util.cc b/chrome/browser/safe_browsing/safe_browsing_util.cc index 802d5ff..304a637 100644 --- a/chrome/browser/safe_browsing/safe_browsing_util.cc +++ b/chrome/browser/safe_browsing/safe_browsing_util.cc @@ -165,12 +165,12 @@ bool VerifyMAC(const std::string& key, const std::string& mac, std::string key_copy = key; DecodeWebSafe(&key_copy); std::string decoded_key; - Base64Decode(key_copy, &decoded_key); + net::Base64Decode(key_copy, &decoded_key); std::string mac_copy = mac; DecodeWebSafe(&mac_copy); std::string decoded_mac; - Base64Decode(mac_copy, &decoded_mac); + net::Base64Decode(mac_copy, &decoded_mac); HMAC hmac(HMAC::SHA1, reinterpret_cast<const unsigned char*>(decoded_key.data()), diff --git a/chrome/browser/web_app.cc b/chrome/browser/web_app.cc index 4c4620f..1760263 100644 --- a/chrome/browser/web_app.cc +++ b/chrome/browser/web_app.cc @@ -58,7 +58,7 @@ static std::set<GURL> ExtractImageURLs(const GearsShortcutData& data) { static SkBitmap DecodePNGEncodedURL(const GURL& url) { std::string mime_type, charset, data; if (!url.SchemeIs("data") || - !DataURL::Parse(url, &mime_type, &charset, &data) || + !net::DataURL::Parse(url, &mime_type, &charset, &data) || mime_type != kPNGImageMimeType) { return SkBitmap(); } diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc index 8ee43e3..5a330e7 100644 --- a/chrome/browser/web_contents.cc +++ b/chrome/browser/web_contents.cc @@ -2975,8 +2975,8 @@ HWND WebContents::GetContentHWND() { bool WebContents::CanDisplayFile(const std::wstring& full_path) { bool allow_wildcard = false; std::string mime_type; - mime_util::GetMimeTypeFromFile(full_path, &mime_type); - if (mime_util::IsSupportedMimeType(mime_type) || + net::GetMimeTypeFromFile(full_path, &mime_type); + if (net::IsSupportedMimeType(mime_type) || (PluginService::GetInstance() && PluginService::GetInstance()->HavePluginFor(mime_type, allow_wildcard))) return true; diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index cfe1d9c..5d9c9d4 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -162,7 +162,7 @@ void webkit_glue::AppendToLog(const char* file, int line, const char* msg) { bool webkit_glue::GetMimeTypeFromExtension(std::wstring &ext, std::string *mime_type) { if (IsPluginProcess()) - return mime_util::GetMimeTypeFromExtension(ext, mime_type); + return net::GetMimeTypeFromExtension(ext, mime_type); // The sandbox restricts our access to the registry, so we need to proxy // these calls over to the browser process. @@ -175,7 +175,7 @@ bool webkit_glue::GetMimeTypeFromExtension(std::wstring &ext, bool webkit_glue::GetMimeTypeFromFile(const std::wstring &file_path, std::string *mime_type) { if (IsPluginProcess()) - return mime_util::GetMimeTypeFromFile(file_path, mime_type); + return net::GetMimeTypeFromFile(file_path, mime_type); // The sandbox restricts our access to the registry, so we need to proxy // these calls over to the browser process. @@ -188,7 +188,7 @@ bool webkit_glue::GetMimeTypeFromFile(const std::wstring &file_path, bool webkit_glue::GetPreferredExtensionForMimeType(const std::string& mime_type, std::wstring* ext) { if (IsPluginProcess()) - return mime_util::GetPreferredExtensionForMimeType(mime_type, ext); + return net::GetPreferredExtensionForMimeType(mime_type, ext); // The sandbox restricts our access to the registry, so we need to proxy // these calls over to the browser process. 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 { diff --git a/net/http/http_transaction_factory.h b/net/http/http_transaction_factory.h index 013a48d..f800c9e 100644 --- a/net/http/http_transaction_factory.h +++ b/net/http/http_transaction_factory.h @@ -30,10 +30,9 @@ #ifndef NET_HTTP_HTTP_TRANSACTION_FACTORY_H__ #define NET_HTTP_HTTP_TRANSACTION_FACTORY_H__ -class AuthCache; - namespace net { +class AuthCache; class HttpCache; class HttpTransaction; diff --git a/net/http/http_transaction_unittest.h b/net/http/http_transaction_unittest.h index 32f8a5a..f2165e7 100644 --- a/net/http/http_transaction_unittest.h +++ b/net/http/http_transaction_unittest.h @@ -324,7 +324,7 @@ class MockNetworkLayer : public net::HttpTransactionFactory { return NULL; } - virtual AuthCache* GetAuthCache() { + virtual net::AuthCache* GetAuthCache() { return NULL; } diff --git a/net/url_request/mime_sniffer_proxy.cc b/net/url_request/mime_sniffer_proxy.cc index 2a0dec6..47568d9 100644 --- a/net/url_request/mime_sniffer_proxy.cc +++ b/net/url_request/mime_sniffer_proxy.cc @@ -41,7 +41,7 @@ MimeSnifferProxy::MimeSnifferProxy(URLRequest* request, void MimeSnifferProxy::OnResponseStarted(URLRequest* request) { if (request->status().is_success()) { request->GetMimeType(&mime_type_); - if (mime_util::ShouldSniffMimeType(request->url(), mime_type_)) { + if (net::ShouldSniffMimeType(request->url(), mime_type_)) { // We need to read content before we know the mime type, // so we don't call OnResponseStarted. sniff_content_ = true; @@ -82,8 +82,8 @@ void MimeSnifferProxy::OnReadCompleted(URLRequest* request, int bytes_read) { std::string type_hint; request_->GetMimeType(&type_hint); bytes_read_ = bytes_read; - mime_util::SniffMimeType(buf_, bytes_read_, - request_->url(), type_hint, &mime_type_); + net::SniffMimeType( + buf_, bytes_read_, request_->url(), type_hint, &mime_type_); } else { error_ = true; } diff --git a/net/url_request/mime_sniffer_proxy.h b/net/url_request/mime_sniffer_proxy.h index 7246e46..af02dfd 100644 --- a/net/url_request/mime_sniffer_proxy.h +++ b/net/url_request/mime_sniffer_proxy.h @@ -63,7 +63,7 @@ class MimeSnifferProxy : public URLRequest::Delegate { delegate_->OnReceivedRedirect(request, new_url); } virtual void OnAuthRequired(URLRequest* request, - AuthChallengeInfo* auth_info) { + net::AuthChallengeInfo* auth_info) { delegate_->OnAuthRequired(request, auth_info); } virtual void OnSSLCertificateError(URLRequest* request, diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h index 89b36b0..6740975 100644 --- a/net/url_request/url_request.h +++ b/net/url_request/url_request.h @@ -132,7 +132,7 @@ class URLRequest { // When it does so, the request will be reissued, restarting the sequence // of On* callbacks. virtual void OnAuthRequired(URLRequest* request, - AuthChallengeInfo* auth_info) { + net::AuthChallengeInfo* auth_info) { request->CancelAuth(); } diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h index 059df6c..63b8f45 100644 --- a/net/url_request/url_request_context.h +++ b/net/url_request/url_request_context.h @@ -68,7 +68,7 @@ class URLRequestContext : CookiePolicy* cookie_policy() { return &cookie_policy_; } // Gets the FTP realm authentication cache for this context. - AuthCache* ftp_auth_cache() { return &ftp_auth_cache_; } + net::AuthCache* ftp_auth_cache() { return &ftp_auth_cache_; } // Gets the UA string to use for this context. const std::string& user_agent() const { return user_agent_; } @@ -92,7 +92,7 @@ class URLRequestContext : net::HttpTransactionFactory* http_transaction_factory_; CookieMonster* cookie_store_; CookiePolicy cookie_policy_; - AuthCache ftp_auth_cache_; + net::AuthCache ftp_auth_cache_; std::string user_agent_; bool is_off_the_record_; std::string accept_language_; diff --git a/net/url_request/url_request_file_dir_job.cc b/net/url_request/url_request_file_dir_job.cc index 5ad44a6..5845abf 100644 --- a/net/url_request/url_request_file_dir_job.cc +++ b/net/url_request/url_request_file_dir_job.cc @@ -73,7 +73,7 @@ void URLRequestFileDirJob::StartAsync() { // is trying to feed us data. AddRef(); - lister_ = new DirectoryLister(dir_path_, this); + lister_ = new net::DirectoryLister(dir_path_, this); lister_->Start(); NotifyHeadersComplete(); diff --git a/net/url_request/url_request_file_dir_job.h b/net/url_request/url_request_file_dir_job.h index 78d6863..618b067 100644 --- a/net/url_request/url_request_file_dir_job.h +++ b/net/url_request/url_request_file_dir_job.h @@ -34,7 +34,7 @@ #include "net/url_request/url_request_job.h" class URLRequestFileDirJob : public URLRequestJob, - public DirectoryLister::Delegate { + public net::DirectoryLister::Delegate { public: URLRequestFileDirJob(URLRequest* request, const std::wstring& dir_path); virtual ~URLRequestFileDirJob(); @@ -61,7 +61,7 @@ class URLRequestFileDirJob : public URLRequestJob, // Fills a buffer with the output. bool FillReadBuffer(char *buf, int buf_size, int *bytes_read); - scoped_refptr<DirectoryLister> lister_; + scoped_refptr<net::DirectoryLister> lister_; std::wstring dir_path_; std::string data_; bool canceled_; diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc index 17e5f5c..e469047 100644 --- a/net/url_request/url_request_file_job.cc +++ b/net/url_request/url_request_file_job.cc @@ -221,7 +221,7 @@ bool URLRequestFileJob::ReadRawData(char* dest, int dest_size, bool URLRequestFileJob::GetMimeType(std::string* mime_type) { DCHECK(request_); - return mime_util::GetMimeTypeFromFile(file_path_, mime_type); + return net::GetMimeTypeFromFile(file_path_, mime_type); } void URLRequestFileJob::CloseHandles() { diff --git a/net/url_request/url_request_ftp_job.cc b/net/url_request/url_request_ftp_job.cc index f619609..134cb61 100644 --- a/net/url_request/url_request_ftp_job.cc +++ b/net/url_request/url_request_ftp_job.cc @@ -146,7 +146,7 @@ void URLRequestFtpJob::SendRequest() { // in the url (if anything). string username, password; bool have_auth = false; - if (server_auth_ != NULL && server_auth_->state == AUTH_STATE_HAVE_AUTH) { + if (server_auth_ && server_auth_->state == net::AUTH_STATE_HAVE_AUTH) { // Add auth info to cache have_auth = true; username = WideToUTF8(server_auth_->username); @@ -194,13 +194,13 @@ void URLRequestFtpJob::OnIOComplete(const AsyncResult& result) { // fall through case ERROR_INTERNET_INCORRECT_PASSWORD: if (server_auth_ != NULL && - server_auth_->state == AUTH_STATE_HAVE_AUTH) { + server_auth_->state == net::AUTH_STATE_HAVE_AUTH) { request_->context()->ftp_auth_cache()->Remove(request_->url().host()); } else { - server_auth_ = new AuthData(); + server_auth_ = new net::AuthData(); } // Try again, prompting for authentication. - server_auth_->state = AUTH_STATE_NEED_AUTH; + server_auth_->state = net::AUTH_STATE_NEED_AUTH; // The io completed fine, the error was due to invalid auth. SetStatus(URLRequestStatus()); NotifyHeadersComplete(); @@ -271,15 +271,14 @@ bool URLRequestFtpJob::NeedsAuth() { // requires auth (and not a proxy), because connecting to FTP via proxy // effectively means the browser communicates via HTTP, and uses HTTP's // Proxy-Authenticate protocol when proxy servers require auth. - return ((server_auth_ != NULL) && - server_auth_->state == AUTH_STATE_NEED_AUTH); + return server_auth_ && server_auth_->state == net::AUTH_STATE_NEED_AUTH; } void URLRequestFtpJob::GetAuthChallengeInfo( - scoped_refptr<AuthChallengeInfo>* result) { + scoped_refptr<net::AuthChallengeInfo>* result) { DCHECK((server_auth_ != NULL) && - (server_auth_->state == AUTH_STATE_NEED_AUTH)); - scoped_refptr<AuthChallengeInfo> auth_info = new AuthChallengeInfo; + (server_auth_->state == net::AUTH_STATE_NEED_AUTH)); + scoped_refptr<net::AuthChallengeInfo> auth_info = new net::AuthChallengeInfo; auth_info->is_proxy = false; auth_info->host = UTF8ToWide(request_->url().host()); auth_info->scheme = L""; @@ -288,8 +287,8 @@ void URLRequestFtpJob::GetAuthChallengeInfo( } void URLRequestFtpJob::GetCachedAuthData( - const AuthChallengeInfo& auth_info, - scoped_refptr<AuthData>* auth_data) { + const net::AuthChallengeInfo& auth_info, + scoped_refptr<net::AuthData>* auth_data) { *auth_data = request_->context()->ftp_auth_cache()-> Lookup(WideToUTF8(auth_info.host)); } diff --git a/net/url_request/url_request_ftp_job.h b/net/url_request/url_request_ftp_job.h index ae47dbf..654262d 100644 --- a/net/url_request/url_request_ftp_job.h +++ b/net/url_request/url_request_ftp_job.h @@ -57,9 +57,9 @@ class URLRequestFtpJob : public URLRequestInetJob { virtual void OnCancelAuth(); virtual void OnSetAuth(); virtual bool NeedsAuth(); - virtual void GetAuthChallengeInfo(scoped_refptr<AuthChallengeInfo>*); - virtual void GetCachedAuthData(const AuthChallengeInfo& auth_info, - scoped_refptr<AuthData>* auth_data); + virtual void GetAuthChallengeInfo(scoped_refptr<net::AuthChallengeInfo>*); + virtual void GetCachedAuthData(const net::AuthChallengeInfo& auth_info, + scoped_refptr<net::AuthData>* auth_data); virtual bool IsRedirectResponse(GURL* location, int* http_status_code); private: diff --git a/net/url_request/url_request_http_cache_job.cc b/net/url_request/url_request_http_cache_job.cc index 9537638..d583f96 100644 --- a/net/url_request/url_request_http_cache_job.cc +++ b/net/url_request/url_request_http_cache_job.cc @@ -66,8 +66,8 @@ URLRequestHttpCacheJob::URLRequestHttpCacheJob(URLRequest* request) context_(request->context()), transaction_(NULL), response_info_(NULL), - proxy_auth_state_(AUTH_STATE_DONT_NEED_AUTH), - server_auth_state_(AUTH_STATE_DONT_NEED_AUTH), + proxy_auth_state_(net::AUTH_STATE_DONT_NEED_AUTH), + server_auth_state_(net::AUTH_STATE_DONT_NEED_AUTH), start_callback_(this, &URLRequestHttpCacheJob::OnStartCompleted), read_callback_(this, &URLRequestHttpCacheJob::OnReadCompleted), read_in_progress_(false) { @@ -238,27 +238,27 @@ bool URLRequestHttpCacheJob::NeedsAuth() { // because we either provided no auth info, or provided incorrect info. switch (code) { case 407: - if (proxy_auth_state_ == AUTH_STATE_CANCELED) + if (proxy_auth_state_ == net::AUTH_STATE_CANCELED) return false; - proxy_auth_state_ = AUTH_STATE_NEED_AUTH; + proxy_auth_state_ = net::AUTH_STATE_NEED_AUTH; return true; case 401: - if (server_auth_state_ == AUTH_STATE_CANCELED) + if (server_auth_state_ == net::AUTH_STATE_CANCELED) return false; - server_auth_state_ = AUTH_STATE_NEED_AUTH; + server_auth_state_ = net::AUTH_STATE_NEED_AUTH; return true; } return false; } void URLRequestHttpCacheJob::GetAuthChallengeInfo( - scoped_refptr<AuthChallengeInfo>* result) { + scoped_refptr<net::AuthChallengeInfo>* result) { DCHECK(transaction_); DCHECK(response_info_); // sanity checks: - DCHECK(proxy_auth_state_ == AUTH_STATE_NEED_AUTH || - server_auth_state_ == AUTH_STATE_NEED_AUTH); + DCHECK(proxy_auth_state_ == net::AUTH_STATE_NEED_AUTH || + server_auth_state_ == net::AUTH_STATE_NEED_AUTH); DCHECK(response_info_->headers->response_code() == 401 || response_info_->headers->response_code() == 407); @@ -266,16 +266,16 @@ void URLRequestHttpCacheJob::GetAuthChallengeInfo( } void URLRequestHttpCacheJob::GetCachedAuthData( - const AuthChallengeInfo& auth_info, - scoped_refptr<AuthData>* auth_data) { - AuthCache* auth_cache = + const net::AuthChallengeInfo& auth_info, + scoped_refptr<net::AuthData>* auth_data) { + net::AuthCache* auth_cache = request_->context()->http_transaction_factory()->GetAuthCache(); if (!auth_cache) { *auth_data = NULL; return; } - std::string auth_cache_key = AuthCache::HttpKey(request_->url(), - auth_info); + std::string auth_cache_key = + net::AuthCache::HttpKey(request_->url(), auth_info); *auth_data = auth_cache->Lookup(auth_cache_key); } @@ -284,11 +284,11 @@ void URLRequestHttpCacheJob::SetAuth(const std::wstring& username, DCHECK(transaction_); // Proxy gets set first, then WWW. - if (proxy_auth_state_ == AUTH_STATE_NEED_AUTH) { - proxy_auth_state_ = AUTH_STATE_HAVE_AUTH; + if (proxy_auth_state_ == net::AUTH_STATE_NEED_AUTH) { + proxy_auth_state_ = net::AUTH_STATE_HAVE_AUTH; } else { - DCHECK(server_auth_state_ == AUTH_STATE_NEED_AUTH); - server_auth_state_ = AUTH_STATE_HAVE_AUTH; + DCHECK(server_auth_state_ == net::AUTH_STATE_NEED_AUTH); + server_auth_state_ = net::AUTH_STATE_HAVE_AUTH; } // These will be reset in OnStartCompleted. @@ -312,11 +312,11 @@ void URLRequestHttpCacheJob::SetAuth(const std::wstring& username, void URLRequestHttpCacheJob::CancelAuth() { // Proxy gets set first, then WWW. - if (proxy_auth_state_ == AUTH_STATE_NEED_AUTH) { - proxy_auth_state_ = AUTH_STATE_CANCELED; + if (proxy_auth_state_ == net::AUTH_STATE_NEED_AUTH) { + proxy_auth_state_ = net::AUTH_STATE_CANCELED; } else { - DCHECK(server_auth_state_ == AUTH_STATE_NEED_AUTH); - server_auth_state_ = AUTH_STATE_CANCELED; + DCHECK(server_auth_state_ == net::AUTH_STATE_NEED_AUTH); + server_auth_state_ = net::AUTH_STATE_CANCELED; } // These will be reset in OnStartCompleted. diff --git a/net/url_request/url_request_http_cache_job.h b/net/url_request/url_request_http_cache_job.h index 261d66b..249bc7d 100644 --- a/net/url_request/url_request_http_cache_job.h +++ b/net/url_request/url_request_http_cache_job.h @@ -67,9 +67,9 @@ class URLRequestHttpCacheJob : public URLRequestJob { virtual bool IsRedirectResponse(GURL* location, int* http_status_code); virtual bool IsSafeRedirect(const GURL& location); virtual bool NeedsAuth(); - virtual void GetAuthChallengeInfo(scoped_refptr<AuthChallengeInfo>*); - virtual void GetCachedAuthData(const AuthChallengeInfo& auth_info, - scoped_refptr<AuthData>* auth_data); + virtual void GetAuthChallengeInfo(scoped_refptr<net::AuthChallengeInfo>*); + virtual void GetCachedAuthData(const net::AuthChallengeInfo& auth_info, + scoped_refptr<net::AuthData>* auth_data); virtual void SetAuth(const std::wstring& username, const std::wstring& password); virtual void CancelAuth(); @@ -94,8 +94,8 @@ class URLRequestHttpCacheJob : public URLRequestJob { std::vector<std::string> response_cookies_; // Auth states for proxy and origin server. - AuthState proxy_auth_state_; - AuthState server_auth_state_; + net::AuthState proxy_auth_state_; + net::AuthState server_auth_state_; net::CompletionCallbackImpl<URLRequestHttpCacheJob> start_callback_; net::CompletionCallbackImpl<URLRequestHttpCacheJob> read_callback_; diff --git a/net/url_request/url_request_inet_job.cc b/net/url_request/url_request_inet_job.cc index ab4f91b..e2d80fd 100644 --- a/net/url_request/url_request_inet_job.cc +++ b/net/url_request/url_request_inet_job.cc @@ -141,17 +141,16 @@ void URLRequestInetJob::Kill() { void URLRequestInetJob::SetAuth(const wstring& username, const wstring& password) { - DCHECK((proxy_auth_ != NULL && proxy_auth_->state == AUTH_STATE_NEED_AUTH) || - (server_auth_ != NULL && - (server_auth_->state == AUTH_STATE_NEED_AUTH))); + DCHECK((proxy_auth_ && proxy_auth_->state == net::AUTH_STATE_NEED_AUTH) || + (server_auth_ && server_auth_->state == net::AUTH_STATE_NEED_AUTH)); // Proxy gets set first, then WWW. - AuthData* auth = - (proxy_auth_ != NULL && proxy_auth_->state == AUTH_STATE_NEED_AUTH ? + net::AuthData* auth = + (proxy_auth_ && proxy_auth_->state == net::AUTH_STATE_NEED_AUTH ? proxy_auth_.get() : server_auth_.get()); if (auth) { - auth->state = AUTH_STATE_HAVE_AUTH; + auth->state = net::AUTH_STATE_HAVE_AUTH; auth->username = username; auth->password = password; } @@ -165,17 +164,16 @@ void URLRequestInetJob::SetAuth(const wstring& username, } void URLRequestInetJob::CancelAuth() { - DCHECK((proxy_auth_ != NULL && proxy_auth_->state == AUTH_STATE_NEED_AUTH) || - (server_auth_ != NULL && - (server_auth_->state == AUTH_STATE_NEED_AUTH))); + DCHECK((proxy_auth_ && proxy_auth_->state == net::AUTH_STATE_NEED_AUTH) || + (server_auth_ && server_auth_->state == net::AUTH_STATE_NEED_AUTH)); // Proxy gets set first, then WWW. - AuthData* auth = - (proxy_auth_ != NULL && proxy_auth_->state == AUTH_STATE_NEED_AUTH ? + net::AuthData* auth = + (proxy_auth_ && proxy_auth_->state == net::AUTH_STATE_NEED_AUTH ? proxy_auth_.get() : server_auth_.get()); if (auth) { - auth->state = AUTH_STATE_CANCELED; + auth->state = net::AUTH_STATE_CANCELED; } // Once the auth is cancelled, we proceed with the request as though diff --git a/net/url_request/url_request_inet_job.h b/net/url_request/url_request_inet_job.h index a82d754..ec44689 100644 --- a/net/url_request/url_request_inet_job.h +++ b/net/url_request/url_request_inet_job.h @@ -36,7 +36,10 @@ #include "net/url_request/url_request.h" #include "net/url_request/url_request_job.h" +namespace net { class AuthData; +} + class MessageLoop; // For all WinInet-based URL requests @@ -139,8 +142,8 @@ protected: std::string extra_request_headers_; // Authentication information. - scoped_refptr<AuthData> proxy_auth_; - scoped_refptr<AuthData> server_auth_; + scoped_refptr<net::AuthData> proxy_auth_; + scoped_refptr<net::AuthData> server_auth_; private: diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc index 6485489..628038f 100644 --- a/net/url_request/url_request_job.cc +++ b/net/url_request/url_request_job.cc @@ -299,12 +299,12 @@ void URLRequestJob::NotifyHeadersComplete() { return; } } else if (NeedsAuth()) { - scoped_refptr<AuthChallengeInfo> auth_info; + scoped_refptr<net::AuthChallengeInfo> auth_info; GetAuthChallengeInfo(&auth_info); // Need to check for a NULL auth_info because the server may have failed // to send a challenge with the 401 response. if (auth_info) { - scoped_refptr<AuthData> auth_data; + scoped_refptr<net::AuthData> auth_data; GetCachedAuthData(*auth_info, &auth_data); if (auth_data) { SetAuth(auth_data->username, auth_data->password); diff --git a/net/url_request/url_request_job.h b/net/url_request/url_request_job.h index 60a870d..9cb4a18 100644 --- a/net/url_request/url_request_job.h +++ b/net/url_request/url_request_job.h @@ -168,7 +168,7 @@ class URLRequestJob : public base::RefCounted<URLRequestJob> { // Fills the authentication info with the server's response. virtual void GetAuthChallengeInfo( - scoped_refptr<AuthChallengeInfo>* auth_info) { + scoped_refptr<net::AuthChallengeInfo>* auth_info) { // This will only be called if NeedsAuth() returns true, in which // case the derived class should implement this! NOTREACHED(); @@ -177,8 +177,8 @@ class URLRequestJob : public base::RefCounted<URLRequestJob> { // Returns cached auth data for the auth challenge. Returns NULL if there // is no auth cache or if the auth cache doesn't have the auth data for // the auth challenge. - virtual void GetCachedAuthData(const AuthChallengeInfo& auth_info, - scoped_refptr<AuthData>* auth_data) { + virtual void GetCachedAuthData(const net::AuthChallengeInfo& auth_info, + scoped_refptr<net::AuthData>* auth_data) { *auth_data = NULL; } diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h index 7e40710..0ee0043 100644 --- a/net/url_request/url_request_unittest.h +++ b/net/url_request/url_request_unittest.h @@ -143,7 +143,7 @@ class TestDelegate : public URLRequest::Delegate { MessageLoop::current()->Quit(); } - void OnAuthRequired(URLRequest* request, AuthChallengeInfo* auth_info) { + void OnAuthRequired(URLRequest* request, net::AuthChallengeInfo* auth_info) { if (!username_.empty() || !password_.empty()) { request->SetAuth(username_, password_); } else { diff --git a/webkit/glue/plugins/plugin_lib.cc b/webkit/glue/plugins/plugin_lib.cc index bf36152..8f28284 100644 --- a/webkit/glue/plugins/plugin_lib.cc +++ b/webkit/glue/plugins/plugin_lib.cc @@ -181,7 +181,7 @@ bool PluginLib::SupportsType(const std::string &mime_type, for (size_t i = 0; i < web_plugin_info_->mime_types.size(); ++i) { const WebPluginMimeType& mime_info = web_plugin_info_->mime_types[i]; - if (mime_util::MatchesMimeType(mime_info.mime_type, mime_type)) { + if (net::MatchesMimeType(mime_info.mime_type, mime_type)) { if (!allow_wildcard && (mime_info.mime_type == "*")) { continue; } diff --git a/webkit/glue/resource_handle_win.cc b/webkit/glue/resource_handle_win.cc index 1646f0a..f309274 100644 --- a/webkit/glue/resource_handle_win.cc +++ b/webkit/glue/resource_handle_win.cc @@ -91,7 +91,7 @@ bool GetInfoFromDataUrl(const GURL& url, std::string* data, URLRequestStatus* status) { std::string mime_type; std::string charset; - if (DataURL::Parse(url, &mime_type, &charset, data)) { + if (net::DataURL::Parse(url, &mime_type, &charset, data)) { info->request_time = Time::Now(); info->response_time = Time::Now(); info->mime_type.swap(mime_type); diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index b1056d8..232230f 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -1169,8 +1169,8 @@ bool WebFrameLoaderClient::canShowMIMEType(const String& mime_type) const { // "internally" (i.e. inside the browser) regardless of whether or not the // browser or a plugin is doing the rendering. - if (mime_util::IsSupportedMimeType( - WideToASCII(webkit_glue::StringToStdWString(mime_type)))) + if (net::IsSupportedMimeType( + WideToASCII(webkit_glue::StringToStdWString(mime_type)))) return true; // See if the type is handled by an installed plugin, if so, we can show it. diff --git a/webkit/port/bridge/PluginsWin.cpp b/webkit/port/bridge/PluginsWin.cpp index b310b36..f1f837d 100644 --- a/webkit/port/bridge/PluginsWin.cpp +++ b/webkit/port/bridge/PluginsWin.cpp @@ -109,7 +109,7 @@ bool PluginInfoStore::supportsMIMEType(const WebCore::String &mime_type) for (size_t i = 0; i < g_plugins.size(); ++i) { for (size_t j = 0; j < g_plugins[i].mime_types.size(); ++j) { - if (mime_util::MatchesMimeType( + if (net::MatchesMimeType( g_plugins[i].mime_types[j].mime_type, WideToNativeMB(converted_mime_type))) { // Don't allow wildcard matches here as this will result in diff --git a/webkit/port/platform/MIMETypeRegistry.cpp b/webkit/port/platform/MIMETypeRegistry.cpp index 4905004..6c936d1 100644 --- a/webkit/port/platform/MIMETypeRegistry.cpp +++ b/webkit/port/platform/MIMETypeRegistry.cpp @@ -71,13 +71,13 @@ String MIMETypeRegistry::getMIMETypeForPath(const String& path) bool MIMETypeRegistry::isSupportedImageMIMEType(const String& mimeType) { return !mimeType.isEmpty() - && mime_util::IsSupportedImageMimeType(mimeType.latin1().data()); + && net::IsSupportedImageMimeType(mimeType.latin1().data()); } bool MIMETypeRegistry::isSupportedJavaScriptMIMEType(const String& mimeType) { return !mimeType.isEmpty() - && mime_util::IsSupportedJavascriptMimeType(mimeType.latin1().data()); + && net::IsSupportedJavascriptMimeType(mimeType.latin1().data()); } bool MIMETypeRegistry::isSupportedImageResourceMIMEType(const String& mimeType) @@ -88,7 +88,7 @@ bool MIMETypeRegistry::isSupportedImageResourceMIMEType(const String& mimeType) bool MIMETypeRegistry::isSupportedNonImageMIMEType(const String& mimeType) { return !mimeType.isEmpty() - && mime_util::IsSupportedNonImageMimeType(mimeType.latin1().data()); + && net::IsSupportedNonImageMimeType(mimeType.latin1().data()); } bool MIMETypeRegistry::isJavaAppletMIMEType(const String& mimeType) diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 407b95d..cbe8561 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -1008,17 +1008,17 @@ void AppendToLog(const char* file, int line, const char* msg) { } bool GetMimeTypeFromExtension(std::wstring &ext, std::string *mime_type) { - return mime_util::GetMimeTypeFromExtension(ext, mime_type); + return net::GetMimeTypeFromExtension(ext, mime_type); } bool GetMimeTypeFromFile(const std::wstring &file_path, std::string *mime_type) { - return mime_util::GetMimeTypeFromFile(file_path, mime_type); + return net::GetMimeTypeFromFile(file_path, mime_type); } bool GetPreferredExtensionForMimeType(const std::string& mime_type, std::wstring* ext) { - return mime_util::GetPreferredExtensionForMimeType(mime_type, ext); + return net::GetPreferredExtensionForMimeType(mime_type, ext); } IMLangFontLink2* GetLangFontLink() { |