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

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

Issue 1523543002: SPDY Servers - Servers that are restored from preferences maintain MRU order (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mru_cache_swap
Patch Set: rebase Created 5 years 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
« no previous file with comments | « no previous file | net/http/http_server_properties_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 29 matching lines...) Expand all
40 40
41 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { 41 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() {
42 } 42 }
43 43
44 void HttpServerPropertiesImpl::InitializeSpdyServers( 44 void HttpServerPropertiesImpl::InitializeSpdyServers(
45 std::vector<std::string>* spdy_servers, 45 std::vector<std::string>* spdy_servers,
46 bool support_spdy) { 46 bool support_spdy) {
47 DCHECK(CalledOnValidThread()); 47 DCHECK(CalledOnValidThread());
48 if (!spdy_servers) 48 if (!spdy_servers)
49 return; 49 return;
50
50 // Add the entries from persisted data. 51 // Add the entries from persisted data.
52 SpdyServerHostPortMap spdy_servers_map(SpdyServerHostPortMap::NO_AUTO_EVICT);
51 for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin(); 53 for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin();
52 it != spdy_servers->rend(); ++it) { 54 it != spdy_servers->rend(); ++it) {
53 spdy_servers_map_.Put(*it, support_spdy); 55 spdy_servers_map.Put(*it, support_spdy);
56 }
57
58 // |spdy_servers_map| will have the memory cache.
59 spdy_servers_map_.Swap(spdy_servers_map);
60
61 // Add the entries from the memory cache.
62 for (SpdyServerHostPortMap::reverse_iterator it = spdy_servers_map.rbegin();
63 it != spdy_servers_map.rend(); ++it) {
64 // Add the entry if it is not in the cache, otherwise move it to the front
65 // of recency list.
66 if (spdy_servers_map_.Get(it->first) == spdy_servers_map_.end())
67 spdy_servers_map_.Put(it->first, it->second);
54 } 68 }
55 } 69 }
56 70
57 void HttpServerPropertiesImpl::InitializeAlternativeServiceServers( 71 void HttpServerPropertiesImpl::InitializeAlternativeServiceServers(
58 AlternativeServiceMap* alternative_service_map) { 72 AlternativeServiceMap* alternative_service_map) {
59 // Add the entries from persisted data. 73 // Add the entries from persisted data.
60 for (AlternativeServiceMap::reverse_iterator input_it = 74 for (AlternativeServiceMap::reverse_iterator input_it =
61 alternative_service_map->rbegin(); 75 alternative_service_map->rbegin();
62 input_it != alternative_service_map->rend(); ++input_it) { 76 input_it != alternative_service_map->rend(); ++input_it) {
63 DCHECK(!input_it->second.empty()); 77 DCHECK(!input_it->second.empty());
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); 732 base::TimeDelta delay = when > now ? when - now : base::TimeDelta();
719 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 733 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
720 FROM_HERE, 734 FROM_HERE,
721 base::Bind( 735 base::Bind(
722 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, 736 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings,
723 weak_ptr_factory_.GetWeakPtr()), 737 weak_ptr_factory_.GetWeakPtr()),
724 delay); 738 delay);
725 } 739 }
726 740
727 } // namespace net 741 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_server_properties_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698