diff options
author | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-06 02:47:42 +0000 |
---|---|---|
committer | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-06 02:47:42 +0000 |
commit | 92a98df95fa1b552ec8d30f20a4aa568dfadddfa (patch) | |
tree | 7902f4e4b6e9b1741f022c365da09d1441a5bbca | |
parent | a4766fb2ede9c22876a41cf388c4b280387bbe2b (diff) | |
download | chromium_src-92a98df95fa1b552ec8d30f20a4aa568dfadddfa.zip chromium_src-92a98df95fa1b552ec8d30f20a4aa568dfadddfa.tar.gz chromium_src-92a98df95fa1b552ec8d30f20a4aa568dfadddfa.tar.bz2 |
Expose the HttpResponseInfo's ConnectionInfo in window.chrome.loadTimes()
Review URL: https://chromiumcodereview.appspot.com/12792010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204393 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/renderer/loadtimes_extension_bindings.cc | 8 | ||||
-rw-r--r-- | content/browser/loader/resource_loader.cc | 1 | ||||
-rw-r--r-- | content/common/resource_messages.h | 6 | ||||
-rw-r--r-- | content/public/renderer/document_state.cc | 1 | ||||
-rw-r--r-- | content/public/renderer/document_state.h | 10 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 2 | ||||
-rw-r--r-- | net/http/http_response_info.cc | 24 | ||||
-rw-r--r-- | net/http/http_response_info.h | 14 | ||||
-rw-r--r-- | webkit/glue/resource_loader_bridge.cc | 1 | ||||
-rw-r--r-- | webkit/glue/resource_loader_bridge.h | 4 | ||||
-rw-r--r-- | webkit/glue/weburlloader_impl.cc | 1 | ||||
-rw-r--r-- | webkit/glue/weburlresponse_extradata_impl.cc | 3 | ||||
-rw-r--r-- | webkit/glue/weburlresponse_extradata_impl.h | 11 |
13 files changed, 78 insertions, 8 deletions
diff --git a/chrome/renderer/loadtimes_extension_bindings.cc b/chrome/renderer/loadtimes_extension_bindings.cc index 771f70f..d95a364 100644 --- a/chrome/renderer/loadtimes_extension_bindings.cc +++ b/chrome/renderer/loadtimes_extension_bindings.cc @@ -8,6 +8,7 @@ #include "base/time.h" #include "content/public/renderer/document_state.h" +#include "net/http/http_response_info.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "v8/include/v8.h" @@ -135,13 +136,18 @@ class LoadTimesExtensionWrapper : public v8::Extension { load_times->Set( v8::String::New("wasNpnNegotiated"), v8::Boolean::New(document_state->was_npn_negotiated())); - load_times->Set( + load_times->Set( v8::String::New("npnNegotiatedProtocol"), v8::String::New(document_state->npn_negotiated_protocol().c_str())); load_times->Set( v8::String::New("wasAlternateProtocolAvailable"), v8::Boolean::New( document_state->was_alternate_protocol_available())); + load_times->Set( + v8::String::New("connectionInfo"), + v8::String::New( + net::HttpResponseInfo::ConnectionInfoToString( + document_state->connection_info()).c_str())); return load_times; } } diff --git a/content/browser/loader/resource_loader.cc b/content/browser/loader/resource_loader.cc index 7713c38..00f700d 100644 --- a/content/browser/loader/resource_loader.cc +++ b/content/browser/loader/resource_loader.cc @@ -48,6 +48,7 @@ void PopulateResourceResponse(net::URLRequest* request, response->head.was_npn_negotiated = response_info.was_npn_negotiated; response->head.npn_negotiated_protocol = response_info.npn_negotiated_protocol; + response->head.connection_info = response_info.connection_info; response->head.was_fetched_via_proxy = request->was_fetched_via_proxy(); response->head.socket_address = request->GetSocketAddress(); appcache::AppCacheInterceptor::GetExtraResponseInfo( diff --git a/content/common/resource_messages.h b/content/common/resource_messages.h index 7aebd09..d29e65a 100644 --- a/content/common/resource_messages.h +++ b/content/common/resource_messages.h @@ -14,6 +14,7 @@ #include "content/public/common/resource_response.h" #include "ipc/ipc_message_macros.h" #include "net/base/request_priority.h" +#include "net/http/http_response_info.h" #include "webkit/glue/resource_request_body.h" #ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_ @@ -78,6 +79,10 @@ struct ParamTraits<scoped_refptr<webkit_glue::ResourceRequestBody> > { #undef IPC_MESSAGE_EXPORT #define IPC_MESSAGE_EXPORT CONTENT_EXPORT +IPC_ENUM_TRAITS_MAX_VALUE( \ + net::HttpResponseInfo::ConnectionInfo, \ + net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS - 1) + IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseHead) IPC_STRUCT_TRAITS_PARENT(webkit_glue::ResourceResponseInfo) IPC_STRUCT_TRAITS_MEMBER(error_code) @@ -108,6 +113,7 @@ IPC_STRUCT_TRAITS_BEGIN(webkit_glue::ResourceResponseInfo) IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_spdy) IPC_STRUCT_TRAITS_MEMBER(was_npn_negotiated) IPC_STRUCT_TRAITS_MEMBER(was_alternate_protocol_available) + IPC_STRUCT_TRAITS_MEMBER(connection_info) IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_proxy) IPC_STRUCT_TRAITS_MEMBER(npn_negotiated_protocol) IPC_STRUCT_TRAITS_MEMBER(socket_address) diff --git a/content/public/renderer/document_state.cc b/content/public/renderer/document_state.cc index 854431b3..9e9d57d 100644 --- a/content/public/renderer/document_state.cc +++ b/content/public/renderer/document_state.cc @@ -15,6 +15,7 @@ DocumentState::DocumentState() was_fetched_via_spdy_(false), was_npn_negotiated_(false), was_alternate_protocol_available_(false), + connection_info_(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN), was_fetched_via_proxy_(false), was_prefetcher_(false), was_referred_by_prefetcher_(false), diff --git a/content/public/renderer/document_state.h b/content/public/renderer/document_state.h index 144eae4..21e0b72 100644 --- a/content/public/renderer/document_state.h +++ b/content/public/renderer/document_state.h @@ -12,6 +12,7 @@ #include "base/supports_user_data.h" #include "base/time.h" #include "content/common/content_export.h" +#include "net/http/http_response_info.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" namespace content { @@ -148,6 +149,14 @@ class CONTENT_EXPORT DocumentState was_alternate_protocol_available_ = value; } + net::HttpResponseInfo::ConnectionInfo connection_info() const { + return connection_info_; + } + void set_connection_info( + net::HttpResponseInfo::ConnectionInfo connection_info) { + connection_info_ = connection_info; + } + bool was_fetched_via_proxy() const { return was_fetched_via_proxy_; } void set_was_fetched_via_proxy(bool value) { was_fetched_via_proxy_ = value; @@ -203,6 +212,7 @@ class CONTENT_EXPORT DocumentState bool was_npn_negotiated_; std::string npn_negotiated_protocol_; bool was_alternate_protocol_available_; + net::HttpResponseInfo::ConnectionInfo connection_info_; bool was_fetched_via_proxy_; scoped_ptr<PasswordForm> password_form_data_; diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index df21065..ca49362 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -4078,6 +4078,8 @@ void RenderViewImpl::didReceiveResponse( extra_data->npn_negotiated_protocol()); document_state->set_was_alternate_protocol_available( extra_data->was_alternate_protocol_available()); + document_state->set_connection_info( + extra_data->connection_info()); document_state->set_was_fetched_via_proxy( extra_data->was_fetched_via_proxy()); } diff --git a/net/http/http_response_info.cc b/net/http/http_response_info.cc index dc6fd1e..a3dcfec 100644 --- a/net/http/http_response_info.cc +++ b/net/http/http_response_info.cc @@ -136,6 +136,7 @@ HttpResponseInfo& HttpResponseInfo::operator=(const HttpResponseInfo& rhs) { did_use_http_auth = rhs.did_use_http_auth; socket_address = rhs.socket_address; npn_negotiated_protocol = rhs.npn_negotiated_protocol; + connection_info = rhs.connection_info; request_time = rhs.request_time; response_time = rhs.response_time; auth_challenge = rhs.auth_challenge; @@ -327,4 +328,27 @@ void HttpResponseInfo::Persist(Pickle* pickle, pickle->WriteInt(static_cast<int>(connection_info)); } +// static +std::string HttpResponseInfo::ConnectionInfoToString( + ConnectionInfo connection_info) { + switch (connection_info) { + case CONNECTION_INFO_UNKNOWN: + return "unknown"; + case CONNECTION_INFO_HTTP1: + return "http/1"; + case CONNECTION_INFO_SPDY2: + return "spdy/2"; + case CONNECTION_INFO_SPDY3: + return "spdy/3"; + case CONNECTION_INFO_SPDY4: + return "spdy/4"; + case CONNECTION_INFO_QUIC1_SPDY3: + return "quic/1+spdy/3"; + case NUM_OF_CONNECTION_INFOS: + break; + } + NOTREACHED(); + return ""; +} + } // namespace net diff --git a/net/http/http_response_info.h b/net/http/http_response_info.h index de27825..4210db6 100644 --- a/net/http/http_response_info.h +++ b/net/http/http_response_info.h @@ -26,12 +26,12 @@ class NET_EXPORT HttpResponseInfo { public: // Describes the kind of connection used to fetch this response. enum ConnectionInfo { - CONNECTION_INFO_UNKNOWN, - CONNECTION_INFO_HTTP1, - CONNECTION_INFO_SPDY2, - CONNECTION_INFO_SPDY3, - CONNECTION_INFO_SPDY4, - CONNECTION_INFO_QUIC1_SPDY3, + CONNECTION_INFO_UNKNOWN = 0, + CONNECTION_INFO_HTTP1 = 1, + CONNECTION_INFO_SPDY2 = 2, + CONNECTION_INFO_SPDY3 = 3, + CONNECTION_INFO_SPDY4 = 4, + CONNECTION_INFO_QUIC1_SPDY3 = 5, NUM_OF_CONNECTION_INFOS, }; @@ -126,6 +126,8 @@ class NET_EXPORT HttpResponseInfo { // Any metadata asociated with this resource's cached data. scoped_refptr<IOBufferWithSize> metadata; + + static std::string ConnectionInfoToString(ConnectionInfo connection_info); }; } // namespace net diff --git a/webkit/glue/resource_loader_bridge.cc b/webkit/glue/resource_loader_bridge.cc index 23de004..f3b89b3 100644 --- a/webkit/glue/resource_loader_bridge.cc +++ b/webkit/glue/resource_loader_bridge.cc @@ -22,6 +22,7 @@ ResourceResponseInfo::ResourceResponseInfo() was_fetched_via_spdy(false), was_npn_negotiated(false), was_alternate_protocol_available(false), + connection_info(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN), was_fetched_via_proxy(false) { } diff --git a/webkit/glue/resource_loader_bridge.h b/webkit/glue/resource_loader_bridge.h index 3389394..5f1aee6 100644 --- a/webkit/glue/resource_loader_bridge.h +++ b/webkit/glue/resource_loader_bridge.h @@ -32,6 +32,7 @@ #include "net/base/host_port_pair.h" #include "net/base/load_timing_info.h" #include "net/base/request_priority.h" +#include "net/http/http_response_info.h" #include "net/url_request/url_request_status.h" #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" #include "third_party/WebKit/public/platform/WebURLRequest.h" @@ -127,6 +128,9 @@ struct ResourceResponseInfo { // ignore the alternate protocol when spdy is not enabled on browser side. bool was_alternate_protocol_available; + // Information about the type of connection used to fetch this response. + net::HttpResponseInfo::ConnectionInfo connection_info; + // True if the response was fetched via an explicit proxy (as opposed to a // transparent proxy). The proxy could be any type of proxy, HTTP or SOCKS. // Note: we cannot tell if a transparent proxy may have been involved. diff --git a/webkit/glue/weburlloader_impl.cc b/webkit/glue/weburlloader_impl.cc index 579bdca..9ed2b8c 100644 --- a/webkit/glue/weburlloader_impl.cc +++ b/webkit/glue/weburlloader_impl.cc @@ -211,6 +211,7 @@ void PopulateURLResponse( extra_data->set_was_npn_negotiated(info.was_npn_negotiated); extra_data->set_was_alternate_protocol_available( info.was_alternate_protocol_available); + extra_data->set_connection_info(info.connection_info); extra_data->set_was_fetched_via_proxy(info.was_fetched_via_proxy); // If there's no received headers end time, don't set load timing. This is diff --git a/webkit/glue/weburlresponse_extradata_impl.cc b/webkit/glue/weburlresponse_extradata_impl.cc index 59e43ff..4063662 100644 --- a/webkit/glue/weburlresponse_extradata_impl.cc +++ b/webkit/glue/weburlresponse_extradata_impl.cc @@ -9,7 +9,8 @@ namespace webkit_glue { WebURLResponseExtraDataImpl::WebURLResponseExtraDataImpl( const std::string& npn_negotiated_protocol) : npn_negotiated_protocol_(npn_negotiated_protocol), - is_ftp_directory_listing_(false) { + is_ftp_directory_listing_(false), + connection_info_(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN) { } WebURLResponseExtraDataImpl::~WebURLResponseExtraDataImpl() { diff --git a/webkit/glue/weburlresponse_extradata_impl.h b/webkit/glue/weburlresponse_extradata_impl.h index 84b63e8..a5ddba0 100644 --- a/webkit/glue/weburlresponse_extradata_impl.h +++ b/webkit/glue/weburlresponse_extradata_impl.h @@ -9,6 +9,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" +#include "net/http/http_response_info.h" #include "third_party/WebKit/public/platform/WebURLResponse.h" #include "webkit/glue/webkit_glue_export.h" @@ -44,6 +45,15 @@ class WEBKIT_GLUE_EXPORT WebURLResponseExtraDataImpl : was_fetched_via_spdy_ = was_fetched_via_spdy; } + // Information about the type of connection used to fetch this response. + net::HttpResponseInfo::ConnectionInfo connection_info() const { + return connection_info_; + } + void set_connection_info( + net::HttpResponseInfo::ConnectionInfo connection_info) { + connection_info_ = connection_info; + } + // Flag whether this request was loaded after the // TLS/Next-Protocol-Negotiation was used. // This is related to SPDY. @@ -75,6 +85,7 @@ class WEBKIT_GLUE_EXPORT WebURLResponseExtraDataImpl : bool was_fetched_via_proxy_; bool was_fetched_via_spdy_; bool was_npn_negotiated_; + net::HttpResponseInfo::ConnectionInfo connection_info_; bool was_alternate_protocol_available_; DISALLOW_COPY_AND_ASSIGN(WebURLResponseExtraDataImpl); |