Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1393)

Unified Diff: net/url_request/url_request_context.cc

Issue 10918279: Provide mutable members of UrlRequestContext via pure-virtual interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/url_request/url_request_context.cc
diff --git a/net/url_request/url_request_context.cc b/net/url_request/url_request_context.cc
index b9ee75f329d5c26bdccc9d181aab656d0b9f2b07..c5de16a86e08fd4bfe85ae861b1407f9e66226e0 100644
--- a/net/url_request/url_request_context.cc
+++ b/net/url_request/url_request_context.cc
@@ -16,6 +16,29 @@
namespace net {
+ConstHttpAcceptLanguageAndCharset::ConstHttpAcceptLanguageAndCharset(
erikwright (departed) 2012/09/21 15:06:33 move.
+ const std::string& accept_language, const std::string& accept_charset) :
+ accept_language_(accept_language),
+ accept_charset_(accept_charset) {}
erikwright (departed) 2012/09/21 15:06:33 Feel free to check prior-art and tell me what is p
+
+const std::string& ConstHttpAcceptLanguageAndCharset::GetAcceptLanguage() {
+ return accept_language_;
+}
+
+const std::string& ConstHttpAcceptLanguageAndCharset::GetAcceptCharset() {
+ return accept_charset_;
+}
+
+ConstHttpUserAgentSettings::ConstHttpUserAgentSettings(
+ const std::string& accept_language, const std::string& accept_charset,
+ const std::string& user_agent) :
+ ConstHttpAcceptLanguageAndCharset(accept_language, accept_charset),
+ user_agent_(user_agent) {}
+
+const std::string& ConstHttpUserAgentSettings::GetUserAgent(const GURL& url) {
+ return user_agent_;
+}
+
URLRequestContext::URLRequestContext()
: net_log_(NULL),
host_resolver_(NULL),
@@ -34,6 +57,7 @@ URLRequestContext::URLRequestContext()
ftp_transaction_factory_(NULL),
job_factory_(NULL),
throttler_manager_(NULL),
+ http_user_agent_settings_(NULL),
url_requests_(new std::set<const URLRequest*>) {
}
@@ -56,8 +80,7 @@ void URLRequestContext::CopyFrom(const URLRequestContext* other) {
set_cookie_store(other->cookie_store_);
set_transport_security_state(other->transport_security_state_);
// FTPAuthCache is unique per context.
- set_accept_language(other->accept_language_);
- set_accept_charset(other->accept_charset_);
+ set_http_user_agent_settings(other->http_user_agent_settings_);
set_referrer_charset(other->referrer_charset_);
set_http_transaction_factory(other->http_transaction_factory_);
set_ftp_transaction_factory(other->ftp_transaction_factory_);
@@ -85,8 +108,24 @@ void URLRequestContext::set_cookie_store(CookieStore* cookie_store) {
cookie_store_ = cookie_store;
}
+// Gets the value of 'Accept-Charset' header field.
erikwright (departed) 2012/09/21 15:06:33 no implementation comment necessary.
+const std::string& URLRequestContext::accept_charset() const {
+ if (!http_user_agent_settings_)
erikwright (departed) 2012/09/21 15:06:33 nit: return http_user_agent_settings_ ? ht
+ return EmptyString();
+ return http_user_agent_settings_->GetAcceptCharset();
+}
+
+// Gets the value of 'Accept-Language' header field.
+const std::string& URLRequestContext::accept_language() const {
+ if (!http_user_agent_settings_)
+ return EmptyString();
+ return http_user_agent_settings_->GetAcceptLanguage();
+}
+
const std::string& URLRequestContext::GetUserAgent(const GURL& url) const {
- return EmptyString();
+ if (!http_user_agent_settings_)
+ return EmptyString();
+ return http_user_agent_settings_->GetUserAgent(url);
}
void URLRequestContext::AssertNoURLRequests() const {

Powered by Google App Engine
This is Rietveld 408576698