summaryrefslogtreecommitdiff
path: root/chromium/net/disk_cache/blockfile/in_flight_backend_io.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/net/disk_cache/blockfile/in_flight_backend_io.cc')
-rw-r--r--chromium/net/disk_cache/blockfile/in_flight_backend_io.cc26
1 files changed, 19 insertions, 7 deletions
diff --git a/chromium/net/disk_cache/blockfile/in_flight_backend_io.cc b/chromium/net/disk_cache/blockfile/in_flight_backend_io.cc
index 98bb1ec43ae..ceebe54a4c0 100644
--- a/chromium/net/disk_cache/blockfile/in_flight_backend_io.cc
+++ b/chromium/net/disk_cache/blockfile/in_flight_backend_io.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -74,13 +74,19 @@ void BackendIO::OnIOComplete(int result) {
DCHECK(IsEntryOperation());
DCHECK_NE(result, net::ERR_IO_PENDING);
result_ = result;
- NotifyController();
+ if (notify_controller_)
+ NotifyController();
}
// Runs on the primary thread.
void BackendIO::OnDone(bool cancel) {
if (IsEntryOperation()) {
CACHE_UMA(TIMES, "TotalIOTime", 0, ElapsedTime());
+ if (operation_ == OP_READ) {
+ CACHE_UMA(TIMES, "TotalIOTimeRead", 0, ElapsedTime());
+ } else if (operation_ == OP_WRITE) {
+ CACHE_UMA(TIMES, "TotalIOTimeWrite", 0, ElapsedTime());
+ }
}
if (ReturnsEntry() && result_ == net::OK) {
@@ -88,6 +94,7 @@ void BackendIO::OnDone(bool cancel) {
if (cancel)
out_entry_.ExtractAsDangling()->Close();
}
+ ClearController();
}
bool BackendIO::IsEntryOperation() {
@@ -335,7 +342,7 @@ void BackendIO::ExecuteBackendOperation() {
case OP_CLOSE_ENTRY:
// Collect the reference to |entry_| to balance with the AddRef() in
// LeakEntryImpl.
- entry_->Release();
+ entry_.ExtractAsDangling()->Release();
result_ = net::OK;
break;
case OP_DOOM_ENTRY:
@@ -366,11 +373,16 @@ void BackendIO::ExecuteEntryOperation() {
entry_->ReadDataImpl(index_, offset_, buf_.get(), buf_len_,
base::BindOnce(&BackendIO::OnIOComplete, this));
break;
- case OP_WRITE:
- result_ = entry_->WriteDataImpl(
- index_, offset_, buf_.get(), buf_len_,
- base::BindOnce(&BackendIO::OnIOComplete, this), truncate_);
+ case OP_WRITE: {
+ bool optimistic = false;
+ result_ =
+ entry_->WriteDataImpl(index_, offset_, buf_.get(), buf_len_,
+ base::BindOnce(&BackendIO::OnIOComplete, this),
+ truncate_, &optimistic);
+ if (optimistic)
+ notify_controller_ = false;
break;
+ }
case OP_READ_SPARSE:
result_ = entry_->ReadSparseDataImpl(
offset64_, buf_.get(), buf_len_,