| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/quic/crypto/properties_based_quic_server_info.h" | |
| 6 | |
| 7 #include "base/base64.h" | |
| 8 #include "net/base/net_errors.h" | |
| 9 #include "net/http/http_server_properties.h" | |
| 10 | |
| 11 using std::string; | |
| 12 | |
| 13 namespace net { | |
| 14 | |
| 15 PropertiesBasedQuicServerInfo::PropertiesBasedQuicServerInfo( | |
| 16 const QuicServerId& server_id, | |
| 17 HttpServerProperties* http_server_properties) | |
| 18 : QuicServerInfo(server_id), | |
| 19 http_server_properties_(http_server_properties) { | |
| 20 DCHECK(http_server_properties_); | |
| 21 } | |
| 22 | |
| 23 PropertiesBasedQuicServerInfo::~PropertiesBasedQuicServerInfo() {} | |
| 24 | |
| 25 void PropertiesBasedQuicServerInfo::Start() {} | |
| 26 | |
| 27 int PropertiesBasedQuicServerInfo::WaitForDataReady( | |
| 28 const CompletionCallback& callback) { | |
| 29 const string* data = http_server_properties_->GetQuicServerInfo(server_id_); | |
| 30 string decoded; | |
| 31 if (!data || !base::Base64Decode(*data, &decoded) || !Parse(decoded)) { | |
| 32 return ERR_FAILED; | |
| 33 } | |
| 34 return OK; | |
| 35 } | |
| 36 | |
| 37 void PropertiesBasedQuicServerInfo::ResetWaitForDataReadyCallback() {} | |
| 38 | |
| 39 void PropertiesBasedQuicServerInfo::CancelWaitForDataReadyCallback() {} | |
| 40 | |
| 41 bool PropertiesBasedQuicServerInfo::IsDataReady() { | |
| 42 return true; | |
| 43 } | |
| 44 | |
| 45 bool PropertiesBasedQuicServerInfo::IsReadyToPersist() { | |
| 46 return true; | |
| 47 } | |
| 48 | |
| 49 void PropertiesBasedQuicServerInfo::Persist() { | |
| 50 string encoded; | |
| 51 base::Base64Encode(Serialize(), &encoded); | |
| 52 http_server_properties_->SetQuicServerInfo(server_id_, encoded); | |
| 53 } | |
| 54 | |
| 55 void PropertiesBasedQuicServerInfo::OnExternalCacheHit() {} | |
| 56 | |
| 57 PropertiesBasedQuicServerInfoFactory::PropertiesBasedQuicServerInfoFactory( | |
| 58 HttpServerProperties* http_server_properties) | |
| 59 : http_server_properties_(http_server_properties) {} | |
| 60 | |
| 61 PropertiesBasedQuicServerInfoFactory::~PropertiesBasedQuicServerInfoFactory() {} | |
| 62 | |
| 63 QuicServerInfo* PropertiesBasedQuicServerInfoFactory::GetForServer( | |
| 64 const QuicServerId& server_id) { | |
| 65 return new PropertiesBasedQuicServerInfo(server_id, http_server_properties_); | |
| 66 } | |
| 67 | |
| 68 } // namespace net | |
| OLD | NEW |