diff options
author | pauljensen@chromium.org <pauljensen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-07 15:08:43 +0000 |
---|---|---|
committer | pauljensen@chromium.org <pauljensen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-07 15:08:43 +0000 |
commit | ee4c30d8c5fca53a990da472de17314de366341b (patch) | |
tree | bc52b41397e143b46d0673991a13052edb1c9c66 /sync | |
parent | 91d4f2541624923604d54fdf280483a08a393464 (diff) | |
download | chromium_src-ee4c30d8c5fca53a990da472de17314de366341b.zip chromium_src-ee4c30d8c5fca53a990da472de17314de366341b.tar.gz chromium_src-ee4c30d8c5fca53a990da472de17314de366341b.tar.bz2 |
Provide mutable members of UrlRequestContext via pure-virtual interface. Create a pure-virtual interface called HttpUserAgentSettings that provides access to the Accept-Language, Accept-Charset, and User-Agent HTTP headers. Each UrlRequestContext should have a HttpUserAgentSettings implementation attached via set_http_user_agent_settings().
BUG=146596
Review URL: https://chromiumcodereview.appspot.com/10918279
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166425 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/internal_api/http_bridge.cc | 18 | ||||
-rw-r--r-- | sync/internal_api/public/http_bridge.h | 5 |
2 files changed, 10 insertions, 13 deletions
diff --git a/sync/internal_api/http_bridge.cc b/sync/internal_api/http_bridge.cc index 96e1a58..5b38233 100644 --- a/sync/internal_api/http_bridge.cc +++ b/sync/internal_api/http_bridge.cc @@ -15,6 +15,7 @@ #include "net/http/http_network_layer.h" #include "net/http/http_response_headers.h" #include "net/proxy/proxy_service.h" +#include "net/url_request/static_http_user_agent_settings.h" #include "net/url_request/url_fetcher.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_status.h" @@ -81,9 +82,8 @@ HttpBridge::RequestContext::RequestContext( network_task_runner, const std::string& user_agent) : baseline_context_(baseline_context), - network_task_runner_(network_task_runner), - user_agent_(user_agent) { - DCHECK(!user_agent_.empty()); + network_task_runner_(network_task_runner) { + DCHECK(!user_agent.empty()); // Create empty, in-memory cookie store. set_cookie_store(new net::CookieMonster(NULL, NULL)); @@ -109,8 +109,11 @@ HttpBridge::RequestContext::RequestContext( // should be tied to whatever the sync servers expect (if anything). These // fields should probably just be settable by sync backend; though we should // figure out if we need to give the user explicit control over policies etc. - set_accept_language(baseline_context->accept_language()); - set_accept_charset(baseline_context->accept_charset()); + http_user_agent_settings_.reset(new net::StaticHttpUserAgentSettings( + baseline_context->GetAcceptLanguage(), + baseline_context->GetAcceptCharset(), + user_agent)); + set_http_user_agent_settings(http_user_agent_settings_.get()); set_net_log(baseline_context->net_log()); } @@ -120,11 +123,6 @@ HttpBridge::RequestContext::~RequestContext() { delete http_transaction_factory(); } -const std::string& HttpBridge::RequestContext::GetUserAgent( - const GURL& url) const { - return user_agent_; -} - HttpBridge::URLFetchState::URLFetchState() : url_poster(NULL), aborted(false), request_completed(false), diff --git a/sync/internal_api/public/http_bridge.h b/sync/internal_api/public/http_bridge.h index 15001c2..40cf6e7 100644 --- a/sync/internal_api/public/http_bridge.h +++ b/sync/internal_api/public/http_bridge.h @@ -25,6 +25,7 @@ class HttpBridgeTest; namespace net { class HttpResponseHeaders; +class HttpUserAgentSettings; class URLFetcher; } @@ -58,12 +59,10 @@ class HttpBridge : public base::RefCountedThreadSafe<HttpBridge>, // The destructor MUST be called on the IO thread. virtual ~RequestContext(); - virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE; - private: net::URLRequestContext* const baseline_context_; const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; - const std::string user_agent_; + scoped_ptr<net::HttpUserAgentSettings> http_user_agent_settings_; DISALLOW_COPY_AND_ASSIGN(RequestContext); }; |