OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/disk_cache/simple/simple_index.h" | 5 #include "net/disk_cache/simple/simple_index.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 DCHECK(it); | 128 DCHECK(it); |
129 int64 tmp_last_used_time; | 129 int64 tmp_last_used_time; |
130 uint64 tmp_entry_size; | 130 uint64 tmp_entry_size; |
131 if (!it->ReadInt64(&tmp_last_used_time) || !it->ReadUInt64(&tmp_entry_size)) | 131 if (!it->ReadInt64(&tmp_last_used_time) || !it->ReadUInt64(&tmp_entry_size)) |
132 return false; | 132 return false; |
133 SetLastUsedTime(base::Time::FromInternalValue(tmp_last_used_time)); | 133 SetLastUsedTime(base::Time::FromInternalValue(tmp_last_used_time)); |
134 entry_size_ = tmp_entry_size; | 134 entry_size_ = tmp_entry_size; |
135 return true; | 135 return true; |
136 } | 136 } |
137 | 137 |
138 SimpleIndex::SimpleIndex( | 138 SimpleIndex::SimpleIndex(base::SingleThreadTaskRunner* io_thread, |
139 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread, | 139 SimpleIndexDelegate* delegate, |
140 SimpleIndexDelegate* delegate, | 140 net::CacheType cache_type, |
141 net::CacheType cache_type, | 141 scoped_ptr<SimpleIndexFile> index_file) |
142 scoped_ptr<SimpleIndexFile> index_file) | |
143 : delegate_(delegate), | 142 : delegate_(delegate), |
144 cache_type_(cache_type), | 143 cache_type_(cache_type), |
145 cache_size_(0), | 144 cache_size_(0), |
146 max_size_(0), | 145 max_size_(0), |
147 high_watermark_(0), | 146 high_watermark_(0), |
148 low_watermark_(0), | 147 low_watermark_(0), |
149 eviction_in_progress_(false), | 148 eviction_in_progress_(false), |
150 initialized_(false), | 149 initialized_(false), |
151 index_file_(index_file.Pass()), | 150 index_file_(index_file.Pass()), |
152 io_thread_(io_thread), | 151 io_thread_(io_thread), |
153 // Creating the callback once so it is reused every time | 152 // Creating the callback once so it is reused every time |
154 // write_to_disk_timer_.Start() is called. | 153 // write_to_disk_timer_.Start() is called. |
155 write_to_disk_cb_(base::Bind(&SimpleIndex::WriteToDisk, AsWeakPtr())), | 154 write_to_disk_cb_(base::Bind(&SimpleIndex::WriteToDisk, AsWeakPtr())), |
156 app_on_background_(false) { | 155 app_on_background_(false) {} |
157 } | |
158 | 156 |
159 SimpleIndex::~SimpleIndex() { | 157 SimpleIndex::~SimpleIndex() { |
160 DCHECK(io_thread_checker_.CalledOnValidThread()); | 158 DCHECK(io_thread_checker_.CalledOnValidThread()); |
161 | 159 |
162 // Fail all callbacks waiting for the index to come up. | 160 // Fail all callbacks waiting for the index to come up. |
163 for (CallbackList::iterator it = to_run_when_initialized_.begin(), | 161 for (CallbackList::iterator it = to_run_when_initialized_.begin(), |
164 end = to_run_when_initialized_.end(); it != end; ++it) { | 162 end = to_run_when_initialized_.end(); it != end; ++it) { |
165 it->Run(net::ERR_ABORTED); | 163 it->Run(net::ERR_ABORTED); |
166 } | 164 } |
167 } | 165 } |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 start - last_write_to_disk_); | 471 start - last_write_to_disk_); |
474 } | 472 } |
475 } | 473 } |
476 last_write_to_disk_ = start; | 474 last_write_to_disk_ = start; |
477 | 475 |
478 index_file_->WriteToDisk(entries_set_, cache_size_, | 476 index_file_->WriteToDisk(entries_set_, cache_size_, |
479 start, app_on_background_); | 477 start, app_on_background_); |
480 } | 478 } |
481 | 479 |
482 } // namespace disk_cache | 480 } // namespace disk_cache |
OLD | NEW |