summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorpmeenan@chromium.org <pmeenan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-08 23:47:55 +0000
committerpmeenan@chromium.org <pmeenan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-08 23:47:55 +0000
commitb304306c524b168bc6a7f3eb246a3a095c3eb039 (patch)
tree8cf4bceb1e13757c74a6777d64abfb0fdbbdb13f /content
parent283a4bb9f32244128fd8262eb2d574296c25bfd0 (diff)
downloadchromium_src-b304306c524b168bc6a7f3eb246a3a095c3eb039.zip
chromium_src-b304306c524b168bc6a7f3eb246a3a095c3eb039.tar.gz
chromium_src-b304306c524b168bc6a7f3eb246a3a095c3eb039.tar.bz2
Disabled resource scheduling when using a SPDY proxy
We already disable the artificial delaying of resources when connected to a SPDY-capable host, this extends that to also include pages that are served through a SPDY proxy. As-implemented, as soon as any request for a given client completes and was served using SPDY over a proxy connection, that client will be treated as a SPDY-capable client. Some resources will still be delayed until the base page (or another request) completes but it is much better than it was before. BUG=324789 Review URL: https://codereview.chromium.org/99533002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243698 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/loader/resource_dispatcher_host_impl.cc7
-rw-r--r--content/browser/loader/resource_scheduler.cc29
-rw-r--r--content/browser/loader/resource_scheduler.h6
-rw-r--r--content/browser/loader/resource_scheduler_unittest.cc14
4 files changed, 52 insertions, 4 deletions
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
index 34b2d3a..4fa3fb9 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -704,6 +704,13 @@ void ResourceDispatcherHostImpl::DidReceiveRedirect(ResourceLoader* loader,
void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) {
ResourceRequestInfoImpl* info = loader->GetRequestInfo();
+ if (loader->request()->was_fetched_via_proxy() &&
+ loader->request()->was_fetched_via_spdy() &&
+ loader->request()->url().SchemeIs("http")) {
+ scheduler_->OnReceivedSpdyProxiedHttpResponse(
+ info->GetChildID(), info->GetRouteID());
+ }
+
// There should be an entry in the map created when we dispatched the
// request unless it's been detached and the renderer has died.
OfflineMap::iterator policy_it(
diff --git a/content/browser/loader/resource_scheduler.cc b/content/browser/loader/resource_scheduler.cc
index 4ae240e..15c7027 100644
--- a/content/browser/loader/resource_scheduler.cc
+++ b/content/browser/loader/resource_scheduler.cc
@@ -178,10 +178,11 @@ class ResourceScheduler::ScheduledResourceRequest
// Each client represents a tab.
struct ResourceScheduler::Client {
- Client() : has_body(false) {}
+ Client() : has_body(false), using_spdy_proxy(false) {}
~Client() {}
bool has_body;
+ bool using_spdy_proxy;
RequestQueue pending_requests;
RequestSet in_flight_requests;
};
@@ -305,9 +306,25 @@ void ResourceScheduler::OnWillInsertBody(int child_id, int route_id) {
}
Client* client = it->second;
- client->has_body = false;
- if (!client->has_body) {
- client->has_body = true;
+ client->has_body = true;
+ LoadAnyStartablePendingRequests(client);
+}
+
+void ResourceScheduler::OnReceivedSpdyProxiedHttpResponse(
+ int child_id,
+ int route_id) {
+ DCHECK(CalledOnValidThread());
+ ClientId client_id = MakeClientId(child_id, route_id);
+
+ ClientMap::iterator client_it = client_map_.find(client_id);
+ if (client_it == client_map_.end()) {
+ return;
+ }
+
+ Client* client = client_it->second;
+
+ if (!client->using_spdy_proxy) {
+ client->using_spdy_proxy = true;
LoadAnyStartablePendingRequests(client);
}
}
@@ -451,6 +468,10 @@ ResourceScheduler::ShouldStartReqResult ResourceScheduler::ShouldStartRequest(
return START_REQUEST;
}
+ if (client->using_spdy_proxy && url_request.url().SchemeIs("http")) {
+ return START_REQUEST;
+ }
+
const net::HttpServerProperties& http_server_properties =
*url_request.context()->http_server_properties();
diff --git a/content/browser/loader/resource_scheduler.h b/content/browser/loader/resource_scheduler.h
index dddc831..b374b6c 100644
--- a/content/browser/loader/resource_scheduler.h
+++ b/content/browser/loader/resource_scheduler.h
@@ -78,6 +78,12 @@ class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe {
// resource loads won't interfere with first paint.
void OnWillInsertBody(int child_id, int route_id);
+ // Signals from the IO thread
+
+ // Called when we received a response to a http request that was served
+ // from a proxy using SPDY.
+ void OnReceivedSpdyProxiedHttpResponse(int child_id, int route_id);
+
private:
class RequestQueue;
class ScheduledResourceRequest;
diff --git a/content/browser/loader/resource_scheduler_unittest.cc b/content/browser/loader/resource_scheduler_unittest.cc
index 07dd333..5f9c693 100644
--- a/content/browser/loader/resource_scheduler_unittest.cc
+++ b/content/browser/loader/resource_scheduler_unittest.cc
@@ -465,6 +465,20 @@ TEST_F(ResourceSchedulerTest, NonHTTPSchedulesImmediately) {
EXPECT_TRUE(request->started());
}
+TEST_F(ResourceSchedulerTest, SpdyProxySchedulesImmediately) {
+ scoped_ptr<TestRequest> high(NewRequest("http://host/high", net::HIGHEST));
+ scoped_ptr<TestRequest> low(NewRequest("http://host/low", net::LOWEST));
+
+ scoped_ptr<TestRequest> request(NewRequest("http://host/req", net::IDLE));
+ EXPECT_FALSE(request->started());
+
+ scheduler_.OnReceivedSpdyProxiedHttpResponse(kChildId, kRouteId);
+ EXPECT_TRUE(request->started());
+
+ scoped_ptr<TestRequest> after(NewRequest("http://host/after", net::IDLE));
+ EXPECT_TRUE(after->started());
+}
+
} // unnamed namespace
} // namespace content