| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/url_request/view_cache_helper.h" | 5 #include "net/url_request/view_cache_helper.h" |
| 6 | 6 |
| 7 #include "base/pickle.h" | 7 #include "base/pickle.h" |
| 8 #include "net/base/test_completion_callback.h" | 8 #include "net/base/test_completion_callback.h" |
| 9 #include "net/disk_cache/disk_cache.h" | 9 #include "net/disk_cache/disk_cache.h" |
| 10 #include "net/http/http_cache.h" | 10 #include "net/http/http_cache.h" |
| 11 #include "net/url_request/url_request_context.h" | 11 #include "net/url_request/url_request_context.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 class TestURLRequestContext : public URLRequestContext { | 16 class TestURLRequestContext : public net::URLRequestContext { |
| 17 public: | 17 public: |
| 18 TestURLRequestContext(); | 18 TestURLRequestContext(); |
| 19 | 19 |
| 20 // Gets a pointer to the cache backend. | 20 // Gets a pointer to the cache backend. |
| 21 disk_cache::Backend* GetBackend(); | 21 disk_cache::Backend* GetBackend(); |
| 22 | 22 |
| 23 private: | 23 private: |
| 24 net::HttpCache cache_; | 24 net::HttpCache cache_; |
| 25 }; | 25 }; |
| 26 | 26 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 ASSERT_EQ(net::OK, cb.GetResult(rv)); | 74 ASSERT_EQ(net::OK, cb.GetResult(rv)); |
| 75 } | 75 } |
| 76 | 76 |
| 77 WriteHeaders(entry, 0, data0); | 77 WriteHeaders(entry, 0, data0); |
| 78 WriteData(entry, 1, data1); | 78 WriteData(entry, 1, data1); |
| 79 WriteData(entry, 2, data2); | 79 WriteData(entry, 2, data2); |
| 80 | 80 |
| 81 entry->Close(); | 81 entry->Close(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void FillCache(URLRequestContext* context) { | 84 void FillCache(net::URLRequestContext* context) { |
| 85 TestCompletionCallback cb; | 85 TestCompletionCallback cb; |
| 86 disk_cache::Backend* cache; | 86 disk_cache::Backend* cache; |
| 87 int rv = | 87 int rv = |
| 88 context->http_transaction_factory()->GetCache()->GetBackend(&cache, &cb); | 88 context->http_transaction_factory()->GetCache()->GetBackend(&cache, &cb); |
| 89 ASSERT_EQ(net::OK, cb.GetResult(rv)); | 89 ASSERT_EQ(net::OK, cb.GetResult(rv)); |
| 90 | 90 |
| 91 std::string empty; | 91 std::string empty; |
| 92 WriteToEntry(cache, "first", "some", empty, empty); | 92 WriteToEntry(cache, "first", "some", empty, empty); |
| 93 WriteToEntry(cache, "second", "only hex_dumped", "same", "kind"); | 93 WriteToEntry(cache, "second", "only hex_dumped", "same", "kind"); |
| 94 WriteToEntry(cache, "third", empty, "another", "thing"); | 94 WriteToEntry(cache, "third", empty, "another", "thing"); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 int flags = 1 << 12; | 192 int flags = 1 << 12; |
| 193 WriteHeaders(entry, flags, "something"); | 193 WriteHeaders(entry, flags, "something"); |
| 194 entry->Close(); | 194 entry->Close(); |
| 195 | 195 |
| 196 std::string data; | 196 std::string data; |
| 197 rv = helper.GetEntryInfoHTML(key, context, &data, &cb); | 197 rv = helper.GetEntryInfoHTML(key, context, &data, &cb); |
| 198 EXPECT_EQ(net::OK, cb.GetResult(rv)); | 198 EXPECT_EQ(net::OK, cb.GetResult(rv)); |
| 199 | 199 |
| 200 EXPECT_NE(std::string::npos, data.find("RESPONSE_INFO_TRUNCATED")); | 200 EXPECT_NE(std::string::npos, data.find("RESPONSE_INFO_TRUNCATED")); |
| 201 } | 201 } |
| OLD | NEW |