OLD | NEW |
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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 5917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5928 EXPECT_FALSE(cache.network_layer()->last_transaction()); | 5928 EXPECT_FALSE(cache.network_layer()->last_transaction()); |
5929 EXPECT_EQ(net::DEFAULT_PRIORITY, | 5929 EXPECT_EQ(net::DEFAULT_PRIORITY, |
5930 cache.network_layer()->last_create_transaction_priority()); | 5930 cache.network_layer()->last_create_transaction_priority()); |
5931 | 5931 |
5932 net::HttpRequestInfo info; | 5932 net::HttpRequestInfo info; |
5933 info.url = GURL(kSimpleGET_Transaction.url); | 5933 info.url = GURL(kSimpleGET_Transaction.url); |
5934 net::TestCompletionCallback callback; | 5934 net::TestCompletionCallback callback; |
5935 EXPECT_EQ(net::ERR_IO_PENDING, | 5935 EXPECT_EQ(net::ERR_IO_PENDING, |
5936 trans->Start(&info, callback.callback(), net::BoundNetLog())); | 5936 trans->Start(&info, callback.callback(), net::BoundNetLog())); |
5937 | 5937 |
5938 ASSERT_TRUE(cache.network_layer()->last_transaction()); | 5938 EXPECT_TRUE(cache.network_layer()->last_transaction()); |
5939 EXPECT_EQ(net::LOW, | 5939 if (cache.network_layer()->last_transaction()) { |
5940 cache.network_layer()->last_create_transaction_priority()); | 5940 EXPECT_EQ(net::LOW, |
5941 EXPECT_EQ(net::LOW, | 5941 cache.network_layer()->last_create_transaction_priority()); |
5942 cache.network_layer()->last_transaction()->priority()); | 5942 EXPECT_EQ(net::LOW, |
| 5943 cache.network_layer()->last_transaction()->priority()); |
| 5944 } |
5943 | 5945 |
5944 trans->SetPriority(net::HIGHEST); | 5946 trans->SetPriority(net::HIGHEST); |
5945 EXPECT_EQ(net::LOW, | 5947 |
5946 cache.network_layer()->last_create_transaction_priority()); | 5948 if (cache.network_layer()->last_transaction()) { |
5947 EXPECT_EQ(net::HIGHEST, | 5949 EXPECT_EQ(net::LOW, |
5948 cache.network_layer()->last_transaction()->priority()); | 5950 cache.network_layer()->last_create_transaction_priority()); |
| 5951 EXPECT_EQ(net::HIGHEST, |
| 5952 cache.network_layer()->last_transaction()->priority()); |
| 5953 } |
5949 | 5954 |
5950 EXPECT_EQ(net::OK, callback.WaitForResult()); | 5955 EXPECT_EQ(net::OK, callback.WaitForResult()); |
5951 } | 5956 } |
5952 | 5957 |
5953 // Make sure that a cache transaction passes on its priority to | 5958 // Make sure that a cache transaction passes on its priority to |
5954 // newly-created network transactions. | 5959 // newly-created network transactions. |
5955 TEST(HttpCache, SetPriorityNewTransaction) { | 5960 TEST(HttpCache, SetPriorityNewTransaction) { |
5956 MockHttpCache cache; | 5961 MockHttpCache cache; |
5957 AddMockTransaction(&kRangeGET_TransactionOK); | 5962 AddMockTransaction(&kRangeGET_TransactionOK); |
5958 | 5963 |
(...skipping 30 matching lines...) Expand all Loading... |
5989 trans->SetPriority(net::HIGHEST); | 5994 trans->SetPriority(net::HIGHEST); |
5990 // Should trigger a new network transaction and pick up the new | 5995 // Should trigger a new network transaction and pick up the new |
5991 // priority. | 5996 // priority. |
5992 ReadAndVerifyTransaction(trans.get(), transaction); | 5997 ReadAndVerifyTransaction(trans.get(), transaction); |
5993 | 5998 |
5994 EXPECT_EQ(net::HIGHEST, | 5999 EXPECT_EQ(net::HIGHEST, |
5995 cache.network_layer()->last_create_transaction_priority()); | 6000 cache.network_layer()->last_create_transaction_priority()); |
5996 | 6001 |
5997 RemoveMockTransaction(&kRangeGET_TransactionOK); | 6002 RemoveMockTransaction(&kRangeGET_TransactionOK); |
5998 } | 6003 } |
OLD | NEW |