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

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

Issue 2820573004: Remove the code to store and load QUIC server configs in the disk cache. (Closed)
Patch Set: Fix 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
24 void RecordQuicServerInfoFailure(net::QuicServerInfo::FailureReason failure) { 17 void RecordQuicServerInfoFailure(net::QuicServerInfo::FailureReason failure) {
25 UMA_HISTOGRAM_ENUMERATION( 18 UMA_HISTOGRAM_ENUMERATION(
26 "Net.QuicDiskCache.FailureReason.PropertiesBasedCache", failure, 19 "Net.QuicDiskCache.FailureReason.PropertiesBasedCache", failure,
27 net::QuicServerInfo::NUM_OF_FAILURES); 20 net::QuicServerInfo::NUM_OF_FAILURES);
28 } 21 }
29 22
30 } // namespace 23 } // namespace
31 24
32 namespace net { 25 namespace net {
33 26
34 PropertiesBasedQuicServerInfo::PropertiesBasedQuicServerInfo( 27 PropertiesBasedQuicServerInfo::PropertiesBasedQuicServerInfo(
35 const QuicServerId& server_id, 28 const QuicServerId& server_id,
36 HttpServerProperties* http_server_properties) 29 HttpServerProperties* http_server_properties)
37 : QuicServerInfo(server_id), 30 : QuicServerInfo(server_id),
38 http_server_properties_(http_server_properties) { 31 http_server_properties_(http_server_properties) {
39 DCHECK(http_server_properties_); 32 DCHECK(http_server_properties_);
40 } 33 }
41 34
42 PropertiesBasedQuicServerInfo::~PropertiesBasedQuicServerInfo() {} 35 PropertiesBasedQuicServerInfo::~PropertiesBasedQuicServerInfo() {}
43 36
44 void PropertiesBasedQuicServerInfo::Start() { 37 bool PropertiesBasedQuicServerInfo::Load() {
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);
51 const string* data = http_server_properties_->GetQuicServerInfo(server_id_); 38 const string* data = http_server_properties_->GetQuicServerInfo(server_id_);
52 string decoded; 39 string decoded;
53 if (!data) { 40 if (!data) {
54 RecordQuicServerInfoFailure(PARSE_NO_DATA_FAILURE); 41 RecordQuicServerInfoFailure(PARSE_NO_DATA_FAILURE);
55 return ERR_FAILED; 42 return false;
56 } 43 }
57 if (!base::Base64Decode(*data, &decoded)) { 44 if (!base::Base64Decode(*data, &decoded)) {
58 RecordQuicServerInfoFailure(PARSE_DATA_DECODE_FAILURE); 45 RecordQuicServerInfoFailure(PARSE_DATA_DECODE_FAILURE);
59 return ERR_FAILED; 46 return false;
60 } 47 }
61 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_PARSE);
62 if (!Parse(decoded)) { 48 if (!Parse(decoded)) {
63 RecordQuicServerInfoFailure(PARSE_FAILURE); 49 RecordQuicServerInfoFailure(PARSE_FAILURE);
64 return ERR_FAILED; 50 return false;
65 } 51 }
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() {
78 return true; 52 return true;
79 } 53 }
80 54
81 bool PropertiesBasedQuicServerInfo::IsReadyToPersist() {
82 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_READY_TO_PERSIST);
83 return true;
84 }
85 55
86 void PropertiesBasedQuicServerInfo::Persist() { 56 void PropertiesBasedQuicServerInfo::Persist() {
87 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_PERSIST);
88 string encoded; 57 string encoded;
89 base::Base64Encode(Serialize(), &encoded); 58 base::Base64Encode(Serialize(), &encoded);
90 http_server_properties_->SetQuicServerInfo(server_id_, encoded); 59 http_server_properties_->SetQuicServerInfo(server_id_, encoded);
91 } 60 }
92 61
93 void PropertiesBasedQuicServerInfo::OnExternalCacheHit() {
94 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_EXTERNAL_CACHE_HIT);
95 }
96
97 size_t PropertiesBasedQuicServerInfo::EstimateMemoryUsage() const { 62 size_t PropertiesBasedQuicServerInfo::EstimateMemoryUsage() const {
98 return 0; 63 return 0;
99 } 64 }
100 65
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
114 } // namespace net 66 } // 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