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_entry_impl.h" | 5 #include "net/disk_cache/simple/simple_entry_impl.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/callback.h" | 9 #include "base/callback.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 SimpleSynchronousEntry* sync_entry, | 263 SimpleSynchronousEntry* sync_entry, |
264 int result) { | 264 int result) { |
265 if (entry) { | 265 if (entry) { |
266 DCHECK(entry->synchronous_entry_in_use_by_worker_); | 266 DCHECK(entry->synchronous_entry_in_use_by_worker_); |
267 entry->synchronous_entry_in_use_by_worker_ = false; | 267 entry->synchronous_entry_in_use_by_worker_ = false; |
268 entry->SetSynchronousData(); | 268 entry->SetSynchronousData(); |
269 } else { | 269 } else { |
270 // |entry| must have had Close() called while this operation was in flight. | 270 // |entry| must have had Close() called while this operation was in flight. |
271 // Since the simple cache now only supports one pending entry operation in | 271 // Since the simple cache now only supports one pending entry operation in |
272 // flight at a time, it's safe to now call Close() on |sync_entry|. | 272 // flight at a time, it's safe to now call Close() on |sync_entry|. |
273 | |
274 // TODO(felipeg): In this case, how do update the entry size in the total | |
275 // cache size ? | |
gavinp
2013/04/09 15:27:37
sync_entry->data_size(i) still works at this point
felipeg
2013/04/09 16:24:35
Done.
| |
276 | |
273 WorkerPool::PostTask(FROM_HERE, | 277 WorkerPool::PostTask(FROM_HERE, |
274 base::Bind(&SimpleSynchronousEntry::Close, | 278 base::Bind(&SimpleSynchronousEntry::Close, |
275 base::Unretained(sync_entry)), | 279 base::Unretained(sync_entry)), |
276 true); | 280 true); |
277 } | 281 } |
278 completion_callback.Run(result); | 282 completion_callback.Run(result); |
279 } | 283 } |
280 | 284 |
281 void SimpleEntryImpl::SetSynchronousData() { | 285 void SimpleEntryImpl::SetSynchronousData() { |
282 DCHECK(!synchronous_entry_in_use_by_worker_); | 286 DCHECK(!synchronous_entry_in_use_by_worker_); |
283 // TODO(felipeg): These copies to avoid data races are not optimal. While | 287 // TODO(felipeg): These copies to avoid data races are not optimal. While |
284 // adding an IO thread index (for fast misses etc...), we can store this data | 288 // adding an IO thread index (for fast misses etc...), we can store this data |
285 // in that structure. This also solves problems with last_used() on ext4 | 289 // in that structure. This also solves problems with last_used() on ext4 |
286 // filesystems not being accurate. | 290 // filesystems not being accurate. |
287 last_used_ = synchronous_entry_->last_used(); | 291 last_used_ = synchronous_entry_->last_used(); |
288 last_modified_ = synchronous_entry_->last_modified(); | 292 last_modified_ = synchronous_entry_->last_modified(); |
289 for (int i = 0; i < kSimpleEntryFileCount; ++i) | 293 uint64 total_entry_size = 0; |
294 for (int i = 0; i < kSimpleEntryFileCount; ++i) { | |
290 data_size_[i] = synchronous_entry_->data_size(i); | 295 data_size_[i] = synchronous_entry_->data_size(i); |
296 total_entry_size += data_size_[i]; | |
gavinp
2013/04/09 15:40:19
Maybe add SimpleSynchronousEntry::GetFileSize()?
felipeg
2013/04/09 16:24:35
Done.
| |
297 } | |
298 index_->UpdateEntrySize(key_, total_entry_size); | |
291 } | 299 } |
292 | 300 |
293 } // namespace disk_cache | 301 } // namespace disk_cache |
OLD | NEW |