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

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

Issue 2171743002: Do not persist HttpServerProperties to disk that often. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re: #7. Created 4 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_impl.h" 5 #include "net/http/http_server_properties_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 return false; 406 return false;
407 407
408 alternative_service_map_.Erase(it); 408 alternative_service_map_.Erase(it);
409 return true; 409 return true;
410 } 410 }
411 411
412 bool changed = true; 412 bool changed = true;
413 if (it != alternative_service_map_.end()) { 413 if (it != alternative_service_map_.end()) {
414 DCHECK(!it->second.empty()); 414 DCHECK(!it->second.empty());
415 if (it->second.size() == alternative_service_info_vector.size()) { 415 if (it->second.size() == alternative_service_info_vector.size()) {
416 changed = !std::equal(it->second.begin(), it->second.end(), 416 changed = false;
417 alternative_service_info_vector.begin()); 417 auto new_it = alternative_service_info_vector.begin();
418 for (const auto& old : it->second) {
419 // Persist to disk immediately if new entry has different scheme, host,
420 // or port, or if it expires sooner.
421 if (old.alternative_service != new_it->alternative_service ||
422 old.expiration > new_it->expiration) {
423 changed = true;
424 break;
425 }
426 ++new_it;
427 }
418 } 428 }
419 } 429 }
420 430
421 const bool previously_no_alternative_services = 431 const bool previously_no_alternative_services =
422 (GetAlternateProtocolIterator(origin) == alternative_service_map_.end()); 432 (GetAlternateProtocolIterator(origin) == alternative_service_map_.end());
423 433
424 alternative_service_map_.Put(origin, alternative_service_info_vector); 434 alternative_service_map_.Put(origin, alternative_service_info_vector);
425 435
426 if (previously_no_alternative_services && 436 if (previously_no_alternative_services &&
427 !GetAlternativeServices(origin).empty()) { 437 !GetAlternativeServices(origin).empty()) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 789 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
780 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 790 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
781 FROM_HERE, 791 FROM_HERE,
782 base::Bind( 792 base::Bind(
783 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, 793 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings,
784 weak_ptr_factory_.GetWeakPtr()), 794 weak_ptr_factory_.GetWeakPtr()),
785 delay); 795 delay);
786 } 796 }
787 797
788 } // namespace net 798 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698