summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/glue/http_bridge.cc
diff options
context:
space:
mode:
authorchron@chromium.org <chron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-06 02:22:10 +0000
committerchron@chromium.org <chron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-06 02:22:10 +0000
commit659a26023ec2ac7100e5c79c29856ef049af6ca3 (patch)
tree789d0a2e65b3b4a53d191d895e1073d8d65f8855 /chrome/browser/sync/glue/http_bridge.cc
parent1bb5f89e7302cc69f13148651ac6732d89965787 (diff)
downloadchromium_src-659a26023ec2ac7100e5c79c29856ef049af6ca3.zip
chromium_src-659a26023ec2ac7100e5c79c29856ef049af6ca3.tar.gz
chromium_src-659a26023ec2ac7100e5c79c29856ef049af6ca3.tar.bz2
Initial CL for fixing some of the proxy auth issues.
Auth_cache is contained in the http session. We need to share the http session with the parent profile request context in order to retain http authentication. Weirdly enough, Profile::GetDefaultRequestContext() is not the same as profile_->GetRequestContext(), It does NOT yet pop up a dialog if the user hasn't done so already. BUG=19581 TEST=Included. Review URL: http://codereview.chromium.org/241001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28086 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/glue/http_bridge.cc')
-rw-r--r--chrome/browser/sync/glue/http_bridge.cc37
1 files changed, 23 insertions, 14 deletions
diff --git a/chrome/browser/sync/glue/http_bridge.cc b/chrome/browser/sync/glue/http_bridge.cc
index 304f91e..ebf0c7a 100644
--- a/chrome/browser/sync/glue/http_bridge.cc
+++ b/chrome/browser/sync/glue/http_bridge.cc
@@ -12,20 +12,20 @@
#include "chrome/browser/profile.h"
#include "net/base/cookie_monster.h"
#include "net/base/load_flags.h"
+#include "net/http/http_cache.h"
#include "net/http/http_network_layer.h"
#include "net/proxy/proxy_service.h"
+#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_status.h"
#include "webkit/glue/webkit_glue.h"
namespace browser_sync {
-HttpBridge::RequestContext* HttpBridgeFactory::GetRequestContext() {
- if (!request_context_) {
- request_context_ =
- new HttpBridge::RequestContext(Profile::GetDefaultRequestContext());
- request_context_->AddRef();
- }
- return request_context_;
+HttpBridgeFactory::HttpBridgeFactory(
+ URLRequestContext* baseline_context) {
+ DCHECK(baseline_context != NULL);
+ request_context_ = new HttpBridge::RequestContext(baseline_context);
+ request_context_->AddRef();
}
HttpBridgeFactory::~HttpBridgeFactory() {
@@ -38,8 +38,7 @@ HttpBridgeFactory::~HttpBridgeFactory() {
}
sync_api::HttpPostProviderInterface* HttpBridgeFactory::Create() {
- // TODO(timsteele): We want the active profile request context.
- HttpBridge* http = new HttpBridge(GetRequestContext(),
+ HttpBridge* http = new HttpBridge(request_context_,
ChromeThread::GetMessageLoop(ChromeThread::IO));
http->AddRef();
return http;
@@ -49,8 +48,8 @@ void HttpBridgeFactory::Destroy(sync_api::HttpPostProviderInterface* http) {
static_cast<HttpBridge*>(http)->Release();
}
-HttpBridge::RequestContext::RequestContext(
- const URLRequestContext* baseline_context) {
+HttpBridge::RequestContext::RequestContext(URLRequestContext* baseline_context)
+ : baseline_context_(baseline_context) {
// Create empty, in-memory cookie store.
cookie_store_ = new net::CookieMonster();
@@ -59,9 +58,15 @@ HttpBridge::RequestContext::RequestContext(
host_resolver_ = baseline_context->host_resolver();
proxy_service_ = baseline_context->proxy_service();
ssl_config_service_ = baseline_context->ssl_config_service();
- http_transaction_factory_ =
- net::HttpNetworkLayer::CreateFactory(host_resolver_, proxy_service_,
- ssl_config_service_);
+
+ // We want to share the HTTP session data with the network layer factory,
+ // which includes auth_cache for proxies.
+ // Session is not refcounted so we need to be careful to not lose the parent
+ // context.
+ net::HttpNetworkSession* session =
+ baseline_context->http_transaction_factory()->GetSession();
+ DCHECK(session);
+ http_transaction_factory_ = net::HttpNetworkLayer::CreateFactory(session);
// TODO(timsteele): We don't currently listen for pref changes of these
// fields or CookiePolicy; I'm not sure we want to strictly follow the
@@ -189,6 +194,10 @@ const char* HttpBridge::GetResponseContent() const {
return response_content_.data();
}
+URLRequestContext* HttpBridge::GetRequestContext() const {
+ return context_for_request_;
+}
+
void HttpBridge::OnURLFetchComplete(const URLFetcher *source, const GURL &url,
const URLRequestStatus &status,
int response_code,