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" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/profiler/scoped_tracker.h" |
12 #include "net/base/completion_callback.h" | 13 #include "net/base/completion_callback.h" |
13 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
15 #include "net/http/http_cache.h" | 16 #include "net/http/http_cache.h" |
16 #include "net/http/http_network_session.h" | 17 #include "net/http/http_network_session.h" |
17 #include "net/quic/quic_server_id.h" | 18 #include "net/quic/quic_server_id.h" |
18 | 19 |
19 namespace net { | 20 namespace net { |
20 | 21 |
21 // Some APIs inside disk_cache take a handle that the caller must keep alive | 22 // Some APIs inside disk_cache take a handle that the caller must keep alive |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 DCHECK_EQ(last_failure_, NO_FAILURE); | 72 DCHECK_EQ(last_failure_, NO_FAILURE); |
72 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_START); | 73 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_START); |
73 load_start_time_ = base::TimeTicks::Now(); | 74 load_start_time_ = base::TimeTicks::Now(); |
74 DoLoop(OK); | 75 DoLoop(OK); |
75 } | 76 } |
76 | 77 |
77 int DiskCacheBasedQuicServerInfo::WaitForDataReady( | 78 int DiskCacheBasedQuicServerInfo::WaitForDataReady( |
78 const CompletionCallback& callback) { | 79 const CompletionCallback& callback) { |
79 DCHECK(CalledOnValidThread()); | 80 DCHECK(CalledOnValidThread()); |
80 DCHECK_NE(GET_BACKEND, state_); | 81 DCHECK_NE(GET_BACKEND, state_); |
| 82 wait_for_data_start_time_ = base::TimeTicks::Now(); |
81 | 83 |
82 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_WAIT_FOR_DATA_READY); | 84 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_WAIT_FOR_DATA_READY); |
83 if (ready_) { | 85 if (ready_) { |
| 86 wait_for_data_end_time_ = base::TimeTicks::Now(); |
84 RecordLastFailure(); | 87 RecordLastFailure(); |
85 return OK; | 88 return OK; |
86 } | 89 } |
87 | 90 |
88 if (!callback.is_null()) { | 91 if (!callback.is_null()) { |
89 // Prevent a new callback for WaitForDataReady overwriting an existing | 92 // Prevent a new callback for WaitForDataReady overwriting an existing |
90 // pending callback (|wait_for_ready_callback_|). | 93 // pending callback (|wait_for_ready_callback_|). |
91 if (!wait_for_ready_callback_.is_null()) { | 94 if (!wait_for_ready_callback_.is_null()) { |
92 RecordQuicServerInfoFailure(WAIT_FOR_DATA_READY_INVALID_ARGUMENT_FAILURE); | 95 RecordQuicServerInfoFailure(WAIT_FOR_DATA_READY_INVALID_ARGUMENT_FAILURE); |
93 return ERR_INVALID_ARGUMENT; | 96 return ERR_INVALID_ARGUMENT; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 if (entry_) | 179 if (entry_) |
177 entry_->Close(); | 180 entry_->Close(); |
178 } | 181 } |
179 | 182 |
180 std::string DiskCacheBasedQuicServerInfo::key() const { | 183 std::string DiskCacheBasedQuicServerInfo::key() const { |
181 return "quicserverinfo:" + server_id_.ToString(); | 184 return "quicserverinfo:" + server_id_.ToString(); |
182 } | 185 } |
183 | 186 |
184 void DiskCacheBasedQuicServerInfo::OnIOComplete(CacheOperationDataShim* unused, | 187 void DiskCacheBasedQuicServerInfo::OnIOComplete(CacheOperationDataShim* unused, |
185 int rv) { | 188 int rv) { |
| 189 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
| 190 tracked_objects::ScopedTracker tracking_profile( |
| 191 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 192 "422516 DiskCacheBasedQuicServerInfo::OnIOComplete")); |
| 193 |
186 DCHECK_NE(NONE, state_); | 194 DCHECK_NE(NONE, state_); |
187 rv = DoLoop(rv); | 195 rv = DoLoop(rv); |
188 if (rv == ERR_IO_PENDING) | 196 if (rv == ERR_IO_PENDING) |
189 return; | 197 return; |
190 if (!wait_for_ready_callback_.is_null()) { | 198 if (!wait_for_ready_callback_.is_null()) { |
| 199 wait_for_data_end_time_ = base::TimeTicks::Now(); |
191 RecordLastFailure(); | 200 RecordLastFailure(); |
192 base::ResetAndReturn(&wait_for_ready_callback_).Run(rv); | 201 base::ResetAndReturn(&wait_for_ready_callback_).Run(rv); |
193 } | 202 } |
194 if (ready_ && !pending_write_data_.empty()) { | 203 if (ready_ && !pending_write_data_.empty()) { |
195 DCHECK_EQ(NONE, state_); | 204 DCHECK_EQ(NONE, state_); |
196 PersistInternal(); | 205 PersistInternal(); |
197 } | 206 } |
198 } | 207 } |
199 | 208 |
200 int DiskCacheBasedQuicServerInfo::DoLoop(int rv) { | 209 int DiskCacheBasedQuicServerInfo::DoLoop(int rv) { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 } else if (backend_->GetCacheType() == net::MEMORY_CACHE) { | 423 } else if (backend_->GetCacheType() == net::MEMORY_CACHE) { |
415 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason.MemoryCache", | 424 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason.MemoryCache", |
416 failure, NUM_OF_FAILURES); | 425 failure, NUM_OF_FAILURES); |
417 } else { | 426 } else { |
418 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason.DiskCache", | 427 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason.DiskCache", |
419 failure, NUM_OF_FAILURES); | 428 failure, NUM_OF_FAILURES); |
420 } | 429 } |
421 } | 430 } |
422 | 431 |
423 } // namespace net | 432 } // namespace net |
OLD | NEW |