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

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

Issue 8794003: base::Bind: Convert disk_cache_based_ssl_host_info. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove an OldCompletionCallback. Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 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/bind.h"
8 #include "base/bind_helpers.h"
7 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
8 #include "net/base/escape.h" 10 #include "net/base/escape.h"
9 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
11 #include "net/disk_cache/disk_cache.h" 13 #include "net/disk_cache/disk_cache.h"
12 #include "net/http/http_cache.h" 14 #include "net/http/http_cache.h"
13 #include "net/http/http_response_headers.h" 15 #include "net/http/http_response_headers.h"
14 #include "net/http/http_response_info.h" 16 #include "net/http/http_response_info.h"
15 #include "net/url_request/url_request_context.h" 17 #include "net/url_request/url_request_context.h"
16 18
(...skipping 22 matching lines...) Expand all
39 } // namespace. 41 } // namespace.
40 42
41 ViewCacheHelper::ViewCacheHelper() 43 ViewCacheHelper::ViewCacheHelper()
42 : disk_cache_(NULL), 44 : disk_cache_(NULL),
43 entry_(NULL), 45 entry_(NULL),
44 iter_(NULL), 46 iter_(NULL),
45 buf_len_(0), 47 buf_len_(0),
46 index_(0), 48 index_(0),
47 data_(NULL), 49 data_(NULL),
48 next_state_(STATE_NONE), 50 next_state_(STATE_NONE),
51 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_(
52 base::Bind(&ViewCacheHelper::OnIOComplete, base::Unretained(this)))),
49 ALLOW_THIS_IN_INITIALIZER_LIST( 53 ALLOW_THIS_IN_INITIALIZER_LIST(
50 cache_callback_(this, &ViewCacheHelper::OnIOComplete)), 54 old_cache_callback_(this, &ViewCacheHelper::OnIOComplete)),
51 ALLOW_THIS_IN_INITIALIZER_LIST( 55 ALLOW_THIS_IN_INITIALIZER_LIST(
52 entry_callback_(new CancelableOldCompletionCallback<ViewCacheHelper>( 56 entry_callback_(new CancelableOldCompletionCallback<ViewCacheHelper>(
53 this, &ViewCacheHelper::OnIOComplete))) { 57 this, &ViewCacheHelper::OnIOComplete))) {
54 } 58 }
55 59
56 ViewCacheHelper::~ViewCacheHelper() { 60 ViewCacheHelper::~ViewCacheHelper() {
57 if (entry_) 61 if (entry_)
58 entry_->Close(); 62 entry_->Close();
59 63
60 // Cancel any pending entry callback. 64 // Cancel any pending entry callback.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 int ViewCacheHelper::DoGetBackend() { 216 int ViewCacheHelper::DoGetBackend() {
213 next_state_ = STATE_GET_BACKEND_COMPLETE; 217 next_state_ = STATE_GET_BACKEND_COMPLETE;
214 218
215 if (!context_->http_transaction_factory()) 219 if (!context_->http_transaction_factory())
216 return ERR_FAILED; 220 return ERR_FAILED;
217 221
218 HttpCache* http_cache = context_->http_transaction_factory()->GetCache(); 222 HttpCache* http_cache = context_->http_transaction_factory()->GetCache();
219 if (!http_cache) 223 if (!http_cache)
220 return ERR_FAILED; 224 return ERR_FAILED;
221 225
222 return http_cache->GetBackend(&disk_cache_, &cache_callback_); 226 return http_cache->GetBackend(&disk_cache_, cache_callback_);
223 } 227 }
224 228
225 int ViewCacheHelper::DoGetBackendComplete(int result) { 229 int ViewCacheHelper::DoGetBackendComplete(int result) {
226 if (result == ERR_FAILED) { 230 if (result == ERR_FAILED) {
227 data_->append("no disk cache"); 231 data_->append("no disk cache");
228 return OK; 232 return OK;
229 } 233 }
230 234
231 DCHECK_EQ(OK, result); 235 DCHECK_EQ(OK, result);
232 if (key_.empty()) { 236 if (key_.empty()) {
233 data_->assign(VIEW_CACHE_HEAD); 237 data_->assign(VIEW_CACHE_HEAD);
234 DCHECK(!iter_); 238 DCHECK(!iter_);
235 next_state_ = STATE_OPEN_NEXT_ENTRY; 239 next_state_ = STATE_OPEN_NEXT_ENTRY;
236 return OK; 240 return OK;
237 } 241 }
238 242
239 next_state_ = STATE_OPEN_ENTRY; 243 next_state_ = STATE_OPEN_ENTRY;
240 return OK; 244 return OK;
241 } 245 }
242 246
243 int ViewCacheHelper::DoOpenNextEntry() { 247 int ViewCacheHelper::DoOpenNextEntry() {
244 next_state_ = STATE_OPEN_NEXT_ENTRY_COMPLETE; 248 next_state_ = STATE_OPEN_NEXT_ENTRY_COMPLETE;
245 return disk_cache_->OpenNextEntry(&iter_, &entry_, &cache_callback_); 249 return disk_cache_->OpenNextEntry(&iter_, &entry_, &old_cache_callback_);
246 } 250 }
247 251
248 int ViewCacheHelper::DoOpenNextEntryComplete(int result) { 252 int ViewCacheHelper::DoOpenNextEntryComplete(int result) {
249 if (result == ERR_FAILED) { 253 if (result == ERR_FAILED) {
250 data_->append(VIEW_CACHE_TAIL); 254 data_->append(VIEW_CACHE_TAIL);
251 return OK; 255 return OK;
252 } 256 }
253 257
254 DCHECK_EQ(OK, result); 258 DCHECK_EQ(OK, result);
255 data_->append(FormatEntryInfo(entry_, url_prefix_)); 259 data_->append(FormatEntryInfo(entry_, url_prefix_));
256 entry_->Close(); 260 entry_->Close();
257 entry_ = NULL; 261 entry_ = NULL;
258 262
259 next_state_ = STATE_OPEN_NEXT_ENTRY; 263 next_state_ = STATE_OPEN_NEXT_ENTRY;
260 return OK; 264 return OK;
261 } 265 }
262 266
263 int ViewCacheHelper::DoOpenEntry() { 267 int ViewCacheHelper::DoOpenEntry() {
264 next_state_ = STATE_OPEN_ENTRY_COMPLETE; 268 next_state_ = STATE_OPEN_ENTRY_COMPLETE;
265 return disk_cache_->OpenEntry(key_, &entry_, &cache_callback_); 269 return disk_cache_->OpenEntry(key_, &entry_, &old_cache_callback_);
266 } 270 }
267 271
268 int ViewCacheHelper::DoOpenEntryComplete(int result) { 272 int ViewCacheHelper::DoOpenEntryComplete(int result) {
269 if (result == ERR_FAILED) { 273 if (result == ERR_FAILED) {
270 data_->append("no matching cache entry for: " + EscapeForHTML(key_)); 274 data_->append("no matching cache entry for: " + EscapeForHTML(key_));
271 return OK; 275 return OK;
272 } 276 }
273 277
274 data_->assign(VIEW_CACHE_HEAD); 278 data_->assign(VIEW_CACHE_HEAD);
275 data_->append(EscapeForHTML(entry_->GetKey())); 279 data_->append(EscapeForHTML(entry_->GetKey()));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 entry_ = NULL; 352 entry_ = NULL;
349 } 353 }
350 return OK; 354 return OK;
351 } 355 }
352 356
353 void ViewCacheHelper::OnIOComplete(int result) { 357 void ViewCacheHelper::OnIOComplete(int result) {
354 DoLoop(result); 358 DoLoop(result);
355 } 359 }
356 360
357 } // namespace net. 361 } // namespace net.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698