| 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 5443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5454 | 5454 |
| 5455 // Tests basic pickling/unpickling of HttpResponseInfo. | 5455 // Tests basic pickling/unpickling of HttpResponseInfo. |
| 5456 TEST(HttpCache, PersistHttpResponseInfo) { | 5456 TEST(HttpCache, PersistHttpResponseInfo) { |
| 5457 // Set some fields (add more if needed.) | 5457 // Set some fields (add more if needed.) |
| 5458 HttpResponseInfo response1; | 5458 HttpResponseInfo response1; |
| 5459 response1.was_cached = false; | 5459 response1.was_cached = false; |
| 5460 response1.socket_address = HostPortPair("1.2.3.4", 80); | 5460 response1.socket_address = HostPortPair("1.2.3.4", 80); |
| 5461 response1.headers = new HttpResponseHeaders("HTTP/1.1 200 OK"); | 5461 response1.headers = new HttpResponseHeaders("HTTP/1.1 200 OK"); |
| 5462 | 5462 |
| 5463 // Pickle. | 5463 // Pickle. |
| 5464 Pickle pickle; | 5464 base::Pickle pickle; |
| 5465 response1.Persist(&pickle, false, false); | 5465 response1.Persist(&pickle, false, false); |
| 5466 | 5466 |
| 5467 // Unpickle. | 5467 // Unpickle. |
| 5468 HttpResponseInfo response2; | 5468 HttpResponseInfo response2; |
| 5469 bool response_truncated; | 5469 bool response_truncated; |
| 5470 EXPECT_TRUE(response2.InitFromPickle(pickle, &response_truncated)); | 5470 EXPECT_TRUE(response2.InitFromPickle(pickle, &response_truncated)); |
| 5471 EXPECT_FALSE(response_truncated); | 5471 EXPECT_FALSE(response_truncated); |
| 5472 | 5472 |
| 5473 // Verify fields. | 5473 // Verify fields. |
| 5474 EXPECT_TRUE(response2.was_cached); // InitFromPickle sets this flag. | 5474 EXPECT_TRUE(response2.was_cached); // InitFromPickle sets this flag. |
| (...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7801 EXPECT_EQ(LOAD_STATE_WAITING_FOR_CACHE, second->trans->GetLoadState()); | 7801 EXPECT_EQ(LOAD_STATE_WAITING_FOR_CACHE, second->trans->GetLoadState()); |
| 7802 base::MessageLoop::current()->RunUntilIdle(); | 7802 base::MessageLoop::current()->RunUntilIdle(); |
| 7803 EXPECT_EQ(LOAD_STATE_IDLE, second->trans->GetLoadState()); | 7803 EXPECT_EQ(LOAD_STATE_IDLE, second->trans->GetLoadState()); |
| 7804 ASSERT_TRUE(second->trans->GetResponseInfo()); | 7804 ASSERT_TRUE(second->trans->GetResponseInfo()); |
| 7805 EXPECT_TRUE(second->trans->GetResponseInfo()->headers->HasHeaderValue( | 7805 EXPECT_TRUE(second->trans->GetResponseInfo()->headers->HasHeaderValue( |
| 7806 "Cache-Control", "no-store")); | 7806 "Cache-Control", "no-store")); |
| 7807 ReadAndVerifyTransaction(second->trans.get(), kSimpleGET_Transaction); | 7807 ReadAndVerifyTransaction(second->trans.get(), kSimpleGET_Transaction); |
| 7808 } | 7808 } |
| 7809 | 7809 |
| 7810 } // namespace net | 7810 } // namespace net |
| OLD | NEW |