| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 operation_ = OP_DOOM_BETWEEN; | 108 operation_ = OP_DOOM_BETWEEN; |
| 109 initial_time_ = initial_time; | 109 initial_time_ = initial_time; |
| 110 end_time_ = end_time; | 110 end_time_ = end_time; |
| 111 } | 111 } |
| 112 | 112 |
| 113 void BackendIO::DoomEntriesSince(const base::Time initial_time) { | 113 void BackendIO::DoomEntriesSince(const base::Time initial_time) { |
| 114 operation_ = OP_DOOM_SINCE; | 114 operation_ = OP_DOOM_SINCE; |
| 115 initial_time_ = initial_time; | 115 initial_time_ = initial_time; |
| 116 } | 116 } |
| 117 | 117 |
| 118 void BackendIO::CalculateSizeOfEntriesBetween(const base::Time initial_time, |
| 119 const base::Time end_time) { |
| 120 operation_ = OP_SIZE_BETWEEN; |
| 121 initial_time_ = initial_time; |
| 122 end_time_ = end_time; |
| 123 } |
| 124 |
| 118 void BackendIO::OpenNextEntry(Rankings::Iterator* iterator, | 125 void BackendIO::OpenNextEntry(Rankings::Iterator* iterator, |
| 119 Entry** next_entry) { | 126 Entry** next_entry) { |
| 120 operation_ = OP_OPEN_NEXT; | 127 operation_ = OP_OPEN_NEXT; |
| 121 iterator_ = iterator; | 128 iterator_ = iterator; |
| 122 entry_ptr_ = next_entry; | 129 entry_ptr_ = next_entry; |
| 123 } | 130 } |
| 124 | 131 |
| 125 void BackendIO::EndEnumeration(scoped_ptr<Rankings::Iterator> iterator) { | 132 void BackendIO::EndEnumeration(scoped_ptr<Rankings::Iterator> iterator) { |
| 126 operation_ = OP_END_ENUMERATION; | 133 operation_ = OP_END_ENUMERATION; |
| 127 scoped_iterator_ = iterator.Pass(); | 134 scoped_iterator_ = iterator.Pass(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 break; | 244 break; |
| 238 case OP_DOOM_ALL: | 245 case OP_DOOM_ALL: |
| 239 result_ = backend_->SyncDoomAllEntries(); | 246 result_ = backend_->SyncDoomAllEntries(); |
| 240 break; | 247 break; |
| 241 case OP_DOOM_BETWEEN: | 248 case OP_DOOM_BETWEEN: |
| 242 result_ = backend_->SyncDoomEntriesBetween(initial_time_, end_time_); | 249 result_ = backend_->SyncDoomEntriesBetween(initial_time_, end_time_); |
| 243 break; | 250 break; |
| 244 case OP_DOOM_SINCE: | 251 case OP_DOOM_SINCE: |
| 245 result_ = backend_->SyncDoomEntriesSince(initial_time_); | 252 result_ = backend_->SyncDoomEntriesSince(initial_time_); |
| 246 break; | 253 break; |
| 254 case OP_SIZE_BETWEEN: |
| 255 result_ = backend_->SyncCalculateSizeOfEntriesBetween( |
| 256 initial_time_, end_time_); |
| 257 break; |
| 247 case OP_OPEN_NEXT: | 258 case OP_OPEN_NEXT: |
| 248 result_ = backend_->SyncOpenNextEntry(iterator_, entry_ptr_); | 259 result_ = backend_->SyncOpenNextEntry(iterator_, entry_ptr_); |
| 249 break; | 260 break; |
| 250 case OP_END_ENUMERATION: | 261 case OP_END_ENUMERATION: |
| 251 backend_->SyncEndEnumeration(scoped_iterator_.Pass()); | 262 backend_->SyncEndEnumeration(scoped_iterator_.Pass()); |
| 252 result_ = net::OK; | 263 result_ = net::OK; |
| 253 break; | 264 break; |
| 254 case OP_ON_EXTERNAL_CACHE_HIT: | 265 case OP_ON_EXTERNAL_CACHE_HIT: |
| 255 backend_->SyncOnExternalCacheHit(key_); | 266 backend_->SyncOnExternalCacheHit(key_); |
| 256 result_ = net::OK; | 267 result_ = net::OK; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 PostOperation(operation.get()); | 386 PostOperation(operation.get()); |
| 376 } | 387 } |
| 377 | 388 |
| 378 void InFlightBackendIO::DoomEntriesSince( | 389 void InFlightBackendIO::DoomEntriesSince( |
| 379 const base::Time initial_time, const net::CompletionCallback& callback) { | 390 const base::Time initial_time, const net::CompletionCallback& callback) { |
| 380 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 391 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); |
| 381 operation->DoomEntriesSince(initial_time); | 392 operation->DoomEntriesSince(initial_time); |
| 382 PostOperation(operation.get()); | 393 PostOperation(operation.get()); |
| 383 } | 394 } |
| 384 | 395 |
| 396 void InFlightBackendIO::CalculateSizeOfEntriesBetween( |
| 397 const base::Time initial_time, |
| 398 const base::Time end_time, |
| 399 const net::CompletionCallback& callback) { |
| 400 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); |
| 401 operation->CalculateSizeOfEntriesBetween(initial_time, end_time); |
| 402 PostOperation(operation.get()); |
| 403 } |
| 404 |
| 385 void InFlightBackendIO::OpenNextEntry(Rankings::Iterator* iterator, | 405 void InFlightBackendIO::OpenNextEntry(Rankings::Iterator* iterator, |
| 386 Entry** next_entry, | 406 Entry** next_entry, |
| 387 const net::CompletionCallback& callback) { | 407 const net::CompletionCallback& callback) { |
| 388 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); | 408 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); |
| 389 operation->OpenNextEntry(iterator, next_entry); | 409 operation->OpenNextEntry(iterator, next_entry); |
| 390 PostOperation(operation.get()); | 410 PostOperation(operation.get()); |
| 391 } | 411 } |
| 392 | 412 |
| 393 void InFlightBackendIO::EndEnumeration( | 413 void InFlightBackendIO::EndEnumeration( |
| 394 scoped_ptr<Rankings::Iterator> iterator) { | 414 scoped_ptr<Rankings::Iterator> iterator) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 background_thread_->PostTask( | 524 background_thread_->PostTask( |
| 505 FROM_HERE, base::Bind(&BackendIO::ExecuteOperation, operation)); | 525 FROM_HERE, base::Bind(&BackendIO::ExecuteOperation, operation)); |
| 506 OnOperationPosted(operation); | 526 OnOperationPosted(operation); |
| 507 } | 527 } |
| 508 | 528 |
| 509 base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() { | 529 base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() { |
| 510 return ptr_factory_.GetWeakPtr(); | 530 return ptr_factory_.GetWeakPtr(); |
| 511 } | 531 } |
| 512 | 532 |
| 513 } // namespace | 533 } // namespace |
| OLD | NEW |