Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: net/http/http_cache_unittest.cc

Issue 478763004: Bypass http cache for concurrent range requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_cache.h" 5 #include "net/http/http_cache.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 6772 matching lines...) Expand 10 before | Expand all | Expand 10 after
6783 6783
6784 EXPECT_EQ(1, cache.network_layer()->transaction_count()); 6784 EXPECT_EQ(1, cache.network_layer()->transaction_count());
6785 6785
6786 // Send the request again and check that Resource-Freshness header is absent. 6786 // Send the request again and check that Resource-Freshness header is absent.
6787 stale_while_revalidate_transaction.handler = CheckResourceFreshnessAbsent; 6787 stale_while_revalidate_transaction.handler = CheckResourceFreshnessAbsent;
6788 6788
6789 RunTransactionTest(cache.http_cache(), stale_while_revalidate_transaction); 6789 RunTransactionTest(cache.http_cache(), stale_while_revalidate_transaction);
6790 6790
6791 EXPECT_EQ(2, cache.network_layer()->transaction_count()); 6791 EXPECT_EQ(2, cache.network_layer()->transaction_count());
6792 } 6792 }
6793
6794 // Tests that we allow multiple simultaneous, non-overlapping transactions to
6795 // take place on a sparse entry.
6796 TEST(HttpCache, RangeGET_MultipleRequests) {
6797 MockHttpCache cache;
6798
6799 // Create a transaction for bytes 0-9.
6800 MockHttpRequest request(kRangeGET_TransactionOK);
6801 MockTransaction transaction(kRangeGET_TransactionOK);
6802 transaction.request_headers = "Range: bytes = 0-9\r\n" EXTRA_HEADER;
6803 transaction.data = "rg: 00-09 ";
6804 AddMockTransaction(&transaction);
6805
6806 net::TestCompletionCallback callback;
6807 scoped_ptr<net::HttpTransaction> trans;
6808 int rv = cache.http_cache()->CreateTransaction(net::DEFAULT_PRIORITY, &trans);
6809 EXPECT_EQ(net::OK, rv);
6810 ASSERT_TRUE(trans.get());
6811
6812 // Start our transaction.
6813 trans->Start(&request, callback.callback(), net::BoundNetLog());
6814
6815 // A second transaction on a different part of the file (the default
6816 // kRangeGET_TransactionOK requests 40-49) should not be blocked by
6817 // the already pending transaction.
6818 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK);
6819
6820 // Let the first transaction complete.
6821 callback.WaitForResult();
6822
6823 RemoveMockTransaction(&transaction);
6824 }
OLDNEW
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698