OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/http/disk_cache_based_quic_server_info.h" | 5 #include "net/http/disk_cache_based_quic_server_info.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 int rv) { | 193 int rv) { |
194 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 194 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
195 tracked_objects::ScopedTracker tracking_profile( | 195 tracked_objects::ScopedTracker tracking_profile( |
196 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 196 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
197 "422516 DiskCacheBasedQuicServerInfo::OnIOComplete")); | 197 "422516 DiskCacheBasedQuicServerInfo::OnIOComplete")); |
198 | 198 |
199 DCHECK_NE(NONE, state_); | 199 DCHECK_NE(NONE, state_); |
200 rv = DoLoop(rv); | 200 rv = DoLoop(rv); |
201 if (rv == ERR_IO_PENDING) | 201 if (rv == ERR_IO_PENDING) |
202 return; | 202 return; |
| 203 |
| 204 base::WeakPtr<DiskCacheBasedQuicServerInfo> weak_this = |
| 205 weak_factory_.GetWeakPtr(); |
| 206 |
203 if (!wait_for_ready_callback_.is_null()) { | 207 if (!wait_for_ready_callback_.is_null()) { |
204 wait_for_data_end_time_ = base::TimeTicks::Now(); | 208 wait_for_data_end_time_ = base::TimeTicks::Now(); |
205 RecordLastFailure(); | 209 RecordLastFailure(); |
206 base::ResetAndReturn(&wait_for_ready_callback_).Run(rv); | 210 base::ResetAndReturn(&wait_for_ready_callback_).Run(rv); |
207 } | 211 } |
208 if (ready_ && !pending_write_data_.empty()) { | 212 // |wait_for_ready_callback_| could delete the object if there is an error. |
| 213 // Check if |weak_this| still exists before accessing it. |
| 214 if (weak_this.get() && ready_ && !pending_write_data_.empty()) { |
209 DCHECK_EQ(NONE, state_); | 215 DCHECK_EQ(NONE, state_); |
210 PersistInternal(); | 216 PersistInternal(); |
211 } | 217 } |
212 } | 218 } |
213 | 219 |
214 int DiskCacheBasedQuicServerInfo::DoLoop(int rv) { | 220 int DiskCacheBasedQuicServerInfo::DoLoop(int rv) { |
215 do { | 221 do { |
216 switch (state_) { | 222 switch (state_) { |
217 case GET_BACKEND: | 223 case GET_BACKEND: |
218 rv = DoGetBackend(); | 224 rv = DoGetBackend(); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 } else if (backend_->GetCacheType() == net::MEMORY_CACHE) { | 489 } else if (backend_->GetCacheType() == net::MEMORY_CACHE) { |
484 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason.MemoryCache", | 490 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason.MemoryCache", |
485 failure, NUM_OF_FAILURES); | 491 failure, NUM_OF_FAILURES); |
486 } else { | 492 } else { |
487 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason.DiskCache", | 493 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason.DiskCache", |
488 failure, NUM_OF_FAILURES); | 494 failure, NUM_OF_FAILURES); |
489 } | 495 } |
490 } | 496 } |
491 | 497 |
492 } // namespace net | 498 } // namespace net |
OLD | NEW |