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), | |
49 buf_len_(0), | 48 buf_len_(0), |
50 index_(0), | 49 index_(0), |
51 data_(NULL), | 50 data_(NULL), |
52 next_state_(STATE_NONE), | 51 next_state_(STATE_NONE), |
53 weak_factory_(this) { | 52 weak_factory_(this) { |
54 } | 53 } |
55 | 54 |
56 ViewCacheHelper::~ViewCacheHelper() { | 55 ViewCacheHelper::~ViewCacheHelper() { |
57 if (entry_) | 56 if (entry_) |
58 entry_->Close(); | 57 entry_->Close(); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 next_state_ = STATE_OPEN_NEXT_ENTRY; | 234 next_state_ = STATE_OPEN_NEXT_ENTRY; |
236 return OK; | 235 return OK; |
237 } | 236 } |
238 | 237 |
239 next_state_ = STATE_OPEN_ENTRY; | 238 next_state_ = STATE_OPEN_ENTRY; |
240 return OK; | 239 return OK; |
241 } | 240 } |
242 | 241 |
243 int ViewCacheHelper::DoOpenNextEntry() { | 242 int ViewCacheHelper::DoOpenNextEntry() { |
244 next_state_ = STATE_OPEN_NEXT_ENTRY_COMPLETE; | 243 next_state_ = STATE_OPEN_NEXT_ENTRY_COMPLETE; |
245 return disk_cache_->OpenNextEntry( | 244 if (!iter_) |
246 &iter_, &entry_, | 245 iter_ = disk_cache_->CreateIterator(); |
247 base::Bind(&ViewCacheHelper::OnIOComplete, base::Unretained(this))); | 246 return |
| 247 iter_->OpenNextEntry(&entry_, base::Bind(&ViewCacheHelper::OnIOComplete, |
| 248 base::Unretained(this))); |
248 } | 249 } |
249 | 250 |
250 int ViewCacheHelper::DoOpenNextEntryComplete(int result) { | 251 int ViewCacheHelper::DoOpenNextEntryComplete(int result) { |
251 if (result == ERR_FAILED) { | 252 if (result == ERR_FAILED) { |
252 data_->append(VIEW_CACHE_TAIL); | 253 data_->append(VIEW_CACHE_TAIL); |
253 return OK; | 254 return OK; |
254 } | 255 } |
255 | 256 |
256 DCHECK_EQ(OK, result); | 257 DCHECK_EQ(OK, result); |
257 data_->append(FormatEntryInfo(entry_, url_prefix_)); | 258 data_->append(FormatEntryInfo(entry_, url_prefix_)); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 entry_ = NULL; | 359 entry_ = NULL; |
359 } | 360 } |
360 return OK; | 361 return OK; |
361 } | 362 } |
362 | 363 |
363 void ViewCacheHelper::OnIOComplete(int result) { | 364 void ViewCacheHelper::OnIOComplete(int result) { |
364 DoLoop(result); | 365 DoLoop(result); |
365 } | 366 } |
366 | 367 |
367 } // namespace net. | 368 } // namespace net. |
OLD | NEW |