| 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/url_request/view_cache_helper.h" | 5 #include "net/url_request/view_cache_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "net/base/escape.h" | 10 #include "net/base/escape.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 "</a></td></tr>"; | 38 "</a></td></tr>"; |
| 39 return row; | 39 return row; |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace. | 42 } // namespace. |
| 43 | 43 |
| 44 ViewCacheHelper::ViewCacheHelper() | 44 ViewCacheHelper::ViewCacheHelper() |
| 45 : context_(NULL), | 45 : context_(NULL), |
| 46 disk_cache_(NULL), | 46 disk_cache_(NULL), |
| 47 entry_(NULL), | 47 entry_(NULL), |
| 48 iter_(NULL), |
| 48 buf_len_(0), | 49 buf_len_(0), |
| 49 index_(0), | 50 index_(0), |
| 50 data_(NULL), | 51 data_(NULL), |
| 51 next_state_(STATE_NONE), | 52 next_state_(STATE_NONE), |
| 52 weak_factory_(this) { | 53 weak_factory_(this) { |
| 53 } | 54 } |
| 54 | 55 |
| 55 ViewCacheHelper::~ViewCacheHelper() { | 56 ViewCacheHelper::~ViewCacheHelper() { |
| 56 if (entry_) | 57 if (entry_) |
| 57 entry_->Close(); | 58 entry_->Close(); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 next_state_ = STATE_OPEN_NEXT_ENTRY; | 235 next_state_ = STATE_OPEN_NEXT_ENTRY; |
| 235 return OK; | 236 return OK; |
| 236 } | 237 } |
| 237 | 238 |
| 238 next_state_ = STATE_OPEN_ENTRY; | 239 next_state_ = STATE_OPEN_ENTRY; |
| 239 return OK; | 240 return OK; |
| 240 } | 241 } |
| 241 | 242 |
| 242 int ViewCacheHelper::DoOpenNextEntry() { | 243 int ViewCacheHelper::DoOpenNextEntry() { |
| 243 next_state_ = STATE_OPEN_NEXT_ENTRY_COMPLETE; | 244 next_state_ = STATE_OPEN_NEXT_ENTRY_COMPLETE; |
| 244 if (!iter_) | 245 return disk_cache_->OpenNextEntry( |
| 245 iter_ = disk_cache_->CreateIterator(); | 246 &iter_, &entry_, |
| 246 return | 247 base::Bind(&ViewCacheHelper::OnIOComplete, base::Unretained(this))); |
| 247 iter_->OpenNextEntry(&entry_, base::Bind(&ViewCacheHelper::OnIOComplete, | |
| 248 base::Unretained(this))); | |
| 249 } | 248 } |
| 250 | 249 |
| 251 int ViewCacheHelper::DoOpenNextEntryComplete(int result) { | 250 int ViewCacheHelper::DoOpenNextEntryComplete(int result) { |
| 252 if (result == ERR_FAILED) { | 251 if (result == ERR_FAILED) { |
| 253 data_->append(VIEW_CACHE_TAIL); | 252 data_->append(VIEW_CACHE_TAIL); |
| 254 return OK; | 253 return OK; |
| 255 } | 254 } |
| 256 | 255 |
| 257 DCHECK_EQ(OK, result); | 256 DCHECK_EQ(OK, result); |
| 258 data_->append(FormatEntryInfo(entry_, url_prefix_)); | 257 data_->append(FormatEntryInfo(entry_, url_prefix_)); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 entry_ = NULL; | 358 entry_ = NULL; |
| 360 } | 359 } |
| 361 return OK; | 360 return OK; |
| 362 } | 361 } |
| 363 | 362 |
| 364 void ViewCacheHelper::OnIOComplete(int result) { | 363 void ViewCacheHelper::OnIOComplete(int result) { |
| 365 DoLoop(result); | 364 DoLoop(result); |
| 366 } | 365 } |
| 367 | 366 |
| 368 } // namespace net. | 367 } // namespace net. |
| OLD | NEW |