Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: net/disk_cache/blockfile/in_flight_backend_io.cc

Issue 588243002: Reland of "Remove void** from disk_cache interface" w/ blockfile iter fix. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@1-webcacheimpl
Patch Set: cleanup presubmit Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/disk_cache/blockfile/in_flight_backend_io.h ('k') | net/disk_cache/blockfile/rankings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "net/disk_cache/blockfile/backend_impl.h" 13 #include "net/disk_cache/blockfile/backend_impl.h"
14 #include "net/disk_cache/blockfile/entry_impl.h" 14 #include "net/disk_cache/blockfile/entry_impl.h"
15 #include "net/disk_cache/blockfile/histogram_macros.h" 15 #include "net/disk_cache/blockfile/histogram_macros.h"
16 16
17 // Provide a BackendImpl object to macros from histogram_macros.h. 17 // Provide a BackendImpl object to macros from histogram_macros.h.
18 #define CACHE_UMA_BACKEND_IMPL_OBJ backend_ 18 #define CACHE_UMA_BACKEND_IMPL_OBJ backend_
19 19
20 namespace disk_cache { 20 namespace disk_cache {
21 21
22 BackendIO::BackendIO(InFlightIO* controller, BackendImpl* backend, 22 BackendIO::BackendIO(InFlightIO* controller, BackendImpl* backend,
23 const net::CompletionCallback& callback) 23 const net::CompletionCallback& callback)
24 : BackgroundIO(controller), 24 : BackgroundIO(controller),
25 backend_(backend), 25 backend_(backend),
26 callback_(callback), 26 callback_(callback),
27 operation_(OP_NONE), 27 operation_(OP_NONE),
28 entry_ptr_(NULL), 28 entry_ptr_(NULL),
29 iter_ptr_(NULL), 29 iterator_(NULL),
30 iter_(NULL),
31 entry_(NULL), 30 entry_(NULL),
32 index_(0), 31 index_(0),
33 offset_(0), 32 offset_(0),
34 buf_len_(0), 33 buf_len_(0),
35 truncate_(false), 34 truncate_(false),
36 offset64_(0), 35 offset64_(0),
37 start_(NULL) { 36 start_(NULL) {
38 start_time_ = base::TimeTicks::Now(); 37 start_time_ = base::TimeTicks::Now();
39 } 38 }
40 39
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 operation_ = OP_DOOM_BETWEEN; 108 operation_ = OP_DOOM_BETWEEN;
110 initial_time_ = initial_time; 109 initial_time_ = initial_time;
111 end_time_ = end_time; 110 end_time_ = end_time;
112 } 111 }
113 112
114 void BackendIO::DoomEntriesSince(const base::Time initial_time) { 113 void BackendIO::DoomEntriesSince(const base::Time initial_time) {
115 operation_ = OP_DOOM_SINCE; 114 operation_ = OP_DOOM_SINCE;
116 initial_time_ = initial_time; 115 initial_time_ = initial_time;
117 } 116 }
118 117
119 void BackendIO::OpenNextEntry(void** iter, Entry** next_entry) { 118 void BackendIO::OpenNextEntry(Rankings::Iterator* iterator,
119 Entry** next_entry) {
120 operation_ = OP_OPEN_NEXT; 120 operation_ = OP_OPEN_NEXT;
121 iter_ptr_ = iter; 121 iterator_ = iterator;
122 entry_ptr_ = next_entry; 122 entry_ptr_ = next_entry;
123 } 123 }
124 124
125 void BackendIO::EndEnumeration(void* iterator) { 125 void BackendIO::EndEnumeration(scoped_ptr<Rankings::Iterator> iterator) {
126 operation_ = OP_END_ENUMERATION; 126 operation_ = OP_END_ENUMERATION;
127 iter_ = iterator; 127 scoped_iterator_ = iterator.Pass();
128 } 128 }
129 129
130 void BackendIO::OnExternalCacheHit(const std::string& key) { 130 void BackendIO::OnExternalCacheHit(const std::string& key) {
131 operation_ = OP_ON_EXTERNAL_CACHE_HIT; 131 operation_ = OP_ON_EXTERNAL_CACHE_HIT;
132 key_ = key; 132 key_ = key;
133 } 133 }
134 134
135 void BackendIO::CloseEntryImpl(EntryImpl* entry) { 135 void BackendIO::CloseEntryImpl(EntryImpl* entry) {
136 operation_ = OP_CLOSE_ENTRY; 136 operation_ = OP_CLOSE_ENTRY;
137 entry_ = entry; 137 entry_ = entry;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 case OP_DOOM_ALL: 238 case OP_DOOM_ALL:
239 result_ = backend_->SyncDoomAllEntries(); 239 result_ = backend_->SyncDoomAllEntries();
240 break; 240 break;
241 case OP_DOOM_BETWEEN: 241 case OP_DOOM_BETWEEN:
242 result_ = backend_->SyncDoomEntriesBetween(initial_time_, end_time_); 242 result_ = backend_->SyncDoomEntriesBetween(initial_time_, end_time_);
243 break; 243 break;
244 case OP_DOOM_SINCE: 244 case OP_DOOM_SINCE:
245 result_ = backend_->SyncDoomEntriesSince(initial_time_); 245 result_ = backend_->SyncDoomEntriesSince(initial_time_);
246 break; 246 break;
247 case OP_OPEN_NEXT: 247 case OP_OPEN_NEXT:
248 result_ = backend_->SyncOpenNextEntry(iter_ptr_, entry_ptr_); 248 result_ = backend_->SyncOpenNextEntry(iterator_, entry_ptr_);
249 break; 249 break;
250 case OP_END_ENUMERATION: 250 case OP_END_ENUMERATION:
251 backend_->SyncEndEnumeration(iter_); 251 backend_->SyncEndEnumeration(scoped_iterator_.Pass());
252 result_ = net::OK; 252 result_ = net::OK;
253 break; 253 break;
254 case OP_ON_EXTERNAL_CACHE_HIT: 254 case OP_ON_EXTERNAL_CACHE_HIT:
255 backend_->SyncOnExternalCacheHit(key_); 255 backend_->SyncOnExternalCacheHit(key_);
256 result_ = net::OK; 256 result_ = net::OK;
257 break; 257 break;
258 case OP_CLOSE_ENTRY: 258 case OP_CLOSE_ENTRY:
259 entry_->Release(); 259 entry_->Release();
260 result_ = net::OK; 260 result_ = net::OK;
261 break; 261 break;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 PostOperation(operation.get()); 375 PostOperation(operation.get());
376 } 376 }
377 377
378 void InFlightBackendIO::DoomEntriesSince( 378 void InFlightBackendIO::DoomEntriesSince(
379 const base::Time initial_time, const net::CompletionCallback& callback) { 379 const base::Time initial_time, const net::CompletionCallback& callback) {
380 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); 380 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback));
381 operation->DoomEntriesSince(initial_time); 381 operation->DoomEntriesSince(initial_time);
382 PostOperation(operation.get()); 382 PostOperation(operation.get());
383 } 383 }
384 384
385 void InFlightBackendIO::OpenNextEntry(void** iter, Entry** next_entry, 385 void InFlightBackendIO::OpenNextEntry(Rankings::Iterator* iterator,
386 Entry** next_entry,
386 const net::CompletionCallback& callback) { 387 const net::CompletionCallback& callback) {
387 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback)); 388 scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, callback));
388 operation->OpenNextEntry(iter, next_entry); 389 operation->OpenNextEntry(iterator, next_entry);
389 PostOperation(operation.get()); 390 PostOperation(operation.get());
390 } 391 }
391 392
392 void InFlightBackendIO::EndEnumeration(void* iterator) { 393 void InFlightBackendIO::EndEnumeration(
394 scoped_ptr<Rankings::Iterator> iterator) {
393 scoped_refptr<BackendIO> operation( 395 scoped_refptr<BackendIO> operation(
394 new BackendIO(this, backend_, net::CompletionCallback())); 396 new BackendIO(this, backend_, net::CompletionCallback()));
395 operation->EndEnumeration(iterator); 397 operation->EndEnumeration(iterator.Pass());
396 PostOperation(operation.get()); 398 PostOperation(operation.get());
397 } 399 }
398 400
399 void InFlightBackendIO::OnExternalCacheHit(const std::string& key) { 401 void InFlightBackendIO::OnExternalCacheHit(const std::string& key) {
400 scoped_refptr<BackendIO> operation( 402 scoped_refptr<BackendIO> operation(
401 new BackendIO(this, backend_, net::CompletionCallback())); 403 new BackendIO(this, backend_, net::CompletionCallback()));
402 operation->OnExternalCacheHit(key); 404 operation->OnExternalCacheHit(key);
403 PostOperation(operation.get()); 405 PostOperation(operation.get());
404 } 406 }
405 407
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 background_thread_->PostTask( 504 background_thread_->PostTask(
503 FROM_HERE, base::Bind(&BackendIO::ExecuteOperation, operation)); 505 FROM_HERE, base::Bind(&BackendIO::ExecuteOperation, operation));
504 OnOperationPosted(operation); 506 OnOperationPosted(operation);
505 } 507 }
506 508
507 base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() { 509 base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() {
508 return ptr_factory_.GetWeakPtr(); 510 return ptr_factory_.GetWeakPtr();
509 } 511 }
510 512
511 } // namespace 513 } // namespace
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/in_flight_backend_io.h ('k') | net/disk_cache/blockfile/rankings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698