| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 weak_factory_(this) { | 71 weak_factory_(this) { |
| 72 io_callback_ = | 72 io_callback_ = |
| 73 base::Bind(&DiskCacheBasedQuicServerInfo::OnIOComplete, | 73 base::Bind(&DiskCacheBasedQuicServerInfo::OnIOComplete, |
| 74 weak_factory_.GetWeakPtr(), | 74 weak_factory_.GetWeakPtr(), |
| 75 base::Owned(data_shim_)); // Ownership assigned. | 75 base::Owned(data_shim_)); // Ownership assigned. |
| 76 } | 76 } |
| 77 | 77 |
| 78 void DiskCacheBasedQuicServerInfo::Start() { | 78 void DiskCacheBasedQuicServerInfo::Start() { |
| 79 DCHECK(CalledOnValidThread()); | 79 DCHECK(CalledOnValidThread()); |
| 80 DCHECK_EQ(GET_BACKEND, state_); | 80 DCHECK_EQ(GET_BACKEND, state_); |
| 81 load_start_time_ = base::TimeTicks::Now(); |
| 81 DoLoop(OK); | 82 DoLoop(OK); |
| 82 } | 83 } |
| 83 | 84 |
| 84 int DiskCacheBasedQuicServerInfo::WaitForDataReady( | 85 int DiskCacheBasedQuicServerInfo::WaitForDataReady( |
| 85 const CompletionCallback& callback) { | 86 const CompletionCallback& callback) { |
| 86 DCHECK(CalledOnValidThread()); | 87 DCHECK(CalledOnValidThread()); |
| 87 DCHECK_NE(GET_BACKEND, state_); | 88 DCHECK_NE(GET_BACKEND, state_); |
| 88 | 89 |
| 89 if (ready_) | 90 if (ready_) |
| 90 return OK; | 91 return OK; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 state_ = NONE; | 306 state_ = NONE; |
| 306 ready_ = true; | 307 ready_ = true; |
| 307 // We close the entry because, if we shutdown before ::Persist is called, | 308 // We close the entry because, if we shutdown before ::Persist is called, |
| 308 // then we might leak a cache reference, which causes a DCHECK on shutdown. | 309 // then we might leak a cache reference, which causes a DCHECK on shutdown. |
| 309 if (entry_) { | 310 if (entry_) { |
| 310 entry_->Close(); | 311 entry_->Close(); |
| 311 RecordDiskCacheEntryState(DISK_CACHE_ENTRY_CLOSED); | 312 RecordDiskCacheEntryState(DISK_CACHE_ENTRY_CLOSED); |
| 312 } | 313 } |
| 313 entry_ = NULL; | 314 entry_ = NULL; |
| 314 Parse(data_); | 315 Parse(data_); |
| 316 UMA_HISTOGRAM_TIMES("Net.QuicServerInfo.DiskCacheLoadTime", |
| 317 base::TimeTicks::Now() - load_start_time_); |
| 315 return OK; | 318 return OK; |
| 316 } | 319 } |
| 317 | 320 |
| 318 int DiskCacheBasedQuicServerInfo::DoSetDone() { | 321 int DiskCacheBasedQuicServerInfo::DoSetDone() { |
| 319 if (entry_) { | 322 if (entry_) { |
| 320 entry_->Close(); | 323 entry_->Close(); |
| 321 RecordDiskCacheEntryState(DISK_CACHE_ENTRY_CLOSED); | 324 RecordDiskCacheEntryState(DISK_CACHE_ENTRY_CLOSED); |
| 322 } | 325 } |
| 323 entry_ = NULL; | 326 entry_ = NULL; |
| 324 new_data_.clear(); | 327 new_data_.clear(); |
| 325 state_ = NONE; | 328 state_ = NONE; |
| 326 return OK; | 329 return OK; |
| 327 } | 330 } |
| 328 | 331 |
| 329 } // namespace net | 332 } // namespace net |
| OLD | NEW |