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 /net/spdy/spdy_network_transaction_unittest.cc | |
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
Diffstat (limited to 'net/spdy/spdy_network_transaction_unittest.cc')
-rw-r--r-- | net/spdy/spdy_network_transaction_unittest.cc | 65 |
1 files changed, 61 insertions, 4 deletions
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 |