diff options
author | gavinp@google.com <gavinp@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-31 01:30:03 +0000 |
---|---|---|
committer | gavinp@google.com <gavinp@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-31 01:30:03 +0000 |
commit | c9c6f5cbd15124457b0fe77f03fda9e4c4855f48 (patch) | |
tree | c23bd4ba9fbe29cfd872bc38f4f3b808c39fd949 | |
parent | 8dd21c4de17c8011703f3ac5a6e155b6325f65a2 (diff) | |
download | chromium_src-c9c6f5cbd15124457b0fe77f03fda9e4c4855f48.zip chromium_src-c9c6f5cbd15124457b0fe77f03fda9e4c4855f48.tar.gz chromium_src-c9c6f5cbd15124457b0fe77f03fda9e4c4855f48.tar.bz2 |
Implement prefetching in chrome
With this CL (see also issue 2910009), chrome will support basic
prefetching. You can optionally deactivate prefetching with the
command line argument --disable-prefetch.
A new RequestPriority was created as well, IDLE, which is lower
than LOWEST. Unfortunately, SPDY has only two bits for priority, so
as a temporary measure (pending SPDY v3 which will have three), we
have a mapping in SPDY that folds net::LOWEST and net::IDLE together.
BUG=13505
TEST=http://gemal.dk/browserspy/prefetch.php
Review URL: http://codereview.chromium.org/3050016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54421 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | build/features_override.gypi | 1 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host.cc | 11 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 5 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/test/functional/prefetch.py | 138 | ||||
-rw-r--r-- | net/base/host_resolver_impl.cc | 3 | ||||
-rw-r--r-- | net/base/request_priority.h | 2 | ||||
-rw-r--r-- | net/http/http_network_transaction.cc | 16 | ||||
-rw-r--r-- | net/http/http_network_transaction.h | 2 | ||||
-rw-r--r-- | net/socket/client_socket_pool_base_unittest.cc | 16 | ||||
-rw-r--r-- | net/spdy/spdy_network_transaction_unittest.cc | 65 | ||||
-rw-r--r-- | net/spdy/spdy_session.cc | 11 | ||||
-rw-r--r-- | net/spdy/spdy_stream_unittest.cc | 2 | ||||
-rw-r--r-- | net/spdy/spdy_test_util.cc | 17 | ||||
-rw-r--r-- | net/url_request/url_request.h | 2 | ||||
-rw-r--r-- | webkit/glue/resource_type.h | 1 | ||||
-rw-r--r-- | webkit/glue/weburlloader_impl.cc | 2 |
17 files changed, 269 insertions, 26 deletions
diff --git a/build/features_override.gypi b/build/features_override.gypi index c7f19b1..08fd7cb 100644 --- a/build/features_override.gypi +++ b/build/features_override.gypi @@ -28,6 +28,7 @@ 'ENABLE_INPUT_SPEECH=1', 'ENABLE_JAVASCRIPT_DEBUGGER=1', 'ENABLE_JSC_MULTIPLE_THREADS=0', + 'ENABLE_LINK_PREFETCH=0', 'ENABLE_METER_TAG=1', 'ENABLE_NOTIFICATIONS=1', 'ENABLE_OFFLINE_WEB_APPLICATIONS=1', diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index 7e53a5e..92e8514 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -125,6 +125,10 @@ bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type, if (process_type == ChildProcessInfo::PLUGIN_PROCESS) return true; + if (request_data.resource_type == ResourceType::PREFETCH && + CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisablePrefetch)) + return false; + ChildProcessSecurityPolicy* policy = ChildProcessSecurityPolicy::GetInstance(); @@ -1837,12 +1841,17 @@ net::RequestPriority ResourceDispatcherHost::DetermineRequestPriority( case ResourceType::SHARED_WORKER: return net::LOW; - // Images are the lowest priority because they typically do not block + // Images are the "lowest" priority because they typically do not block // downloads or rendering and most pages have some useful content without // them. case ResourceType::IMAGE: return net::LOWEST; + // Prefetches are at a lower priority than even LOWEST, since they + // are not even required for rendering of the current page. + case ResourceType::PREFETCH: + return net::IDLE; + default: // When new resource types are added, their priority must be considered. NOTREACHED(); diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 138f7ae..faf6480 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -184,6 +184,11 @@ const char kDisablePlugins[] = "disable-plugins"; // Disable pop-up blocking. const char kDisablePopupBlocking[] = "disable-popup-blocking"; +// Disable requests that webkit labels TargetIsPrefetch. As of +// writing only <link rel=prefetch...> but also eventually +// Link: headers. +const char kDisablePrefetch[] = "disable-prefetch"; + // Normally when the user attempts to navigate to a page that was the result of // a post we prompt to make sure they want to. This switch may be used to // disable that check. This switch is used during automated testing. diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 2a25668..8f0f38e 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -67,6 +67,7 @@ extern const char kDisableLogging[]; extern const char kDisableNewTabFirstRun[]; extern const char kDisablePlugins[]; extern const char kDisablePopupBlocking[]; +extern const char kDisablePrefetch[]; extern const char kDisablePromptOnRepost[]; extern const char kDisableRemoteFonts[]; extern const char kDisableRendererAccessibility[]; diff --git a/chrome/test/functional/prefetch.py b/chrome/test/functional/prefetch.py new file mode 100644 index 0000000..30c0912 --- /dev/null +++ b/chrome/test/functional/prefetch.py @@ -0,0 +1,138 @@ +#!/usr/bin/python +# Copyright (c) 2010 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# this functional test spawns a web server, and runs chrome to point +# at that web server. The content served contains prefetch requests, +# and the tests assert that the webserver logs reflect that. + +# run like any functional test: +# $ python chrome/test/functional/prefetch.py +# in a repo with a built pyautolib + +# the import of multiprocessing implies python 2.6 is required + +import os +import time +import multiprocessing +import Queue +import string +from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer + +import pyauto_functional # Must be imported before pyauto +import pyauto + +# this class handles IPC retrieving server "logs" from our integral +# server. Each test should clear() the log, and then run asserts on +# the retrieval list. + +# at startup, the server puts an int in the queue which is its port, +# we store that for subsequent tests + +class ServerLog: + def clear(self): + self.log = {} + + def __init__(self,queue): + self.clear() + self.port = None + self.queue = queue + + def _readQueue(self): + try: + while True: + queueval = self.queue.get(False) + if isinstance(queueval,int): + self.port = queueval + else: + self.log[queueval] = True + except Queue.Empty: + return + + def getPort(self): + if not self.port: + self._readQueue() + return self.port + + def isRetrieved(self,path): + self._readQueue() + try: + return self.log[path] + except KeyError: + return None + +# +# The next few classes run a simple web server that returns log information +# via a multiprocessing.Queue. +# +class AbstractPrefetchServerHandler(BaseHTTPRequestHandler): + content = { + "prefetch-origin.html": + (200, """<html><head> +<link rel="prefetch" href="static-prefetch-target.html"> +<script type="text/javascript"> +function changeParagraph() +{ + var newPara = document.createElement("p"); + newPara.innerHTML = + "<link rel=\\"prefetch\\" href=\\"dynamic-prefetch-target.html\\">" + + "<p>This paragraph contains a dynamic link prefetch. " + + "The target of this prefetch is " + + "<a href=\\"dynamic-prefetch-target.html\\">this document.</a>"; + var para = document.getElementById("p1"); + document.body.insertBefore(newPara,para); +} +</script> +</head> +<body onload="changeParagraph()"> +<p id="p1">This is a document that contains a link prefetch. The target of +that prefetch is <a href="static-prefetch-target.html">this document.</a> +</body>"""), + "static-prefetch-target.html": + (200, "<html><head></head><body>empty</body>"), + "dynamic-prefetch-target.html": + (200, "<html><head></head><body>empty</body>")} + + def do_GET(self): + self.queue.put(self.path[1:]) + try: + response_code, response = self.content[self.path[1:]] + self.send_response(response_code) + self.end_headers() + self.wfile.write(response) + except KeyError: + self.send_response(404) + self.end_headers() + +def run_web_server(queue_arg): + class PrefetchServerHandler(AbstractPrefetchServerHandler): + queue = queue_arg + server = HTTPServer(('',0), PrefetchServerHandler) + queue.put(server.server_port) + server.serve_forever() + +# +# Here's the test itself +# +queue = multiprocessing.Queue() +server_log = ServerLog(queue) + +class PrefetchTest(pyauto.PyUITest): + """Testcase for Prefetching""" + def testBasic(self): + server_log.clear() + url = "http://localhost:%d/prefetch-origin.html" % server_log.getPort() + self.NavigateToURL(url) + self.assertEqual(True, server_log.isRetrieved("prefetch-origin.html")) + time.sleep(0.1) # required since prefetches occur after onload + self.assertEqual(True, server_log.isRetrieved( + "static-prefetch-target.html")) + self.assertEqual(True, server_log.isRetrieved( + "dynamic-prefetch-target.html")) + +if __name__ == '__main__': + web_server = multiprocessing.Process(target=run_web_server,args=(queue,)) + web_server.daemon = True + web_server.start() + pyauto_functional.Main() diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc index 8d5fe26..43889ac 100644 --- a/net/base/host_resolver_impl.cc +++ b/net/base/host_resolver_impl.cc @@ -560,7 +560,8 @@ class HostResolverImpl::IPv6ProbeJob // and increasing for lower priorities. COMPILE_ASSERT(HIGHEST == 0u && LOWEST > HIGHEST && - NUM_PRIORITIES > LOWEST, + IDLE > LOWEST && + NUM_PRIORITIES > IDLE, priority_indexes_incompatible); // JobPool contains all the information relating to queued requests, including diff --git a/net/base/request_priority.h b/net/base/request_priority.h index 6d9b2a5..ca7a1ec 100644 --- a/net/base/request_priority.h +++ b/net/base/request_priority.h @@ -15,10 +15,10 @@ enum RequestPriority { MEDIUM, LOW, LOWEST, + IDLE, NUM_PRIORITIES, }; } // namespace net #endif // NET_BASE_REQUEST_PRIORITY_H__ - diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index e553ec4..ee98cca 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -1882,6 +1882,22 @@ std::string HttpNetworkTransaction::DescribeState(State state) { return description; } +// TODO(gavinp): re-adjust this once SPDY v3 has three priority bits, +// eliminating the need for this folding. +int ConvertRequestPriorityToSpdyPriority(const RequestPriority priority) { + DCHECK(HIGHEST <= priority && priority < NUM_PRIORITIES); + switch (priority) { + case LOWEST: + return SPDY_PRIORITY_LOWEST-1; + case IDLE: + return SPDY_PRIORITY_LOWEST; + default: + return priority; + } +} + + + #undef STATE_CASE } // namespace net diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h index 695d7b9..b3a083c 100644 --- a/net/http/http_network_transaction.h +++ b/net/http/http_network_transaction.h @@ -340,6 +340,8 @@ class HttpNetworkTransaction : public HttpTransaction { DISALLOW_COPY_AND_ASSIGN(HttpNetworkTransaction); }; +int ConvertRequestPriorityToSpdyPriority(RequestPriority priority); + } // namespace net #endif // NET_HTTP_HTTP_NETWORK_TRANSACTION_H_ diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc index 55f1949..bc3669d 100644 --- a/net/socket/client_socket_pool_base_unittest.cc +++ b/net/socket/client_socket_pool_base_unittest.cc @@ -749,7 +749,7 @@ TEST_F(ClientSocketPoolBaseTest, TotalLimitRespectsPriority) { EXPECT_EQ(5, GetOrderOfRequest(7)); // Make sure we test order of all requests made. - EXPECT_EQ(kIndexOutOfBounds, GetOrderOfRequest(8)); + EXPECT_EQ(kIndexOutOfBounds, GetOrderOfRequest(9)); } TEST_F(ClientSocketPoolBaseTest, TotalLimitRespectsGroupLimit) { @@ -1026,6 +1026,7 @@ TEST_F(ClientSocketPoolBaseTest, PendingRequests) { EXPECT_EQ(OK, StartRequest("a", kDefaultPriority)); EXPECT_EQ(OK, StartRequest("a", kDefaultPriority)); + EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", IDLE)); EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", LOWEST)); EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", MEDIUM)); EXPECT_EQ(ERR_IO_PENDING, StartRequest("a", HIGHEST)); @@ -1040,14 +1041,15 @@ TEST_F(ClientSocketPoolBaseTest, PendingRequests) { EXPECT_EQ(1, GetOrderOfRequest(1)); EXPECT_EQ(2, GetOrderOfRequest(2)); - EXPECT_EQ(6, GetOrderOfRequest(3)); - EXPECT_EQ(4, GetOrderOfRequest(4)); - EXPECT_EQ(3, GetOrderOfRequest(5)); - EXPECT_EQ(5, GetOrderOfRequest(6)); - EXPECT_EQ(7, GetOrderOfRequest(7)); + EXPECT_EQ(8, GetOrderOfRequest(3)); + EXPECT_EQ(6, GetOrderOfRequest(4)); + EXPECT_EQ(4, GetOrderOfRequest(5)); + EXPECT_EQ(3, GetOrderOfRequest(6)); + EXPECT_EQ(5, GetOrderOfRequest(7)); + EXPECT_EQ(7, GetOrderOfRequest(8)); // Make sure we test order of all requests made. - EXPECT_EQ(kIndexOutOfBounds, GetOrderOfRequest(8)); + EXPECT_EQ(kIndexOutOfBounds, GetOrderOfRequest(9)); } TEST_F(ClientSocketPoolBaseTest, PendingRequests_NoKeepAlive) { diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc index 66feee0..f29d69f 100644 --- a/net/spdy/spdy_network_transaction_unittest.cc +++ b/net/spdy/spdy_network_transaction_unittest.cc @@ -289,6 +289,59 @@ TEST_P(SpdyNetworkTransactionTest, Get) { EXPECT_EQ("hello!", out.response_data); } +TEST_P(SpdyNetworkTransactionTest, GetAtEachPriority) { + for (RequestPriority p = HIGHEST; p < NUM_PRIORITIES; + p = RequestPriority(p+1)) { + // Construct the request. + scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, p)); + MockWrite writes[] = { CreateMockWrite(*req) }; + + const int spdy_prio = reinterpret_cast<spdy::SpdySynStreamControlFrame*>( + req.get())->priority(); + // this repeats the RequestPriority-->SpdyPriority mapping from + // SpdyFramer::ConvertRequestPriorityToSpdyPriority to make + // sure it's being done right. + switch(p) { + case HIGHEST: + EXPECT_EQ(0, spdy_prio); + break; + case MEDIUM: + EXPECT_EQ(1, spdy_prio); + break; + case LOW: + case LOWEST: + EXPECT_EQ(2, spdy_prio); + break; + case IDLE: + EXPECT_EQ(3, spdy_prio); + break; + default: + FAIL(); + } + + scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); + scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, true)); + MockRead reads[] = { + CreateMockRead(*resp), + CreateMockRead(*body), + MockRead(true, 0, 0) // EOF + }; + + scoped_refptr<DelayedSocketData> data( + new DelayedSocketData(1, reads, arraysize(reads), + writes, arraysize(writes))); + HttpRequestInfo http_req = CreateGetRequest(); + http_req.priority = p; + + NormalSpdyTransactionHelper helper(http_req, BoundNetLog(), GetParam()); + helper.RunToCompletion(data.get()); + TransactionHelperResult out = helper.output(); + EXPECT_EQ(OK, out.rv); + EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); + EXPECT_EQ("hello!", out.response_data); + } +} + // Start three gets simultaniously; making sure that multiplexed // streams work properly. @@ -1482,7 +1535,8 @@ TEST_P(SpdyNetworkTransactionTest, SynReplyHeadersVary) { spdy::SYN_REPLY, // Syn Reply 1, // Stream ID 0, // Associated Stream ID - SPDY_PRIORITY_LOWEST, // Priority + net::ConvertRequestPriorityToSpdyPriority(LOWEST), + // Priority spdy::CONTROL_FLAG_NONE, // Control Flags false, // Compressed spdy::INVALID, // Status @@ -1650,7 +1704,8 @@ TEST_P(SpdyNetworkTransactionTest, InvalidSynReply) { spdy::SYN_REPLY, // Kind = SynReply 1, // Stream ID 0, // Associated stream ID - SPDY_PRIORITY_LOWEST, // Priority + net::ConvertRequestPriorityToSpdyPriority(LOWEST), + // Priority spdy::CONTROL_FLAG_NONE, // Control Flags false, // Compressed spdy::INVALID, // Status @@ -2411,7 +2466,8 @@ TEST_P(SpdyNetworkTransactionTest, SettingsSaved) { spdy::SYN_REPLY, // Syn Reply 1, // Stream ID 0, // Associated Stream ID - SPDY_PRIORITY_LOWEST, // Priority + net::ConvertRequestPriorityToSpdyPriority(LOWEST), + // Priority spdy::CONTROL_FLAG_NONE, // Control Flags false, // Compressed spdy::INVALID, // Status @@ -2515,7 +2571,8 @@ TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { spdy::SYN_REPLY, // Syn Reply 1, // Stream ID 0, // Associated Stream ID - SPDY_PRIORITY_LOWEST, // Priority + net::ConvertRequestPriorityToSpdyPriority(LOWEST), + // Priority spdy::CONTROL_FLAG_NONE, // Control Flags false, // Compressed spdy::INVALID, // Status diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index 9f2b82f..7ff500a 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -226,7 +226,7 @@ net::Error SpdySession::Connect( const std::string& group_name, const scoped_refptr<TCPSocketParams>& destination, RequestPriority priority) { - DCHECK(priority >= SPDY_PRIORITY_HIGHEST && priority <= SPDY_PRIORITY_LOWEST); + DCHECK(priority >= net::HIGHEST && priority < net::NUM_PRIORITIES); // If the connect process is started, let the caller continue. if (state_ > IDLE) @@ -385,8 +385,7 @@ int SpdySession::CreateStreamImpl( LOG(INFO) << "SpdyStream: Creating stream " << stream_id << " for " << url; // TODO(mbelshe): Optimize memory allocations - DCHECK(priority >= SPDY_PRIORITY_HIGHEST && - priority <= SPDY_PRIORITY_LOWEST); + DCHECK(priority >= net::HIGHEST && priority < net::NUM_PRIORITIES); DCHECK_EQ(active_streams_[stream_id].get(), stream.get()); return OK; @@ -404,8 +403,10 @@ int SpdySession::WriteSynStream( CHECK_EQ(stream->stream_id(), stream_id); scoped_ptr<spdy::SpdySynStreamControlFrame> syn_frame( - spdy_framer_.CreateSynStream(stream_id, 0, priority, flags, false, - headers.get())); + spdy_framer_.CreateSynStream( + stream_id, 0, + ConvertRequestPriorityToSpdyPriority(priority), + flags, false, headers.get())); QueueFrame(syn_frame.get(), priority, stream); static StatsCounter spdy_requests("spdy.requests"); diff --git a/net/spdy/spdy_stream_unittest.cc b/net/spdy/spdy_stream_unittest.cc index 4daad96..471a1786 100644 --- a/net/spdy/spdy_stream_unittest.cc +++ b/net/spdy/spdy_stream_unittest.cc @@ -141,7 +141,7 @@ TEST_F(SpdyStreamTest, SendDataAfterOpen) { spdy::SYN_STREAM, 1, 0, - SPDY_PRIORITY_LOWEST, + net::ConvertRequestPriorityToSpdyPriority(LOWEST), spdy::CONTROL_FLAG_NONE, false, spdy::INVALID, diff --git a/net/spdy/spdy_test_util.cc b/net/spdy/spdy_test_util.cc index 5d65b4a..2b75b0c 100644 --- a/net/spdy/spdy_test_util.cc +++ b/net/spdy/spdy_test_util.cc @@ -8,6 +8,8 @@ #include "base/basictypes.h" #include "base/string_util.h" +#include "net/http/http_network_transaction.h" +#include "net/spdy/spdy_framer.h" namespace net { @@ -261,7 +263,8 @@ spdy::SpdyFrame* ConstructSpdyGet(const char* const url, spdy::SYN_STREAM, // Kind = Syn stream_id, // Stream ID 0, // Associated stream ID - request_priority, // Priority + net::ConvertRequestPriorityToSpdyPriority(request_priority), + // Priority spdy::CONTROL_FLAG_FIN, // Control Flags compressed, // Compressed spdy::INVALID, // Status @@ -319,7 +322,8 @@ spdy::SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], spdy::SYN_STREAM, // Kind = Syn stream_id, // Stream ID 0, // Associated stream ID - request_priority, // Priority + net::ConvertRequestPriorityToSpdyPriority(request_priority), + // Priority spdy::CONTROL_FLAG_FIN, // Control Flags compressed, // Compressed spdy::INVALID, // Status @@ -358,7 +362,8 @@ spdy::SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[], spdy::SYN_REPLY, // Kind = SynReply stream_id, // Stream ID 0, // Associated stream ID - SPDY_PRIORITY_LOWEST, // Priority + net::ConvertRequestPriorityToSpdyPriority(LOWEST), + // Priority spdy::CONTROL_FLAG_NONE, // Control Flags false, // Compressed spdy::INVALID, // Status @@ -396,7 +401,8 @@ spdy::SpdyFrame* ConstructSpdyPost(int64 content_length, spdy::SYN_STREAM, // Kind = Syn 1, // Stream ID 0, // Associated stream ID - SPDY_PRIORITY_LOWEST, // Priority + net::ConvertRequestPriorityToSpdyPriority(LOWEST), + // Priority spdy::CONTROL_FLAG_NONE, // Control Flags false, // Compressed spdy::INVALID, // Status @@ -437,7 +443,8 @@ spdy::SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[], spdy::SYN_REPLY, // Kind = SynReply 1, // Stream ID 0, // Associated stream ID - SPDY_PRIORITY_LOWEST, // Priority + net::ConvertRequestPriorityToSpdyPriority(LOWEST), + // Priority spdy::CONTROL_FLAG_NONE, // Control Flags false, // Compressed spdy::INVALID, // Status diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h index a6ef386..06b1048 100644 --- a/net/url_request/url_request.h +++ b/net/url_request/url_request.h @@ -545,7 +545,7 @@ class URLRequest : public NonThreadSafe { net::RequestPriority priority() const { return priority_; } void set_priority(net::RequestPriority priority) { DCHECK_GE(priority, net::HIGHEST); - DCHECK_LE(priority, net::LOWEST); + DCHECK_LT(priority, net::NUM_PRIORITIES); priority_ = priority; } diff --git a/webkit/glue/resource_type.h b/webkit/glue/resource_type.h index aa4a072..1de4fd2 100644 --- a/webkit/glue/resource_type.h +++ b/webkit/glue/resource_type.h @@ -22,6 +22,7 @@ class ResourceType { MEDIA, // a media resource. WORKER, // the main resource of a dedicated worker. SHARED_WORKER, // the main resource of a shared worker. + PREFETCH, // an explicitly requested prefetch LAST_TYPE // Place holder so we don't need to change ValidType // everytime. }; diff --git a/webkit/glue/weburlloader_impl.cc b/webkit/glue/weburlloader_impl.cc index dcb05fa..3b61bc0 100644 --- a/webkit/glue/weburlloader_impl.cc +++ b/webkit/glue/weburlloader_impl.cc @@ -132,6 +132,8 @@ ResourceType::Type FromTargetType(WebURLRequest::TargetType type) { return ResourceType::WORKER; case WebURLRequest::TargetIsSharedWorker: return ResourceType::SHARED_WORKER; + case WebURLRequest::TargetIsPrefetch: + return ResourceType::PREFETCH; default: NOTREACHED(); return ResourceType::SUB_RESOURCE; |