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 <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 5449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5460 | 5460 |
5461 // Tests basic pickling/unpickling of HttpResponseInfo. | 5461 // Tests basic pickling/unpickling of HttpResponseInfo. |
5462 TEST(HttpCache, PersistHttpResponseInfo) { | 5462 TEST(HttpCache, PersistHttpResponseInfo) { |
5463 // Set some fields (add more if needed.) | 5463 // Set some fields (add more if needed.) |
5464 HttpResponseInfo response1; | 5464 HttpResponseInfo response1; |
5465 response1.was_cached = false; | 5465 response1.was_cached = false; |
5466 response1.socket_address = HostPortPair("1.2.3.4", 80); | 5466 response1.socket_address = HostPortPair("1.2.3.4", 80); |
5467 response1.headers = new HttpResponseHeaders("HTTP/1.1 200 OK"); | 5467 response1.headers = new HttpResponseHeaders("HTTP/1.1 200 OK"); |
5468 | 5468 |
5469 // Pickle. | 5469 // Pickle. |
5470 Pickle pickle; | 5470 base::Pickle pickle; |
5471 response1.Persist(&pickle, false, false); | 5471 response1.Persist(&pickle, false, false); |
5472 | 5472 |
5473 // Unpickle. | 5473 // Unpickle. |
5474 HttpResponseInfo response2; | 5474 HttpResponseInfo response2; |
5475 bool response_truncated; | 5475 bool response_truncated; |
5476 EXPECT_TRUE(response2.InitFromPickle(pickle, &response_truncated)); | 5476 EXPECT_TRUE(response2.InitFromPickle(pickle, &response_truncated)); |
5477 EXPECT_FALSE(response_truncated); | 5477 EXPECT_FALSE(response_truncated); |
5478 | 5478 |
5479 // Verify fields. | 5479 // Verify fields. |
5480 EXPECT_TRUE(response2.was_cached); // InitFromPickle sets this flag. | 5480 EXPECT_TRUE(response2.was_cached); // InitFromPickle sets this flag. |
(...skipping 2361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7842 // Here the second transaction proceeds without reading the first body. | 7842 // Here the second transaction proceeds without reading the first body. |
7843 EXPECT_EQ(LOAD_STATE_WAITING_FOR_CACHE, second->trans->GetLoadState()); | 7843 EXPECT_EQ(LOAD_STATE_WAITING_FOR_CACHE, second->trans->GetLoadState()); |
7844 base::MessageLoop::current()->RunUntilIdle(); | 7844 base::MessageLoop::current()->RunUntilIdle(); |
7845 EXPECT_EQ(LOAD_STATE_IDLE, second->trans->GetLoadState()); | 7845 EXPECT_EQ(LOAD_STATE_IDLE, second->trans->GetLoadState()); |
7846 ASSERT_TRUE(second->trans->GetResponseInfo()); | 7846 ASSERT_TRUE(second->trans->GetResponseInfo()); |
7847 EXPECT_TRUE(second->trans->GetResponseInfo()->headers->HasHeaderValue( | 7847 EXPECT_TRUE(second->trans->GetResponseInfo()->headers->HasHeaderValue( |
7848 "Cache-Control", "no-store")); | 7848 "Cache-Control", "no-store")); |
7849 ReadAndVerifyTransaction(second->trans.get(), kSimpleGET_Transaction); | 7849 ReadAndVerifyTransaction(second->trans.get(), kSimpleGET_Transaction); |
7850 } | 7850 } |
7851 } // namespace net | 7851 } // namespace net |
OLD | NEW |