| 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/disk_cache/blockfile/in_flight_backend_io.h" | 5 #include "net/disk_cache/blockfile/in_flight_backend_io.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 9 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 12 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 13 #include "net/disk_cache/blockfile/backend_impl.h" | 15 #include "net/disk_cache/blockfile/backend_impl.h" |
| 14 #include "net/disk_cache/blockfile/entry_impl.h" | 16 #include "net/disk_cache/blockfile/entry_impl.h" |
| 15 #include "net/disk_cache/blockfile/histogram_macros.h" | 17 #include "net/disk_cache/blockfile/histogram_macros.h" |
| 16 | 18 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 123 |
| 122 void BackendIO::OpenNextEntry(Rankings::Iterator* iterator, | 124 void BackendIO::OpenNextEntry(Rankings::Iterator* iterator, |
| 123 Entry** next_entry) { | 125 Entry** next_entry) { |
| 124 operation_ = OP_OPEN_NEXT; | 126 operation_ = OP_OPEN_NEXT; |
| 125 iterator_ = iterator; | 127 iterator_ = iterator; |
| 126 entry_ptr_ = next_entry; | 128 entry_ptr_ = next_entry; |
| 127 } | 129 } |
| 128 | 130 |
| 129 void BackendIO::EndEnumeration(scoped_ptr<Rankings::Iterator> iterator) { | 131 void BackendIO::EndEnumeration(scoped_ptr<Rankings::Iterator> iterator) { |
| 130 operation_ = OP_END_ENUMERATION; | 132 operation_ = OP_END_ENUMERATION; |
| 131 scoped_iterator_ = iterator.Pass(); | 133 scoped_iterator_ = std::move(iterator); |
| 132 } | 134 } |
| 133 | 135 |
| 134 void BackendIO::OnExternalCacheHit(const std::string& key) { | 136 void BackendIO::OnExternalCacheHit(const std::string& key) { |
| 135 operation_ = OP_ON_EXTERNAL_CACHE_HIT; | 137 operation_ = OP_ON_EXTERNAL_CACHE_HIT; |
| 136 key_ = key; | 138 key_ = key; |
| 137 } | 139 } |
| 138 | 140 |
| 139 void BackendIO::CloseEntryImpl(EntryImpl* entry) { | 141 void BackendIO::CloseEntryImpl(EntryImpl* entry) { |
| 140 operation_ = OP_CLOSE_ENTRY; | 142 operation_ = OP_CLOSE_ENTRY; |
| 141 entry_ = entry; | 143 entry_ = entry; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 case OP_DOOM_SINCE: | 256 case OP_DOOM_SINCE: |
| 255 result_ = backend_->SyncDoomEntriesSince(initial_time_); | 257 result_ = backend_->SyncDoomEntriesSince(initial_time_); |
| 256 break; | 258 break; |
| 257 case OP_SIZE_ALL: | 259 case OP_SIZE_ALL: |
| 258 result_ = backend_->SyncCalculateSizeOfAllEntries(); | 260 result_ = backend_->SyncCalculateSizeOfAllEntries(); |
| 259 break; | 261 break; |
| 260 case OP_OPEN_NEXT: | 262 case OP_OPEN_NEXT: |
| 261 result_ = backend_->SyncOpenNextEntry(iterator_, entry_ptr_); | 263 result_ = backend_->SyncOpenNextEntry(iterator_, entry_ptr_); |
| 262 break; | 264 break; |
| 263 case OP_END_ENUMERATION: | 265 case OP_END_ENUMERATION: |
| 264 backend_->SyncEndEnumeration(scoped_iterator_.Pass()); | 266 backend_->SyncEndEnumeration(std::move(scoped_iterator_)); |
| 265 result_ = net::OK; | 267 result_ = net::OK; |
| 266 break; | 268 break; |
| 267 case OP_ON_EXTERNAL_CACHE_HIT: | 269 case OP_ON_EXTERNAL_CACHE_HIT: |
| 268 backend_->SyncOnExternalCacheHit(key_); | 270 backend_->SyncOnExternalCacheHit(key_); |
| 269 result_ = net::OK; | 271 result_ = net::OK; |
| 270 break; | 272 break; |
| 271 case OP_CLOSE_ENTRY: | 273 case OP_CLOSE_ENTRY: |
| 272 entry_->Release(); | 274 entry_->Release(); |
| 273 result_ = net::OK; | 275 result_ = net::OK; |
| 274 break; | 276 break; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 const net::CompletionCallback& callback) { | 409 const net::CompletionCallback& callback) { |
| 408 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 410 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); |
| 409 operation->OpenNextEntry(iterator, next_entry); | 411 operation->OpenNextEntry(iterator, next_entry); |
| 410 PostOperation(operation.get()); | 412 PostOperation(operation.get()); |
| 411 } | 413 } |
| 412 | 414 |
| 413 void InFlightBackendIO::EndEnumeration( | 415 void InFlightBackendIO::EndEnumeration( |
| 414 scoped_ptr<Rankings::Iterator> iterator) { | 416 scoped_ptr<Rankings::Iterator> iterator) { |
| 415 scoped_refptr<BackendIO> operation( | 417 scoped_refptr<BackendIO> operation( |
| 416 new BackendIO(this, backend_, net::CompletionCallback())); | 418 new BackendIO(this, backend_, net::CompletionCallback())); |
| 417 operation->EndEnumeration(iterator.Pass()); | 419 operation->EndEnumeration(std::move(iterator)); |
| 418 PostOperation(operation.get()); | 420 PostOperation(operation.get()); |
| 419 } | 421 } |
| 420 | 422 |
| 421 void InFlightBackendIO::OnExternalCacheHit(const std::string& key) { | 423 void InFlightBackendIO::OnExternalCacheHit(const std::string& key) { |
| 422 scoped_refptr<BackendIO> operation( | 424 scoped_refptr<BackendIO> operation( |
| 423 new BackendIO(this, backend_, net::CompletionCallback())); | 425 new BackendIO(this, backend_, net::CompletionCallback())); |
| 424 operation->OnExternalCacheHit(key); | 426 operation->OnExternalCacheHit(key); |
| 425 PostOperation(operation.get()); | 427 PostOperation(operation.get()); |
| 426 } | 428 } |
| 427 | 429 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 background_thread_->PostTask( | 535 background_thread_->PostTask( |
| 534 FROM_HERE, base::Bind(&BackendIO::ExecuteOperation, operation)); | 536 FROM_HERE, base::Bind(&BackendIO::ExecuteOperation, operation)); |
| 535 OnOperationPosted(operation); | 537 OnOperationPosted(operation); |
| 536 } | 538 } |
| 537 | 539 |
| 538 base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() { | 540 base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() { |
| 539 return ptr_factory_.GetWeakPtr(); | 541 return ptr_factory_.GetWeakPtr(); |
| 540 } | 542 } |
| 541 | 543 |
| 542 } // namespace | 544 } // namespace |
| OLD | NEW |