| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/in_flight_backend_io.h" | 5 #include "net/disk_cache/in_flight_backend_io.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/disk_cache/backend_impl.h" | 10 #include "net/disk_cache/backend_impl.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 operation_ = OP_OPEN_PREV; | 98 operation_ = OP_OPEN_PREV; |
| 99 iter_ptr_ = iter; | 99 iter_ptr_ = iter; |
| 100 entry_ptr_ = prev_entry; | 100 entry_ptr_ = prev_entry; |
| 101 } | 101 } |
| 102 | 102 |
| 103 void BackendIO::EndEnumeration(void* iterator) { | 103 void BackendIO::EndEnumeration(void* iterator) { |
| 104 operation_ = OP_END_ENUMERATION; | 104 operation_ = OP_END_ENUMERATION; |
| 105 iter_ = iterator; | 105 iter_ = iterator; |
| 106 } | 106 } |
| 107 | 107 |
| 108 void BackendIO::OnExternalCacheHit(const std::string& key) { |
| 109 operation_ = OP_ON_EXTERNAL_CACHE_HIT; |
| 110 key_ = key; |
| 111 } |
| 112 |
| 108 void BackendIO::CloseEntryImpl(EntryImpl* entry) { | 113 void BackendIO::CloseEntryImpl(EntryImpl* entry) { |
| 109 operation_ = OP_CLOSE_ENTRY; | 114 operation_ = OP_CLOSE_ENTRY; |
| 110 entry_ = entry; | 115 entry_ = entry; |
| 111 } | 116 } |
| 112 | 117 |
| 113 void BackendIO::DoomEntryImpl(EntryImpl* entry) { | 118 void BackendIO::DoomEntryImpl(EntryImpl* entry) { |
| 114 operation_ = OP_DOOM_ENTRY; | 119 operation_ = OP_DOOM_ENTRY; |
| 115 entry_ = entry; | 120 entry_ = entry; |
| 116 } | 121 } |
| 117 | 122 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 case OP_OPEN_NEXT: | 216 case OP_OPEN_NEXT: |
| 212 result_ = backend_->SyncOpenNextEntry(iter_ptr_, entry_ptr_); | 217 result_ = backend_->SyncOpenNextEntry(iter_ptr_, entry_ptr_); |
| 213 break; | 218 break; |
| 214 case OP_OPEN_PREV: | 219 case OP_OPEN_PREV: |
| 215 result_ = backend_->SyncOpenPrevEntry(iter_ptr_, entry_ptr_); | 220 result_ = backend_->SyncOpenPrevEntry(iter_ptr_, entry_ptr_); |
| 216 break; | 221 break; |
| 217 case OP_END_ENUMERATION: | 222 case OP_END_ENUMERATION: |
| 218 backend_->SyncEndEnumeration(iter_); | 223 backend_->SyncEndEnumeration(iter_); |
| 219 result_ = net::OK; | 224 result_ = net::OK; |
| 220 break; | 225 break; |
| 226 case OP_ON_EXTERNAL_CACHE_HIT: |
| 227 backend_->SyncOnExternalCacheHit(key_); |
| 228 result_ = net::OK; |
| 229 break; |
| 221 case OP_CLOSE_ENTRY: | 230 case OP_CLOSE_ENTRY: |
| 222 entry_->Release(); | 231 entry_->Release(); |
| 223 result_ = net::OK; | 232 result_ = net::OK; |
| 224 break; | 233 break; |
| 225 case OP_DOOM_ENTRY: | 234 case OP_DOOM_ENTRY: |
| 226 entry_->DoomImpl(); | 235 entry_->DoomImpl(); |
| 227 result_ = net::OK; | 236 result_ = net::OK; |
| 228 break; | 237 break; |
| 229 case OP_FLUSH_QUEUE: | 238 case OP_FLUSH_QUEUE: |
| 230 result_ = net::OK; | 239 result_ = net::OK; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 operation->OpenPrevEntry(iter, prev_entry); | 360 operation->OpenPrevEntry(iter, prev_entry); |
| 352 PostOperation(operation); | 361 PostOperation(operation); |
| 353 } | 362 } |
| 354 | 363 |
| 355 void InFlightBackendIO::EndEnumeration(void* iterator) { | 364 void InFlightBackendIO::EndEnumeration(void* iterator) { |
| 356 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, NULL)); | 365 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, NULL)); |
| 357 operation->EndEnumeration(iterator); | 366 operation->EndEnumeration(iterator); |
| 358 PostOperation(operation); | 367 PostOperation(operation); |
| 359 } | 368 } |
| 360 | 369 |
| 370 void InFlightBackendIO::OnExternalCacheHit(const std::string& key) { |
| 371 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, NULL)); |
| 372 operation->OnExternalCacheHit(key); |
| 373 PostOperation(operation); |
| 374 } |
| 375 |
| 361 void InFlightBackendIO::CloseEntryImpl(EntryImpl* entry) { | 376 void InFlightBackendIO::CloseEntryImpl(EntryImpl* entry) { |
| 362 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, NULL)); | 377 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, NULL)); |
| 363 operation->CloseEntryImpl(entry); | 378 operation->CloseEntryImpl(entry); |
| 364 PostOperation(operation); | 379 PostOperation(operation); |
| 365 } | 380 } |
| 366 | 381 |
| 367 void InFlightBackendIO::DoomEntryImpl(EntryImpl* entry) { | 382 void InFlightBackendIO::DoomEntryImpl(EntryImpl* entry) { |
| 368 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, NULL)); | 383 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, NULL)); |
| 369 operation->DoomEntryImpl(entry); | 384 operation->DoomEntryImpl(entry); |
| 370 PostOperation(operation); | 385 PostOperation(operation); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 op->callback()->Run(op->result()); | 467 op->callback()->Run(op->result()); |
| 453 } | 468 } |
| 454 | 469 |
| 455 void InFlightBackendIO::PostOperation(BackendIO* operation) { | 470 void InFlightBackendIO::PostOperation(BackendIO* operation) { |
| 456 background_thread_->PostTask(FROM_HERE, | 471 background_thread_->PostTask(FROM_HERE, |
| 457 NewRunnableMethod(operation, &BackendIO::ExecuteOperation)); | 472 NewRunnableMethod(operation, &BackendIO::ExecuteOperation)); |
| 458 OnOperationPosted(operation); | 473 OnOperationPosted(operation); |
| 459 } | 474 } |
| 460 | 475 |
| 461 } // namespace | 476 } // namespace |
| OLD | NEW |