Commit b304306c authored by pmeenan@chromium.org's avatar pmeenan@chromium.org

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
parent 283a4bb9
...@@ -704,6 +704,13 @@ void ResourceDispatcherHostImpl::DidReceiveRedirect(ResourceLoader* loader, ...@@ -704,6 +704,13 @@ void ResourceDispatcherHostImpl::DidReceiveRedirect(ResourceLoader* loader,
void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) { void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) {
ResourceRequestInfoImpl* info = loader->GetRequestInfo(); 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 // There should be an entry in the map created when we dispatched the
// request unless it's been detached and the renderer has died. // request unless it's been detached and the renderer has died.
OfflineMap::iterator policy_it( OfflineMap::iterator policy_it(
......
...@@ -178,10 +178,11 @@ class ResourceScheduler::ScheduledResourceRequest ...@@ -178,10 +178,11 @@ class ResourceScheduler::ScheduledResourceRequest
// Each client represents a tab. // Each client represents a tab.
struct ResourceScheduler::Client { struct ResourceScheduler::Client {
Client() : has_body(false) {} Client() : has_body(false), using_spdy_proxy(false) {}
~Client() {} ~Client() {}
bool has_body; bool has_body;
bool using_spdy_proxy;
RequestQueue pending_requests; RequestQueue pending_requests;
RequestSet in_flight_requests; RequestSet in_flight_requests;
}; };
...@@ -305,9 +306,25 @@ void ResourceScheduler::OnWillInsertBody(int child_id, int route_id) { ...@@ -305,9 +306,25 @@ void ResourceScheduler::OnWillInsertBody(int child_id, int route_id) {
} }
Client* client = it->second; Client* client = it->second;
client->has_body = false; client->has_body = true;
if (!client->has_body) { LoadAnyStartablePendingRequests(client);
client->has_body = true; }
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); LoadAnyStartablePendingRequests(client);
} }
} }
...@@ -451,6 +468,10 @@ ResourceScheduler::ShouldStartReqResult ResourceScheduler::ShouldStartRequest( ...@@ -451,6 +468,10 @@ ResourceScheduler::ShouldStartReqResult ResourceScheduler::ShouldStartRequest(
return START_REQUEST; return START_REQUEST;
} }
if (client->using_spdy_proxy && url_request.url().SchemeIs("http")) {
return START_REQUEST;
}
const net::HttpServerProperties& http_server_properties = const net::HttpServerProperties& http_server_properties =
*url_request.context()->http_server_properties(); *url_request.context()->http_server_properties();
......
...@@ -78,6 +78,12 @@ class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe { ...@@ -78,6 +78,12 @@ class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe {
// resource loads won't interfere with first paint. // resource loads won't interfere with first paint.
void OnWillInsertBody(int child_id, int route_id); 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: private:
class RequestQueue; class RequestQueue;
class ScheduledResourceRequest; class ScheduledResourceRequest;
......
...@@ -465,6 +465,20 @@ TEST_F(ResourceSchedulerTest, NonHTTPSchedulesImmediately) { ...@@ -465,6 +465,20 @@ TEST_F(ResourceSchedulerTest, NonHTTPSchedulesImmediately) {
EXPECT_TRUE(request->started()); 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 } // unnamed namespace
} // namespace content } // namespace content
...@@ -506,6 +506,11 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe), ...@@ -506,6 +506,11 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe),
return response_info_.was_fetched_via_proxy; return response_info_.was_fetched_via_proxy;
} }
// Returns true if the URLRequest was delivered over SPDY.
bool was_fetched_via_spdy() const {
return response_info_.was_fetched_via_spdy;
}
// Returns the host and port that the content was fetched from. See // Returns the host and port that the content was fetched from. See
// http_response_info.h for caveats relating to cached content. // http_response_info.h for caveats relating to cached content.
HostPortPair GetSocketAddress() const; HostPortPair GetSocketAddress() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment