Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: net/quic/chromium/properties_based_quic_server_info.cc

Issue 2821053004: Revert of Remove the code to store and load QUIC server configs in the disk cache. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/quic/chromium/properties_based_quic_server_info.h" 5 #include "net/quic/chromium/properties_based_quic_server_info.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
11 #include "net/http/http_server_properties.h" 11 #include "net/http/http_server_properties.h"
12 12
13 using std::string; 13 using std::string;
14 14
15 namespace { 15 namespace {
16 16
17 void RecordQuicServerInfoStatus(
18 net::QuicServerInfo::QuicServerInfoAPICall call) {
19 UMA_HISTOGRAM_ENUMERATION(
20 "Net.QuicDiskCache.APICall.PropertiesBasedCache", call,
21 net::QuicServerInfo::QUIC_SERVER_INFO_NUM_OF_API_CALLS);
22 }
23
17 void RecordQuicServerInfoFailure(net::QuicServerInfo::FailureReason failure) { 24 void RecordQuicServerInfoFailure(net::QuicServerInfo::FailureReason failure) {
18 UMA_HISTOGRAM_ENUMERATION( 25 UMA_HISTOGRAM_ENUMERATION(
19 "Net.QuicDiskCache.FailureReason.PropertiesBasedCache", failure, 26 "Net.QuicDiskCache.FailureReason.PropertiesBasedCache", failure,
20 net::QuicServerInfo::NUM_OF_FAILURES); 27 net::QuicServerInfo::NUM_OF_FAILURES);
21 } 28 }
22 29
23 } // namespace 30 } // namespace
24 31
25 namespace net { 32 namespace net {
26 33
27 PropertiesBasedQuicServerInfo::PropertiesBasedQuicServerInfo( 34 PropertiesBasedQuicServerInfo::PropertiesBasedQuicServerInfo(
28 const QuicServerId& server_id, 35 const QuicServerId& server_id,
29 HttpServerProperties* http_server_properties) 36 HttpServerProperties* http_server_properties)
30 : QuicServerInfo(server_id), 37 : QuicServerInfo(server_id),
31 http_server_properties_(http_server_properties) { 38 http_server_properties_(http_server_properties) {
32 DCHECK(http_server_properties_); 39 DCHECK(http_server_properties_);
33 } 40 }
34 41
35 PropertiesBasedQuicServerInfo::~PropertiesBasedQuicServerInfo() {} 42 PropertiesBasedQuicServerInfo::~PropertiesBasedQuicServerInfo() {}
36 43
37 bool PropertiesBasedQuicServerInfo::Load() { 44 void PropertiesBasedQuicServerInfo::Start() {
45 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_START);
46 }
47
48 int PropertiesBasedQuicServerInfo::WaitForDataReady(
49 const CompletionCallback& callback) {
50 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_WAIT_FOR_DATA_READY);
38 const string* data = http_server_properties_->GetQuicServerInfo(server_id_); 51 const string* data = http_server_properties_->GetQuicServerInfo(server_id_);
39 string decoded; 52 string decoded;
40 if (!data) { 53 if (!data) {
41 RecordQuicServerInfoFailure(PARSE_NO_DATA_FAILURE); 54 RecordQuicServerInfoFailure(PARSE_NO_DATA_FAILURE);
42 return false; 55 return ERR_FAILED;
43 } 56 }
44 if (!base::Base64Decode(*data, &decoded)) { 57 if (!base::Base64Decode(*data, &decoded)) {
45 RecordQuicServerInfoFailure(PARSE_DATA_DECODE_FAILURE); 58 RecordQuicServerInfoFailure(PARSE_DATA_DECODE_FAILURE);
46 return false; 59 return ERR_FAILED;
47 } 60 }
61 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_PARSE);
48 if (!Parse(decoded)) { 62 if (!Parse(decoded)) {
49 RecordQuicServerInfoFailure(PARSE_FAILURE); 63 RecordQuicServerInfoFailure(PARSE_FAILURE);
50 return false; 64 return ERR_FAILED;
51 } 65 }
66 return OK;
67 }
68
69 void PropertiesBasedQuicServerInfo::ResetWaitForDataReadyCallback() {
70 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_RESET_WAIT_FOR_DATA_READY);
71 }
72
73 void PropertiesBasedQuicServerInfo::CancelWaitForDataReadyCallback() {
74 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_WAIT_FOR_DATA_READY_CANCEL);
75 }
76
77 bool PropertiesBasedQuicServerInfo::IsDataReady() {
52 return true; 78 return true;
53 } 79 }
54 80
81 bool PropertiesBasedQuicServerInfo::IsReadyToPersist() {
82 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_READY_TO_PERSIST);
83 return true;
84 }
55 85
56 void PropertiesBasedQuicServerInfo::Persist() { 86 void PropertiesBasedQuicServerInfo::Persist() {
87 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_PERSIST);
57 string encoded; 88 string encoded;
58 base::Base64Encode(Serialize(), &encoded); 89 base::Base64Encode(Serialize(), &encoded);
59 http_server_properties_->SetQuicServerInfo(server_id_, encoded); 90 http_server_properties_->SetQuicServerInfo(server_id_, encoded);
60 } 91 }
61 92
93 void PropertiesBasedQuicServerInfo::OnExternalCacheHit() {
94 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_EXTERNAL_CACHE_HIT);
95 }
96
62 size_t PropertiesBasedQuicServerInfo::EstimateMemoryUsage() const { 97 size_t PropertiesBasedQuicServerInfo::EstimateMemoryUsage() const {
63 return 0; 98 return 0;
64 } 99 }
65 100
101 PropertiesBasedQuicServerInfoFactory::PropertiesBasedQuicServerInfoFactory(
102 HttpServerProperties* http_server_properties)
103 : http_server_properties_(http_server_properties) {}
104
105 PropertiesBasedQuicServerInfoFactory::~PropertiesBasedQuicServerInfoFactory() {}
106
107 std::unique_ptr<QuicServerInfo>
108 PropertiesBasedQuicServerInfoFactory::GetForServer(
109 const QuicServerId& server_id) {
110 return base::MakeUnique<PropertiesBasedQuicServerInfo>(
111 server_id, http_server_properties_);
112 }
113
66 } // namespace net 114 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/properties_based_quic_server_info.h ('k') | net/quic/chromium/properties_based_quic_server_info_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698