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

Side by Side Diff: net/http/http_server_properties_manager.cc

Issue 2496953002: Revert of Unify enum NextProto and enum AlternateProtocol. (Closed)
Patch Set: Created 4 years, 1 month 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 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/http_server_properties_manager.h" 5 #include "net/http/http_server_properties_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 const std::string& server_str, 625 const std::string& server_str,
626 AlternativeServiceInfo* alternative_service_info) { 626 AlternativeServiceInfo* alternative_service_info) {
627 // Protocol is mandatory. 627 // Protocol is mandatory.
628 std::string protocol_str; 628 std::string protocol_str;
629 if (!alternative_service_dict.GetStringWithoutPathExpansion(kProtocolKey, 629 if (!alternative_service_dict.GetStringWithoutPathExpansion(kProtocolKey,
630 &protocol_str)) { 630 &protocol_str)) {
631 DVLOG(1) << "Malformed alternative service protocol string for server: " 631 DVLOG(1) << "Malformed alternative service protocol string for server: "
632 << server_str; 632 << server_str;
633 return false; 633 return false;
634 } 634 }
635 NextProto protocol = NextProtoFromString(protocol_str); 635 AlternateProtocol protocol = AlternateProtocolFromString(protocol_str);
636 if (!IsAlternateProtocolValid(protocol)) { 636 if (!IsAlternateProtocolValid(protocol)) {
637 DVLOG(1) << "Invalid alternative service protocol string for server: " 637 DVLOG(1) << "Invalid alternative service protocol string for server: "
638 << server_str; 638 << server_str;
639 return false; 639 return false;
640 } 640 }
641 alternative_service_info->alternative_service.protocol = protocol; 641 alternative_service_info->alternative_service.protocol = protocol;
642 642
643 // Host is optional, defaults to "". 643 // Host is optional, defaults to "".
644 alternative_service_info->alternative_service.host.clear(); 644 alternative_service_info->alternative_service.host.clear();
645 if (alternative_service_dict.HasKey(kHostKey) && 645 if (alternative_service_dict.HasKey(kHostKey) &&
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 const AlternativeService alternative_service = 1182 const AlternativeService alternative_service =
1183 alternative_service_info.alternative_service; 1183 alternative_service_info.alternative_service;
1184 DCHECK(IsAlternateProtocolValid(alternative_service.protocol)); 1184 DCHECK(IsAlternateProtocolValid(alternative_service.protocol));
1185 std::unique_ptr<base::DictionaryValue> alternative_service_dict( 1185 std::unique_ptr<base::DictionaryValue> alternative_service_dict(
1186 new base::DictionaryValue); 1186 new base::DictionaryValue);
1187 alternative_service_dict->SetInteger(kPortKey, alternative_service.port); 1187 alternative_service_dict->SetInteger(kPortKey, alternative_service.port);
1188 if (!alternative_service.host.empty()) { 1188 if (!alternative_service.host.empty()) {
1189 alternative_service_dict->SetString(kHostKey, alternative_service.host); 1189 alternative_service_dict->SetString(kHostKey, alternative_service.host);
1190 } 1190 }
1191 alternative_service_dict->SetString( 1191 alternative_service_dict->SetString(
1192 kProtocolKey, NextProtoToString(alternative_service.protocol)); 1192 kProtocolKey, AlternateProtocolToString(alternative_service.protocol));
1193 // JSON cannot store int64_t, so expiration is converted to a string. 1193 // JSON cannot store int64_t, so expiration is converted to a string.
1194 alternative_service_dict->SetString( 1194 alternative_service_dict->SetString(
1195 kExpirationKey, 1195 kExpirationKey,
1196 base::Int64ToString( 1196 base::Int64ToString(
1197 alternative_service_info.expiration.ToInternalValue())); 1197 alternative_service_info.expiration.ToInternalValue()));
1198 alternative_service_list->Append(std::move(alternative_service_dict)); 1198 alternative_service_list->Append(std::move(alternative_service_dict));
1199 } 1199 }
1200 if (alternative_service_list->GetSize() == 0) 1200 if (alternative_service_list->GetSize() == 0)
1201 return; 1201 return;
1202 server_pref_dict->SetWithoutPathExpansion(kAlternativeServiceKey, 1202 server_pref_dict->SetWithoutPathExpansion(kAlternativeServiceKey,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 quic_servers_dict); 1252 quic_servers_dict);
1253 } 1253 }
1254 1254
1255 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { 1255 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() {
1256 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); 1256 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread());
1257 if (!setting_prefs_) 1257 if (!setting_prefs_)
1258 ScheduleUpdateCacheOnPrefThread(); 1258 ScheduleUpdateCacheOnPrefThread();
1259 } 1259 }
1260 1260
1261 } // namespace net 1261 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_impl_unittest.cc ('k') | net/http/http_server_properties_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698