summaryrefslogtreecommitdiffstats
path: root/net/base/host_port_pair.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 07:05:18 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 07:05:18 +0000
commitde95f929772cb7214efb747f9a5a115b27561336 (patch)
tree3f376123413c93b064eb65baf2643a407f6dfc7e /net/base/host_port_pair.cc
parent817925aaf716cb623c56e21030650f075e510157 (diff)
downloadchromium_src-de95f929772cb7214efb747f9a5a115b27561336.zip
chromium_src-de95f929772cb7214efb747f9a5a115b27561336.tar.gz
chromium_src-de95f929772cb7214efb747f9a5a115b27561336.tar.bz2
Persist Alternate-Protocol.
Record Alternate-Protocol servers in spdy.alternate_protocol. Don't persist broken Alternate-Protocol so they will retry on next browser session. Also fix listening to notifications when we're the ones setting them. This was leading to unnecessary double updates, where we'd update the cache on the IO thread, and then propagate to the UI thread, where we'd set the prefs, and then observe that change and propagate back to the IO thread to update the cache. BUG=98472 TEST=Observe that spdy.alternate_protocol is empty in your Preferences file. Confirm that there is no alternate-protocol mapping in chrome://net-internals/#spdy. Browse to www.strangeloopnetworks.com. Check chrome://net-internals/#spdy again and notice that it populates with the mapping. Wait some seconds and then check the Preferences file again and note that it got persisted to disk. Restart Chrome and check chrome://net-internals/#spdy and note that the same alternate-protocol mappings reappear. Review URL: http://codereview.chromium.org/8221030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105028 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/host_port_pair.cc')
-rw-r--r--net/base/host_port_pair.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/net/base/host_port_pair.cc b/net/base/host_port_pair.cc
index 5164fcf..773c7ee 100644
--- a/net/base/host_port_pair.cc
+++ b/net/base/host_port_pair.cc
@@ -1,9 +1,11 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/base/host_port_pair.h"
+#include "base/string_number_conversions.h"
+#include "base/string_split.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "googleurl/src/gurl.h"
@@ -27,6 +29,21 @@ HostPortPair HostPortPair::FromAddrInfo(const struct addrinfo* ai) {
GetPortFromSockaddr(ai->ai_addr, ai->ai_addrlen));
}
+HostPortPair HostPortPair::FromString(const std::string& str) {
+ std::vector<std::string> key_port;
+ base::SplitString(str, ':', &key_port);
+ if (key_port.size() != 2)
+ return HostPortPair();
+ int port;
+ if (!base::StringToInt(key_port[1], &port))
+ return HostPortPair();
+ DCHECK_LT(port, 1 << 16);
+ HostPortPair host_port_pair;
+ host_port_pair.set_host(key_port[0]);
+ host_port_pair.set_port(port);
+ return host_port_pair;
+}
+
std::string HostPortPair::ToString() const {
return base::StringPrintf("%s:%u", HostForURL().c_str(), port_);
}