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/tools/quic/quic_in_memory_cache.h" | 5 #include "net/tools/quic/quic_in_memory_cache.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_enumerator.h" |
8 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
9 | 10 |
10 using base::FilePath; | 11 using base::FilePath; |
11 using base::StringPiece; | 12 using base::StringPiece; |
12 using file_util::FileEnumerator; | |
13 using std::string; | 13 using std::string; |
14 | 14 |
15 // Specifies the directory used during QuicInMemoryCache | 15 // Specifies the directory used during QuicInMemoryCache |
16 // construction to seed the cache. Cache directory can be | 16 // construction to seed the cache. Cache directory can be |
17 // generated using `wget -p --save-headers <url> | 17 // generated using `wget -p --save-headers <url> |
18 string FLAGS_quic_in_memory_cache_dir; | 18 string FLAGS_quic_in_memory_cache_dir; |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 namespace tools { | 21 namespace tools { |
22 | 22 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 QuicInMemoryCache::QuicInMemoryCache() { | 112 QuicInMemoryCache::QuicInMemoryCache() { |
113 // If there's no defined cache dir, we have no initialization to do. | 113 // If there's no defined cache dir, we have no initialization to do. |
114 if (FLAGS_quic_in_memory_cache_dir.empty()) { | 114 if (FLAGS_quic_in_memory_cache_dir.empty()) { |
115 LOG(WARNING) << "No cache directory found. Skipping initialization."; | 115 LOG(WARNING) << "No cache directory found. Skipping initialization."; |
116 return; | 116 return; |
117 } | 117 } |
118 LOG(INFO) << "Attempting to initialize QuicInMemoryCache from directory: " | 118 LOG(INFO) << "Attempting to initialize QuicInMemoryCache from directory: " |
119 << FLAGS_quic_in_memory_cache_dir; | 119 << FLAGS_quic_in_memory_cache_dir; |
120 | 120 |
121 FilePath directory(FLAGS_quic_in_memory_cache_dir); | 121 FilePath directory(FLAGS_quic_in_memory_cache_dir); |
122 FileEnumerator file_list(directory, | 122 base::FileEnumerator file_list(directory, |
123 true, | 123 true, |
124 FileEnumerator::FILES); | 124 base::FileEnumerator::FILES); |
125 | 125 |
126 FilePath file = file_list.Next(); | 126 FilePath file = file_list.Next(); |
127 while (!file.empty()) { | 127 while (!file.empty()) { |
128 BalsaHeaders request_headers, response_headers; | 128 BalsaHeaders request_headers, response_headers; |
129 | 129 |
130 string file_contents; | 130 string file_contents; |
131 file_util::ReadFileToString(file, &file_contents); | 131 file_util::ReadFileToString(file, &file_contents); |
132 | 132 |
133 // Frame HTTP. | 133 // Frame HTTP. |
134 CachingBalsaVisitor caching_visitor; | 134 CachingBalsaVisitor caching_visitor; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 STLDeleteValues(&responses_); | 194 STLDeleteValues(&responses_); |
195 } | 195 } |
196 | 196 |
197 string QuicInMemoryCache::GetKey(const BalsaHeaders& request_headers) const { | 197 string QuicInMemoryCache::GetKey(const BalsaHeaders& request_headers) const { |
198 return request_headers.GetHeader("host").as_string() + | 198 return request_headers.GetHeader("host").as_string() + |
199 request_headers.request_uri().as_string(); | 199 request_headers.request_uri().as_string(); |
200 } | 200 } |
201 | 201 |
202 } // namespace tools | 202 } // namespace tools |
203 } // namespace net | 203 } // namespace net |
OLD | NEW |