| 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_backend_impl.h" | 5 #include "net/disk_cache/simple/simple_backend_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstdlib> | 8 #include <cstdlib> |
| 9 #include <functional> | 9 #include <functional> |
| 10 | 10 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 SIMPLE_CACHE_UMA(TIMES, | 191 SIMPLE_CACHE_UMA(TIMES, |
| 192 "CreationToIndexFail", cache_type, creation_to_index); | 192 "CreationToIndexFail", cache_type, creation_to_index); |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 | 195 |
| 196 } // namespace | 196 } // namespace |
| 197 | 197 |
| 198 class SimpleBackendImpl::ActiveEntryProxy | 198 class SimpleBackendImpl::ActiveEntryProxy |
| 199 : public SimpleEntryImpl::ActiveEntryProxy { | 199 : public SimpleEntryImpl::ActiveEntryProxy { |
| 200 public: | 200 public: |
| 201 virtual ~ActiveEntryProxy() { | 201 ~ActiveEntryProxy() override { |
| 202 if (backend_) { | 202 if (backend_) { |
| 203 DCHECK_EQ(1U, backend_->active_entries_.count(entry_hash_)); | 203 DCHECK_EQ(1U, backend_->active_entries_.count(entry_hash_)); |
| 204 backend_->active_entries_.erase(entry_hash_); | 204 backend_->active_entries_.erase(entry_hash_); |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 | 207 |
| 208 static scoped_ptr<SimpleEntryImpl::ActiveEntryProxy> Create( | 208 static scoped_ptr<SimpleEntryImpl::ActiveEntryProxy> Create( |
| 209 int64 entry_hash, | 209 int64 entry_hash, |
| 210 SimpleBackendImpl* backend) { | 210 SimpleBackendImpl* backend) { |
| 211 scoped_ptr<SimpleEntryImpl::ActiveEntryProxy> | 211 scoped_ptr<SimpleEntryImpl::ActiveEntryProxy> |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 } | 468 } |
| 469 | 469 |
| 470 class SimpleBackendImpl::SimpleIterator final : public Iterator { | 470 class SimpleBackendImpl::SimpleIterator final : public Iterator { |
| 471 public: | 471 public: |
| 472 explicit SimpleIterator(base::WeakPtr<SimpleBackendImpl> backend) | 472 explicit SimpleIterator(base::WeakPtr<SimpleBackendImpl> backend) |
| 473 : backend_(backend), | 473 : backend_(backend), |
| 474 weak_factory_(this) { | 474 weak_factory_(this) { |
| 475 } | 475 } |
| 476 | 476 |
| 477 // From Backend::Iterator: | 477 // From Backend::Iterator: |
| 478 virtual int OpenNextEntry(Entry** next_entry, | 478 int OpenNextEntry(Entry** next_entry, |
| 479 const CompletionCallback& callback) override { | 479 const CompletionCallback& callback) override { |
| 480 CompletionCallback open_next_entry_impl = | 480 CompletionCallback open_next_entry_impl = |
| 481 base::Bind(&SimpleIterator::OpenNextEntryImpl, | 481 base::Bind(&SimpleIterator::OpenNextEntryImpl, |
| 482 weak_factory_.GetWeakPtr(), next_entry, callback); | 482 weak_factory_.GetWeakPtr(), next_entry, callback); |
| 483 return backend_->index_->ExecuteWhenReady(open_next_entry_impl); | 483 return backend_->index_->ExecuteWhenReady(open_next_entry_impl); |
| 484 } | 484 } |
| 485 | 485 |
| 486 void OpenNextEntryImpl(Entry** next_entry, | 486 void OpenNextEntryImpl(Entry** next_entry, |
| 487 const CompletionCallback& callback, | 487 const CompletionCallback& callback, |
| 488 int index_initialization_error_code) { | 488 int index_initialization_error_code) { |
| 489 if (!backend_) { | 489 if (!backend_) { |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 this)); | 729 this)); |
| 730 callback.Run(result); | 730 callback.Run(result); |
| 731 } | 731 } |
| 732 | 732 |
| 733 void SimpleBackendImpl::FlushWorkerPoolForTesting() { | 733 void SimpleBackendImpl::FlushWorkerPoolForTesting() { |
| 734 if (g_sequenced_worker_pool) | 734 if (g_sequenced_worker_pool) |
| 735 g_sequenced_worker_pool->FlushForTesting(); | 735 g_sequenced_worker_pool->FlushForTesting(); |
| 736 } | 736 } |
| 737 | 737 |
| 738 } // namespace disk_cache | 738 } // namespace disk_cache |
| OLD | NEW |