| Index: net/disk_cache/in_flight_backend_io.cc | 
| =================================================================== | 
| --- net/disk_cache/in_flight_backend_io.cc	(revision 126788) | 
| +++ net/disk_cache/in_flight_backend_io.cc	(working copy) | 
| @@ -42,9 +42,25 @@ | 
| DCHECK(IsEntryOperation()); | 
| DCHECK_NE(result, net::ERR_IO_PENDING); | 
| result_ = result; | 
| -  controller_->OnIOComplete(this); | 
| +  NotifyController(); | 
| } | 
|  | 
| +// Runs on the primary thread. | 
| +void BackendIO::OnDone(bool cancel) { | 
| +  if (IsEntryOperation()) { | 
| +    CACHE_UMA(TIMES, "TotalIOTime", 0, ElapsedTime()); | 
| +  } | 
| + | 
| +  if (!ReturnsEntry()) | 
| +    return; | 
| + | 
| +  if (result() == net::OK) { | 
| +    static_cast<EntryImpl*>(*entry_ptr_)->OnEntryCreated(backend_); | 
| +    if (cancel) | 
| +      (*entry_ptr_)->Close(); | 
| +  } | 
| +} | 
| + | 
| bool BackendIO::IsEntryOperation() { | 
| return operation_ > OP_MAX_BACKEND; | 
| } | 
| @@ -54,10 +70,6 @@ | 
| entry_->AddRef(); | 
| } | 
|  | 
| -base::TimeDelta BackendIO::ElapsedTime() const { | 
| -  return base::TimeTicks::Now() - start_time_; | 
| -} | 
| - | 
| void BackendIO::Init() { | 
| operation_ = OP_INIT; | 
| } | 
| @@ -196,6 +208,15 @@ | 
|  | 
| BackendIO::~BackendIO() {} | 
|  | 
| +bool BackendIO::ReturnsEntry() { | 
| +  return (operation_ == OP_OPEN || operation_ == OP_CREATE || | 
| +          operation_ == OP_OPEN_NEXT || operation_ == OP_OPEN_PREV); | 
| +} | 
| + | 
| +base::TimeDelta BackendIO::ElapsedTime() const { | 
| +  return base::TimeTicks::Now() - start_time_; | 
| +} | 
| + | 
| // Runs on the background thread. | 
| void BackendIO::ExecuteBackendOperation() { | 
| switch (operation_) { | 
| @@ -254,7 +275,7 @@ | 
| result_ = net::ERR_UNEXPECTED; | 
| } | 
| DCHECK_NE(net::ERR_IO_PENDING, result_); | 
| -  controller_->OnIOComplete(this); | 
| +  NotifyController(); | 
| } | 
|  | 
| // Runs on the background thread. | 
| @@ -297,13 +318,14 @@ | 
| result_ = net::ERR_UNEXPECTED; | 
| } | 
| if (result_ != net::ERR_IO_PENDING) | 
| -    controller_->OnIOComplete(this); | 
| +    NotifyController(); | 
| } | 
|  | 
| InFlightBackendIO::InFlightBackendIO(BackendImpl* backend, | 
| base::MessageLoopProxy* background_thread) | 
| : backend_(backend), | 
| -      background_thread_(background_thread) { | 
| +      background_thread_(background_thread), | 
| +      ALLOW_THIS_IN_INITIALIZER_LIST(ptr_factory_(this)) { | 
| } | 
|  | 
| InFlightBackendIO::~InFlightBackendIO() { | 
| @@ -475,11 +497,8 @@ | 
| void InFlightBackendIO::OnOperationComplete(BackgroundIO* operation, | 
| bool cancel) { | 
| BackendIO* op = static_cast<BackendIO*>(operation); | 
| +  op->OnDone(cancel); | 
|  | 
| -  if (op->IsEntryOperation()) { | 
| -    CACHE_UMA(TIMES, "TotalIOTime", 0, op->ElapsedTime()); | 
| -  } | 
| - | 
| if (!op->callback().is_null() && (!cancel || op->IsEntryOperation())) | 
| op->callback().Run(op->result()); | 
| } | 
| @@ -490,4 +509,8 @@ | 
| OnOperationPosted(operation); | 
| } | 
|  | 
| +base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() { | 
| +  return ptr_factory_.GetWeakPtr(); | 
| +} | 
| + | 
| }  // namespace | 
|  |