Display more information at chrome://net-internals/#spdy
In particular, list the mapping from host:port to port:alternate-protocol and the global spdy configuration state. BUG=none TEST=chrome://net-internals/#spdy Review URL: http://codereview.chromium.org/6465001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74355 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
chrome/browser
net/http
@@ -44,7 +44,9 @@
|
|||||||
#include "net/base/net_util.h"
|
#include "net/base/net_util.h"
|
||||||
#include "net/base/sys_addrinfo.h"
|
#include "net/base/sys_addrinfo.h"
|
||||||
#include "net/disk_cache/disk_cache.h"
|
#include "net/disk_cache/disk_cache.h"
|
||||||
|
#include "net/http/http_alternate_protocols.h"
|
||||||
#include "net/http/http_cache.h"
|
#include "net/http/http_cache.h"
|
||||||
|
#include "net/http/http_stream_factory.h"
|
||||||
#include "net/http/http_network_layer.h"
|
#include "net/http/http_network_layer.h"
|
||||||
#include "net/http/http_network_session.h"
|
#include "net/http/http_network_session.h"
|
||||||
#include "net/proxy/proxy_service.h"
|
#include "net/proxy/proxy_service.h"
|
||||||
@@ -256,6 +258,8 @@ class NetInternalsMessageHandler::IOThreadImpl
|
|||||||
void OnGetHttpCacheInfo(const ListValue* list);
|
void OnGetHttpCacheInfo(const ListValue* list);
|
||||||
void OnGetSocketPoolInfo(const ListValue* list);
|
void OnGetSocketPoolInfo(const ListValue* list);
|
||||||
void OnGetSpdySessionInfo(const ListValue* list);
|
void OnGetSpdySessionInfo(const ListValue* list);
|
||||||
|
void OnGetSpdyStatus(const ListValue* list);
|
||||||
|
void OnGetSpdyAlternateProtocolMappings(const ListValue* list);
|
||||||
#ifdef OS_WIN
|
#ifdef OS_WIN
|
||||||
void OnGetServiceProviders(const ListValue* list);
|
void OnGetServiceProviders(const ListValue* list);
|
||||||
#endif
|
#endif
|
||||||
@@ -511,6 +515,13 @@ void NetInternalsMessageHandler::RegisterMessages() {
|
|||||||
dom_ui_->RegisterMessageCallback(
|
dom_ui_->RegisterMessageCallback(
|
||||||
"getSpdySessionInfo",
|
"getSpdySessionInfo",
|
||||||
proxy_->CreateCallback(&IOThreadImpl::OnGetSpdySessionInfo));
|
proxy_->CreateCallback(&IOThreadImpl::OnGetSpdySessionInfo));
|
||||||
|
dom_ui_->RegisterMessageCallback(
|
||||||
|
"getSpdyStatus",
|
||||||
|
proxy_->CreateCallback(&IOThreadImpl::OnGetSpdyStatus));
|
||||||
|
dom_ui_->RegisterMessageCallback(
|
||||||
|
"getSpdyAlternateProtocolMappings",
|
||||||
|
proxy_->CreateCallback(
|
||||||
|
&IOThreadImpl::OnGetSpdyAlternateProtocolMappings));
|
||||||
#ifdef OS_WIN
|
#ifdef OS_WIN
|
||||||
dom_ui_->RegisterMessageCallback(
|
dom_ui_->RegisterMessageCallback(
|
||||||
"getServiceProviders",
|
"getServiceProviders",
|
||||||
@@ -991,6 +1002,57 @@ void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdySessionInfo(
|
|||||||
CallJavascriptFunction(L"g_browser.receivedSpdySessionInfo", spdy_info);
|
CallJavascriptFunction(L"g_browser.receivedSpdySessionInfo", spdy_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyStatus(
|
||||||
|
const ListValue* list) {
|
||||||
|
DictionaryValue* status_dict = new DictionaryValue();
|
||||||
|
|
||||||
|
status_dict->Set("spdy_enabled",
|
||||||
|
Value::CreateBooleanValue(
|
||||||
|
net::HttpStreamFactory::spdy_enabled()));
|
||||||
|
status_dict->Set("use_alternate_protocols",
|
||||||
|
Value::CreateBooleanValue(
|
||||||
|
net::HttpStreamFactory::use_alternate_protocols()));
|
||||||
|
status_dict->Set("force_spdy_over_ssl",
|
||||||
|
Value::CreateBooleanValue(
|
||||||
|
net::HttpStreamFactory::force_spdy_over_ssl()));
|
||||||
|
status_dict->Set("force_spdy_always",
|
||||||
|
Value::CreateBooleanValue(
|
||||||
|
net::HttpStreamFactory::force_spdy_always()));
|
||||||
|
status_dict->Set("next_protos",
|
||||||
|
Value::CreateStringValue(
|
||||||
|
*net::HttpStreamFactory::next_protos()));
|
||||||
|
|
||||||
|
CallJavascriptFunction(L"g_browser.receivedSpdyStatus", status_dict);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyAlternateProtocolMappings(
|
||||||
|
const ListValue* list) {
|
||||||
|
net::HttpNetworkSession* http_network_session =
|
||||||
|
GetHttpNetworkSession(context_getter_->GetURLRequestContext());
|
||||||
|
|
||||||
|
ListValue* dict_list = new ListValue();
|
||||||
|
|
||||||
|
if (http_network_session) {
|
||||||
|
const net::HttpAlternateProtocols& http_alternate_protocols =
|
||||||
|
http_network_session->alternate_protocols();
|
||||||
|
const net::HttpAlternateProtocols::ProtocolMap& map =
|
||||||
|
http_alternate_protocols.protocol_map();
|
||||||
|
|
||||||
|
for (net::HttpAlternateProtocols::ProtocolMap::const_iterator it =
|
||||||
|
map.begin();
|
||||||
|
it != map.end(); ++it) {
|
||||||
|
DictionaryValue* dict = new DictionaryValue();
|
||||||
|
dict->SetString("host_port_pair", it->first.ToString());
|
||||||
|
dict->SetString("alternate_protocol", it->second.ToString());
|
||||||
|
dict_list->Append(dict);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CallJavascriptFunction(L"g_browser.receivedSpdyAlternateProtocolMappings",
|
||||||
|
dict_list);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef OS_WIN
|
#ifdef OS_WIN
|
||||||
void NetInternalsMessageHandler::IOThreadImpl::OnGetServiceProviders(
|
void NetInternalsMessageHandler::IOThreadImpl::OnGetServiceProviders(
|
||||||
const ListValue* list) {
|
const ListValue* list) {
|
||||||
|
@@ -268,6 +268,20 @@ DataView.prototype.onUpdateAllCompleted = function(data) {
|
|||||||
|
|
||||||
this.appendSocketPoolsAsText_(text, data.socketPoolInfo);
|
this.appendSocketPoolsAsText_(text, data.socketPoolInfo);
|
||||||
|
|
||||||
|
text.push('');
|
||||||
|
text.push('----------------------------------------------');
|
||||||
|
text.push(' SPDY Status');
|
||||||
|
text.push('----------------------------------------------');
|
||||||
|
text.push('');
|
||||||
|
|
||||||
|
text.push('SPDY Enabled: ' + data.spdyStatus.spdy_enabled);
|
||||||
|
text.push('Use Alternate Protocol: ' +
|
||||||
|
data.spdyStatus.use_alternate_protocols);
|
||||||
|
text.push('Force SPDY Always: ' + data.spdyStatus.force_spdy_always);
|
||||||
|
text.push('Force SPDY Over SSL: ' + data.spdyStatus.force_spdy_over_ssl);
|
||||||
|
text.push('Next Protocols: ' + data.spdyStatus.next_protos);
|
||||||
|
|
||||||
|
|
||||||
text.push('');
|
text.push('');
|
||||||
text.push('----------------------------------------------');
|
text.push('----------------------------------------------');
|
||||||
text.push(' SPDY Sessions');
|
text.push(' SPDY Sessions');
|
||||||
@@ -282,6 +296,22 @@ DataView.prototype.onUpdateAllCompleted = function(data) {
|
|||||||
text.push(spdyTablePrinter.toText(2));
|
text.push(spdyTablePrinter.toText(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text.push('');
|
||||||
|
text.push('----------------------------------------------');
|
||||||
|
text.push(' Alternate Protocol Mappings');
|
||||||
|
text.push('----------------------------------------------');
|
||||||
|
text.push('');
|
||||||
|
|
||||||
|
if (data.spdyAlternateProtocolMappings == null ||
|
||||||
|
data.spdyAlternateProtocolMappings.length == 0) {
|
||||||
|
text.push('None');
|
||||||
|
} else {
|
||||||
|
var spdyTablePrinter =
|
||||||
|
SpdyView.createAlternateProtocolMappingsTablePrinter(
|
||||||
|
data.spdyAlternateProtocolMappings);
|
||||||
|
text.push(spdyTablePrinter.toText(2));
|
||||||
|
}
|
||||||
|
|
||||||
if (g_browser.isPlatformWindows()) {
|
if (g_browser.isPlatformWindows()) {
|
||||||
text.push('');
|
text.push('');
|
||||||
text.push('----------------------------------------------');
|
text.push('----------------------------------------------');
|
||||||
|
@@ -147,6 +147,15 @@ found in the LICENSE file.
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div id=spdyTabContent>
|
<div id=spdyTabContent>
|
||||||
|
<h4>SPDY Status</h4>
|
||||||
|
<ul>
|
||||||
|
<li>SPDY Enabled: <span id=spdyEnabledSpan>????</span></li>
|
||||||
|
<li>Use Alternate Protocol: <span id=spdyUseAlternateProtocolSpan>????</span></li>
|
||||||
|
<li>Force SPDY Always: <span id=spdyForceAlwaysSpan>????</span></li>
|
||||||
|
<li>Force SPDY Over SSL: <span id=spdyForceOverSslSpan>????</span></li>
|
||||||
|
<li>Next Protocols: <span id=spdyNextProtocolsSpan>????</span></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<h4>SPDY sessions</h4>
|
<h4>SPDY sessions</h4>
|
||||||
<!-- Only one of these two are shown -->
|
<!-- Only one of these two are shown -->
|
||||||
<span id=spdySessionNoneSpan>None</span>
|
<span id=spdySessionNoneSpan>None</span>
|
||||||
@@ -157,6 +166,11 @@ found in the LICENSE file.
|
|||||||
<div id=spdySessionDiv>
|
<div id=spdySessionDiv>
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h4>Alternate Protocol Mappings</h4>
|
||||||
|
<p />
|
||||||
|
<div id=spdyAlternateProtocolMappingsDiv>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id=httpCacheTabContent>
|
<div id=httpCacheTabContent>
|
||||||
<h4>Entries</h4>
|
<h4>Entries</h4>
|
||||||
|
@@ -95,11 +95,16 @@ function onLoaded() {
|
|||||||
'socketPoolGroupsDiv');
|
'socketPoolGroupsDiv');
|
||||||
|
|
||||||
var spdyView = new SpdyView('spdyTabContent',
|
var spdyView = new SpdyView('spdyTabContent',
|
||||||
|
'spdyEnabledSpan',
|
||||||
|
'spdyUseAlternateProtocolSpan',
|
||||||
|
'spdyForceAlwaysSpan',
|
||||||
|
'spdyForceOverSslSpan',
|
||||||
|
'spdyNextProtocolsSpan',
|
||||||
|
'spdyAlternateProtocolMappingsDiv',
|
||||||
'spdySessionNoneSpan',
|
'spdySessionNoneSpan',
|
||||||
'spdySessionLinkSpan',
|
'spdySessionLinkSpan',
|
||||||
'spdySessionDiv');
|
'spdySessionDiv');
|
||||||
|
|
||||||
|
|
||||||
var serviceView;
|
var serviceView;
|
||||||
if (g_browser.isPlatformWindows()) {
|
if (g_browser.isPlatformWindows()) {
|
||||||
serviceView = new ServiceProvidersView('serviceProvidersTab',
|
serviceView = new ServiceProvidersView('serviceProvidersTab',
|
||||||
@@ -184,6 +189,13 @@ function BrowserBridge() {
|
|||||||
this.pollableDataHelpers_.spdySessionInfo =
|
this.pollableDataHelpers_.spdySessionInfo =
|
||||||
new PollableDataHelper('onSpdySessionInfoChanged',
|
new PollableDataHelper('onSpdySessionInfoChanged',
|
||||||
this.sendGetSpdySessionInfo.bind(this));
|
this.sendGetSpdySessionInfo.bind(this));
|
||||||
|
this.pollableDataHelpers_.spdyStatus =
|
||||||
|
new PollableDataHelper('onSpdyStatusChanged',
|
||||||
|
this.sendGetSpdyStatus.bind(this));
|
||||||
|
this.pollableDataHelpers_.spdyAlternateProtocolMappings =
|
||||||
|
new PollableDataHelper('onSpdyAlternateProtocolMappingsChanged',
|
||||||
|
this.sendGetSpdyAlternateProtocolMappings.bind(
|
||||||
|
this));
|
||||||
if (this.isPlatformWindows()) {
|
if (this.isPlatformWindows()) {
|
||||||
this.pollableDataHelpers_.serviceProviders =
|
this.pollableDataHelpers_.serviceProviders =
|
||||||
new PollableDataHelper('onServiceProvidersChanged',
|
new PollableDataHelper('onServiceProvidersChanged',
|
||||||
@@ -301,6 +313,14 @@ BrowserBridge.prototype.sendGetSpdySessionInfo = function() {
|
|||||||
chrome.send('getSpdySessionInfo');
|
chrome.send('getSpdySessionInfo');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BrowserBridge.prototype.sendGetSpdyStatus = function() {
|
||||||
|
chrome.send('getSpdyStatus');
|
||||||
|
};
|
||||||
|
|
||||||
|
BrowserBridge.prototype.sendGetSpdyAlternateProtocolMappings = function() {
|
||||||
|
chrome.send('getSpdyAlternateProtocolMappings');
|
||||||
|
};
|
||||||
|
|
||||||
BrowserBridge.prototype.sendGetServiceProviders = function() {
|
BrowserBridge.prototype.sendGetServiceProviders = function() {
|
||||||
chrome.send('getServiceProviders');
|
chrome.send('getServiceProviders');
|
||||||
};
|
};
|
||||||
@@ -390,6 +410,16 @@ BrowserBridge.prototype.receivedSpdySessionInfo = function(spdySessionInfo) {
|
|||||||
this.pollableDataHelpers_.spdySessionInfo.update(spdySessionInfo);
|
this.pollableDataHelpers_.spdySessionInfo.update(spdySessionInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BrowserBridge.prototype.receivedSpdyStatus = function(spdyStatus) {
|
||||||
|
this.pollableDataHelpers_.spdyStatus.update(spdyStatus);
|
||||||
|
};
|
||||||
|
|
||||||
|
BrowserBridge.prototype.receivedSpdyAlternateProtocolMappings =
|
||||||
|
function(spdyAlternateProtocolMappings) {
|
||||||
|
this.pollableDataHelpers_.spdyAlternateProtocolMappings.update(
|
||||||
|
spdyAlternateProtocolMappings);
|
||||||
|
};
|
||||||
|
|
||||||
BrowserBridge.prototype.receivedServiceProviders = function(serviceProviders) {
|
BrowserBridge.prototype.receivedServiceProviders = function(serviceProviders) {
|
||||||
this.pollableDataHelpers_.serviceProviders.update(serviceProviders);
|
this.pollableDataHelpers_.serviceProviders.update(serviceProviders);
|
||||||
};
|
};
|
||||||
@@ -608,6 +638,28 @@ BrowserBridge.prototype.addSpdySessionInfoObserver = function(observer) {
|
|||||||
this.pollableDataHelpers_.spdySessionInfo.addObserver(observer);
|
this.pollableDataHelpers_.spdySessionInfo.addObserver(observer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a listener of the SPDY status. |observer| will be called back
|
||||||
|
* when data is received, through:
|
||||||
|
*
|
||||||
|
* observer.onSpdyStatusChanged(spdyStatus)
|
||||||
|
*/
|
||||||
|
BrowserBridge.prototype.addSpdyStatusObserver = function(observer) {
|
||||||
|
this.pollableDataHelpers_.spdyStatus.addObserver(observer);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a listener of the AlternateProtocolMappings. |observer| will be called
|
||||||
|
* back when data is received, through:
|
||||||
|
*
|
||||||
|
* observer.onSpdyAlternateProtocolMappingsChanged(
|
||||||
|
* spdyAlternateProtocolMappings)
|
||||||
|
*/
|
||||||
|
BrowserBridge.prototype.addSpdyAlternateProtocolMappingsObserver =
|
||||||
|
function(observer) {
|
||||||
|
this.pollableDataHelpers_.spdyAlternateProtocolMappings.addObserver(observer);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a listener of the service providers info. |observer| will be called
|
* Adds a listener of the service providers info. |observer| will be called
|
||||||
* back when data is received, through:
|
* back when data is received, through:
|
||||||
|
@@ -8,11 +8,27 @@
|
|||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function SpdyView(mainBoxId, spdySessionNoneSpanId, spdySessionLinkSpanId,
|
function SpdyView(mainBoxId, spdyEnabledSpanId,
|
||||||
|
spdyUseAlternateProtocolSpanId,
|
||||||
|
spdyForceAlwaysSpanId, spdyForceOverSslSpanId,
|
||||||
|
spdyNextProtocolsSpanId, spdyAlternateProtocolMappingsDivId,
|
||||||
|
spdySessionNoneSpanId, spdySessionLinkSpanId,
|
||||||
spdySessionDivId) {
|
spdySessionDivId) {
|
||||||
DivView.call(this, mainBoxId);
|
DivView.call(this, mainBoxId);
|
||||||
g_browser.addSpdySessionInfoObserver(this);
|
g_browser.addSpdySessionInfoObserver(this);
|
||||||
|
g_browser.addSpdyStatusObserver(this);
|
||||||
|
g_browser.addSpdyAlternateProtocolMappingsObserver(this);
|
||||||
|
|
||||||
|
this.spdyEnabledSpan_ = document.getElementById(spdyEnabledSpanId);
|
||||||
|
this.spdyUseAlternateProtocolSpan_ =
|
||||||
|
document.getElementById(spdyUseAlternateProtocolSpanId);
|
||||||
|
this.spdyForceAlwaysSpan_ = document.getElementById(spdyForceAlwaysSpanId);
|
||||||
|
this.spdyForceOverSslSpan_ = document.getElementById(spdyForceOverSslSpanId);
|
||||||
|
this.spdyNextProtocolsSpan_ =
|
||||||
|
document.getElementById(spdyNextProtocolsSpanId);
|
||||||
|
|
||||||
|
this.spdyAlternateProtocolMappingsDiv_ =
|
||||||
|
document.getElementById(spdyAlternateProtocolMappingsDivId);
|
||||||
this.spdySessionNoneSpan_ = document.getElementById(spdySessionNoneSpanId);
|
this.spdySessionNoneSpan_ = document.getElementById(spdySessionNoneSpanId);
|
||||||
this.spdySessionLinkSpan_ = document.getElementById(spdySessionLinkSpanId);
|
this.spdySessionLinkSpan_ = document.getElementById(spdySessionLinkSpanId);
|
||||||
this.spdySessionDiv_ = document.getElementById(spdySessionDivId);
|
this.spdySessionDiv_ = document.getElementById(spdySessionDivId);
|
||||||
@@ -36,6 +52,39 @@ SpdyView.prototype.onSpdySessionInfoChanged = function(spdySessionInfo) {
|
|||||||
|
|
||||||
var tablePrinter = SpdyView.createSessionTablePrinter(spdySessionInfo);
|
var tablePrinter = SpdyView.createSessionTablePrinter(spdySessionInfo);
|
||||||
tablePrinter.toHTML(this.spdySessionDiv_, 'styledTable');
|
tablePrinter.toHTML(this.spdySessionDiv_, 'styledTable');
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays information on the global SPDY status.
|
||||||
|
*/
|
||||||
|
SpdyView.prototype.onSpdyStatusChanged = function(spdyStatus) {
|
||||||
|
this.spdyEnabledSpan_.innerText = spdyStatus.spdy_enabled;
|
||||||
|
this.spdyUseAlternateProtocolSpan_.innerText =
|
||||||
|
spdyStatus.use_alternate_protocols;
|
||||||
|
this.spdyForceAlwaysSpan_.innerText = spdyStatus.force_spdy_always;
|
||||||
|
this.spdyForceOverSslSpan_.innerText = spdyStatus.force_spdy_over_ssl;
|
||||||
|
this.spdyNextProtocolsSpan_.innerText = spdyStatus.next_protos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If |spdyAlternateProtocolMappings| is not empty, displays a single table
|
||||||
|
* with information on each alternate protocol enabled server. Otherwise,
|
||||||
|
* displays "None".
|
||||||
|
*/
|
||||||
|
SpdyView.prototype.onSpdyAlternateProtocolMappingsChanged =
|
||||||
|
function(spdyAlternateProtocolMappings) {
|
||||||
|
|
||||||
|
this.spdyAlternateProtocolMappingsDiv_.innerHTML = '';
|
||||||
|
|
||||||
|
if (spdyAlternateProtocolMappings != null &&
|
||||||
|
spdyAlternateProtocolMappings.length > 0) {
|
||||||
|
var tabPrinter = SpdyView.createAlternateProtocolMappingsTablePrinter(
|
||||||
|
spdyAlternateProtocolMappings);
|
||||||
|
tabPrinter.toHTML(this.spdyAlternateProtocolMappingsDiv_, 'styledTable');
|
||||||
|
} else {
|
||||||
|
this.spdyAlternateProtocolMappingsDiv_.innerHTML = 'None';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,3 +134,24 @@ SpdyView.createSessionTablePrinter = function(spdySessions) {
|
|||||||
return tablePrinter;
|
return tablePrinter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a table printer to print out the list of alternate protocol
|
||||||
|
* mappings.
|
||||||
|
*/
|
||||||
|
SpdyView.createAlternateProtocolMappingsTablePrinter =
|
||||||
|
function(spdyAlternateProtocolMappings) {
|
||||||
|
var tablePrinter = new TablePrinter();
|
||||||
|
tablePrinter.addHeaderCell('Host');
|
||||||
|
tablePrinter.addHeaderCell('Alternate Protocol');
|
||||||
|
|
||||||
|
for (var i = 0; i < spdyAlternateProtocolMappings.length; i++) {
|
||||||
|
var entry = spdyAlternateProtocolMappings[i];
|
||||||
|
tablePrinter.addRow();
|
||||||
|
|
||||||
|
tablePrinter.addCell(entry.host_port_pair);
|
||||||
|
tablePrinter.addCell(entry.alternate_protocol);
|
||||||
|
}
|
||||||
|
return tablePrinter;
|
||||||
|
};
|
||||||
|
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
#include "net/http/http_alternate_protocols.h"
|
#include "net/http/http_alternate_protocols.h"
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/stringprintf.h"
|
||||||
#include "base/stl_util-inl.h"
|
#include "base/stl_util-inl.h"
|
||||||
|
|
||||||
namespace net {
|
namespace net {
|
||||||
@@ -15,6 +16,28 @@ const char* const HttpAlternateProtocols::kProtocolStrings[] = {
|
|||||||
"npn-spdy/2",
|
"npn-spdy/2",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char* HttpAlternateProtocols::ProtocolToString(
|
||||||
|
HttpAlternateProtocols::Protocol protocol) {
|
||||||
|
switch (protocol) {
|
||||||
|
case HttpAlternateProtocols::NPN_SPDY_1:
|
||||||
|
case HttpAlternateProtocols::NPN_SPDY_2:
|
||||||
|
return HttpAlternateProtocols::kProtocolStrings[protocol];
|
||||||
|
case HttpAlternateProtocols::BROKEN:
|
||||||
|
return "Broken";
|
||||||
|
case HttpAlternateProtocols::UNINITIALIZED:
|
||||||
|
return "Uninitialized";
|
||||||
|
default:
|
||||||
|
NOTREACHED();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string HttpAlternateProtocols::PortProtocolPair::ToString() const {
|
||||||
|
return base::StringPrintf("%d:%s", port,
|
||||||
|
HttpAlternateProtocols::ProtocolToString(protocol));
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
HttpAlternateProtocols::PortProtocolPair*
|
HttpAlternateProtocols::PortProtocolPair*
|
||||||
HttpAlternateProtocols::forced_alternate_protocol_ = NULL;
|
HttpAlternateProtocols::forced_alternate_protocol_ = NULL;
|
||||||
|
@@ -34,10 +34,14 @@ class HttpAlternateProtocols {
|
|||||||
return port == other.port && protocol == other.protocol;
|
return port == other.port && protocol == other.protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ToString() const;
|
||||||
|
|
||||||
uint16 port;
|
uint16 port;
|
||||||
Protocol protocol;
|
Protocol protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef std::map<HostPortPair, PortProtocolPair> ProtocolMap;
|
||||||
|
|
||||||
static const char kHeader[];
|
static const char kHeader[];
|
||||||
static const char* const kProtocolStrings[NUM_ALTERNATE_PROTOCOLS];
|
static const char* const kProtocolStrings[NUM_ALTERNATE_PROTOCOLS];
|
||||||
|
|
||||||
@@ -64,6 +68,8 @@ class HttpAlternateProtocols {
|
|||||||
// attempts to set the alternate protocol for |http_host_port_pair| will fail.
|
// attempts to set the alternate protocol for |http_host_port_pair| will fail.
|
||||||
void MarkBrokenAlternateProtocolFor(const HostPortPair& http_host_port_pair);
|
void MarkBrokenAlternateProtocolFor(const HostPortPair& http_host_port_pair);
|
||||||
|
|
||||||
|
const ProtocolMap& protocol_map() const { return protocol_map_; }
|
||||||
|
|
||||||
// Debugging to simulate presence of an AlternateProtocol.
|
// Debugging to simulate presence of an AlternateProtocol.
|
||||||
// If we don't have an alternate protocol in the map for any given host/port
|
// If we don't have an alternate protocol in the map for any given host/port
|
||||||
// pair, force this ProtocolPortPair.
|
// pair, force this ProtocolPortPair.
|
||||||
@@ -71,10 +77,10 @@ class HttpAlternateProtocols {
|
|||||||
static void DisableForcedAlternateProtocol();
|
static void DisableForcedAlternateProtocol();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<HostPortPair, PortProtocolPair> ProtocolMap;
|
|
||||||
|
|
||||||
ProtocolMap protocol_map_;
|
ProtocolMap protocol_map_;
|
||||||
|
|
||||||
|
static const char* ProtocolToString(Protocol protocol);
|
||||||
|
|
||||||
// The forced alternate protocol. If not-null, there is a protocol being
|
// The forced alternate protocol. If not-null, there is a protocol being
|
||||||
// forced.
|
// forced.
|
||||||
static PortProtocolPair* forced_alternate_protocol_;
|
static PortProtocolPair* forced_alternate_protocol_;
|
||||||
|
Reference in New Issue
Block a user