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

Side by Side Diff: net/url_request/view_cache_helper.cc

Issue 378015: Clear disk cache when the cache is not initialized (Closed)
Patch Set: simple test Created 11 years, 1 month 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
« no previous file with comments | « net/http/http_cache_unittest.cc ('k') | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/string_util.h" 7 #include "base/string_util.h"
8 #include "net/base/escape.h" 8 #include "net/base/escape.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/disk_cache/disk_cache.h" 10 #include "net/disk_cache/disk_cache.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 if (!context) 109 if (!context)
110 return NULL; 110 return NULL;
111 111
112 if (!context->http_transaction_factory()) 112 if (!context->http_transaction_factory())
113 return NULL; 113 return NULL;
114 114
115 net::HttpCache* http_cache = context->http_transaction_factory()->GetCache(); 115 net::HttpCache* http_cache = context->http_transaction_factory()->GetCache();
116 if (!http_cache) 116 if (!http_cache)
117 return NULL; 117 return NULL;
118 118
119 return http_cache->disk_cache(); 119 return http_cache->GetBackend();
120 } 120 }
121 121
122 static std::string FormatStatistics(disk_cache::Backend* disk_cache) { 122 static std::string FormatStatistics(disk_cache::Backend* disk_cache) {
123 std::vector<std::pair<std::string, std::string> > stats; 123 std::vector<std::pair<std::string, std::string> > stats;
124 disk_cache->GetStats(&stats); 124 disk_cache->GetStats(&stats);
125 std::string result; 125 std::string result;
126 126
127 for (size_t index = 0; index < stats.size(); index++) { 127 for (size_t index = 0; index < stats.size(); index++) {
128 result.append(stats[index].first); 128 result.append(stats[index].first);
129 result.append(": "); 129 result.append(": ");
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // static 168 // static
169 void ViewCacheHelper::GetStatisticsHTML(URLRequestContext* context, 169 void ViewCacheHelper::GetStatisticsHTML(URLRequestContext* context,
170 std::string* data) { 170 std::string* data) {
171 disk_cache::Backend* disk_cache = GetDiskCache(context); 171 disk_cache::Backend* disk_cache = GetDiskCache(context);
172 if (!disk_cache) { 172 if (!disk_cache) {
173 data->append("no disk cache"); 173 data->append("no disk cache");
174 return; 174 return;
175 } 175 }
176 data->append(FormatStatistics(disk_cache)); 176 data->append(FormatStatistics(disk_cache));
177 } 177 }
OLDNEW
« no previous file with comments | « net/http/http_cache_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698