OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 void WriteHeaders(disk_cache::Entry* entry, int flags, const std::string data) { | 33 void WriteHeaders(disk_cache::Entry* entry, int flags, const std::string data) { |
34 if (data.empty()) | 34 if (data.empty()) |
35 return; | 35 return; |
36 | 36 |
37 Pickle pickle; | 37 Pickle pickle; |
38 pickle.WriteInt(flags | 1); // Version 1. | 38 pickle.WriteInt(flags | 1); // Version 1. |
39 pickle.WriteInt64(0); | 39 pickle.WriteInt64(0); |
40 pickle.WriteInt64(0); | 40 pickle.WriteInt64(0); |
41 pickle.WriteString(data); | 41 pickle.WriteString(data); |
42 | 42 |
43 scoped_refptr<net::WrappedIOBuffer> buf = new net::WrappedIOBuffer( | 43 scoped_refptr<net::WrappedIOBuffer> buf(new net::WrappedIOBuffer( |
44 reinterpret_cast<const char*>(pickle.data())); | 44 reinterpret_cast<const char*>(pickle.data()))); |
45 int len = static_cast<int>(pickle.size()); | 45 int len = static_cast<int>(pickle.size()); |
46 | 46 |
47 TestCompletionCallback cb; | 47 TestCompletionCallback cb; |
48 int rv = entry->WriteData(0, 0, buf, len, &cb, true); | 48 int rv = entry->WriteData(0, 0, buf, len, &cb, true); |
49 ASSERT_EQ(len, cb.GetResult(rv)); | 49 ASSERT_EQ(len, cb.GetResult(rv)); |
50 } | 50 } |
51 | 51 |
52 void WriteData(disk_cache::Entry* entry, int index, const std::string data) { | 52 void WriteData(disk_cache::Entry* entry, int index, const std::string data) { |
53 if (data.empty()) | 53 if (data.empty()) |
54 return; | 54 return; |
(...skipping 137 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 |