Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1225)

Side by Side Diff: net/tools/quic/quic_in_memory_cache.cc

Issue 16392011: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix incorrect includes Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/tools/dump_cache/dump_files.cc ('k') | net/url_request/url_request_file_dir_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 18
19 namespace net { 19 namespace net {
20 namespace tools { 20 namespace tools {
21 21
22 std::string FLAGS_quic_in_memory_cache_dir = "/tmp/quic-data"; 22 std::string FLAGS_quic_in_memory_cache_dir = "/tmp/quic-data";
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 QuicInMemoryCache::QuicInMemoryCache() { 113 QuicInMemoryCache::QuicInMemoryCache() {
114 // If there's no defined cache dir, we have no initialization to do. 114 // If there's no defined cache dir, we have no initialization to do.
115 if (FLAGS_quic_in_memory_cache_dir.empty()) { 115 if (FLAGS_quic_in_memory_cache_dir.empty()) {
116 LOG(WARNING) << "No cache directory found. Skipping initialization."; 116 LOG(WARNING) << "No cache directory found. Skipping initialization.";
117 return; 117 return;
118 } 118 }
119 LOG(INFO) << "Attempting to initialize QuicInMemoryCache from directory: " 119 LOG(INFO) << "Attempting to initialize QuicInMemoryCache from directory: "
120 << FLAGS_quic_in_memory_cache_dir; 120 << FLAGS_quic_in_memory_cache_dir;
121 121
122 FilePath directory(FLAGS_quic_in_memory_cache_dir); 122 FilePath directory(FLAGS_quic_in_memory_cache_dir);
123 FileEnumerator file_list(directory, 123 base::FileEnumerator file_list(directory,
124 true, 124 true,
125 FileEnumerator::FILES); 125 base::FileEnumerator::FILES);
126 126
127 FilePath file = file_list.Next(); 127 FilePath file = file_list.Next();
128 while (!file.empty()) { 128 while (!file.empty()) {
129 BalsaHeaders request_headers, response_headers; 129 BalsaHeaders request_headers, response_headers;
130 130
131 string file_contents; 131 string file_contents;
132 file_util::ReadFileToString(file, &file_contents); 132 file_util::ReadFileToString(file, &file_contents);
133 133
134 // Frame HTTP. 134 // Frame HTTP.
135 CachingBalsaVisitor caching_visitor; 135 CachingBalsaVisitor caching_visitor;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 STLDeleteValues(&responses_); 197 STLDeleteValues(&responses_);
198 } 198 }
199 199
200 string QuicInMemoryCache::GetKey(const BalsaHeaders& request_headers) const { 200 string QuicInMemoryCache::GetKey(const BalsaHeaders& request_headers) const {
201 return request_headers.GetHeader("host").as_string() + 201 return request_headers.GetHeader("host").as_string() +
202 request_headers.request_uri().as_string(); 202 request_headers.request_uri().as_string();
203 } 203 }
204 204
205 } // namespace tools 205 } // namespace tools
206 } // namespace net 206 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/dump_cache/dump_files.cc ('k') | net/url_request/url_request_file_dir_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698