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" |
11 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
12 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
14 #include "net/http/http_cache.h" | 14 #include "net/http/http_cache.h" |
15 #include "net/http/http_network_session.h" | 15 #include "net/http/http_network_session.h" |
16 #include "net/quic/quic_server_id.h" | 16 #include "net/quic/quic_server_id.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
20 // Histogram that tracks number of times data read/parse/write API calls of | |
21 // QuicServerInfo to and from disk cache is called. | |
22 enum QuicServerInfoAPICall { | |
23 QUIC_SERVER_INFO_START = 0, | |
24 QUIC_SERVER_INFO_WAIT_FOR_DATA_READY = 1, | |
25 QUIC_SERVER_INFO_PARSE = 2, | |
26 QUIC_SERVER_INFO_WAIT_FOR_DATA_READY_CANCEL = 3, | |
27 QUIC_SERVER_INFO_READY_TO_PERSIST = 4, | |
28 QUIC_SERVER_INFO_PERSIST = 5, | |
29 QUIC_SERVER_INFO_NUM_OF_API_CALLS = 6, | |
30 }; | |
31 | |
32 // Histogram that tracks failure reasons to read/load/write of QuicServerInfo to | |
33 // and from disk cache. | |
34 enum FailureReason { | |
35 WAIT_FOR_DATA_READY_INVALID_ARGUMENT_FAILURE = 0, | |
36 GET_BACKEND_FAILURE = 1, | |
37 OPEN_FAILURE = 2, | |
38 CREATE_OR_OPEN_FAILURE = 3, | |
39 PARSE_NO_DATA_FAILURE = 4, | |
40 PARSE_FAILURE = 5, | |
41 READ_FAILURE = 6, | |
42 READY_TO_PERSIST_FAILURE = 7, | |
43 PERSIST_NO_BACKEND_FAILURE = 8, | |
44 WRITE_FAILURE = 9, | |
45 NUM_OF_FAILURES = 10, | |
46 }; | |
47 | |
48 void RecordQuicServerInfoStatus(QuicServerInfoAPICall call) { | |
49 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.APICall", call, | |
50 QUIC_SERVER_INFO_NUM_OF_API_CALLS); | |
51 } | |
52 | |
53 void RecordQuicServerInfoFailure(FailureReason failure) { | |
54 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason", failure, | |
55 NUM_OF_FAILURES); | |
56 } | |
57 | |
58 // Some APIs inside disk_cache take a handle that the caller must keep alive | 20 // Some APIs inside disk_cache take a handle that the caller must keep alive |
59 // until the API has finished its asynchronous execution. | 21 // until the API has finished its asynchronous execution. |
60 // | 22 // |
61 // Unfortunately, DiskCacheBasedQuicServerInfo may be deleted before the | 23 // Unfortunately, DiskCacheBasedQuicServerInfo may be deleted before the |
62 // operation completes causing a use-after-free. | 24 // operation completes causing a use-after-free. |
63 // | 25 // |
64 // This data shim struct is meant to provide a location for the disk_cache | 26 // This data shim struct is meant to provide a location for the disk_cache |
65 // APIs to write into even if the originating DiskCacheBasedQuicServerInfo | 27 // APIs to write into even if the originating DiskCacheBasedQuicServerInfo |
66 // object has been deleted. The lifetime for instances of this struct | 28 // object has been deleted. The lifetime for instances of this struct |
67 // should be bound to the CompletionCallback that is passed to the disk_cache | 29 // should be bound to the CompletionCallback that is passed to the disk_cache |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 | 336 |
375 int DiskCacheBasedQuicServerInfo::DoSetDone() { | 337 int DiskCacheBasedQuicServerInfo::DoSetDone() { |
376 if (entry_) | 338 if (entry_) |
377 entry_->Close(); | 339 entry_->Close(); |
378 entry_ = NULL; | 340 entry_ = NULL; |
379 new_data_.clear(); | 341 new_data_.clear(); |
380 state_ = NONE; | 342 state_ = NONE; |
381 return OK; | 343 return OK; |
382 } | 344 } |
383 | 345 |
346 void DiskCacheBasedQuicServerInfo::RecordQuicServerInfoStatus( | |
347 QuicServerInfoAPICall call) { | |
348 if (!backend_) { | |
349 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.APICall", call, | |
350 QUIC_SERVER_INFO_NUM_OF_API_CALLS); | |
351 } else if (backend_->GetCacheType() == net::MEMORY_CACHE) { | |
352 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.APICall.MemoryCache", call, | |
353 QUIC_SERVER_INFO_NUM_OF_API_CALLS); | |
354 } else { | |
355 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.APICall.DiskCache", call, | |
356 QUIC_SERVER_INFO_NUM_OF_API_CALLS); | |
357 } | |
358 } | |
359 | |
360 void DiskCacheBasedQuicServerInfo::RecordQuicServerInfoFailure( | |
361 FailureReason failure) { | |
362 if (!backend_) { | |
363 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason", failure, | |
Alexei Svitkine (slow)
2014/11/07 16:00:36
Generally, the practice is to keep the non suffixe
ramant (doing other things)
2014/11/07 17:53:04
Wanted to give it a new suffix, but made the wrong
| |
364 NUM_OF_FAILURES); | |
365 } else if (backend_->GetCacheType() == net::MEMORY_CACHE) { | |
366 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason.MemoryCache", | |
367 failure, NUM_OF_FAILURES); | |
368 } else { | |
369 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason.DiskCache", | |
370 failure, NUM_OF_FAILURES); | |
371 } | |
372 } | |
373 | |
384 } // namespace net | 374 } // namespace net |
OLD | NEW |