summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-11 21:34:46 +0000
committermbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-11 21:34:46 +0000
commit9fc38b3ac8e8c9cfad867a1177d5b295a7646b57 (patch)
treedb1f4d7ba7b87cf2f006f608448ba92ba596fe64 /net
parente1c16492b1113c01e7467eaa526a01db85bf6470 (diff)
downloadchromium_src-9fc38b3ac8e8c9cfad867a1177d5b295a7646b57.zip
chromium_src-9fc38b3ac8e8c9cfad867a1177d5b295a7646b57.tar.gz
chromium_src-9fc38b3ac8e8c9cfad867a1177d5b295a7646b57.tar.bz2
Enable JS detection of whether SPDY was used to load a web page.
Augments the loadTimes() API with a new field, "wasFetchedViaSpdy". BUG=31615 TEST=flip_network_transaction_unittest Review URL: http://codereview.chromium.org/518039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35943 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/flip/flip_network_transaction_unittest.cc4
-rw-r--r--net/flip/flip_session.cc14
-rw-r--r--net/http/http_response_info.cc7
-rw-r--r--net/http/http_response_info.h3
-rw-r--r--net/url_request/url_request.h5
5 files changed, 28 insertions, 5 deletions
diff --git a/net/flip/flip_network_transaction_unittest.cc b/net/flip/flip_network_transaction_unittest.cc
index 77ed06c..0a6a8f2 100644
--- a/net/flip/flip_network_transaction_unittest.cc
+++ b/net/flip/flip_network_transaction_unittest.cc
@@ -293,6 +293,7 @@ class FlipNetworkTransactionTest : public PlatformTest {
const HttpResponseInfo* response = trans->GetResponseInfo();
EXPECT_TRUE(response->headers != NULL);
+ EXPECT_TRUE(response->was_fetched_via_spdy);
out.status_line = response->headers->GetStatusLine();
out.response_info = *response; // Make a copy so we can verify.
@@ -673,7 +674,6 @@ TEST_F(FlipNetworkTransactionTest, InvalidSynReply) {
}
}
-// TODO(mbelshe): This test is broken right now and we need to fix it!
TEST_F(FlipNetworkTransactionTest, DISABLED_ServerPush) {
// Reply with the X-Associated-Content header.
static const unsigned char syn_reply[] = {
@@ -887,8 +887,6 @@ TEST_F(FlipNetworkTransactionTest, PartialWrite) {
EXPECT_EQ("hello!", out.response_data);
}
-// Disabled due to flaky mac (and possibly linux) valgrind errors.
-// http://crbug.com/29471
TEST_F(FlipNetworkTransactionTest, DISABLED_ConnectFailure) {
MockConnect connects[] = {
MockConnect(true, ERR_NAME_NOT_RESOLVED),
diff --git a/net/flip/flip_session.cc b/net/flip/flip_session.cc
index 73cf834..3812108 100644
--- a/net/flip/flip_session.cc
+++ b/net/flip/flip_session.cc
@@ -54,7 +54,13 @@ namespace net {
namespace {
-const int kReadBufferSize = 32 * 1024;
+#ifdef WIN32
+// We use an artificially small buffer size on windows because the async IO
+// system will artifiially delay IO completions when we use large buffers.
+const int kReadBufferSize = 2 * 1024;
+#else
+const int kReadBufferSize = 8 * 1024;
+#endif
// Convert a FlipHeaderBlock into an HttpResponseInfo.
// |headers| input parameter with the FlipHeaderBlock.
@@ -115,6 +121,7 @@ bool FlipHeadersToHttpResponse(const flip::FlipHeaderBlock& headers,
}
response->headers = new HttpResponseHeaders(raw_headers);
+ response->was_fetched_via_spdy = true;
return true;
}
@@ -198,7 +205,8 @@ FlipSession::FlipSession(const std::string& host, HttpNetworkSession* session)
streams_initiated_count_(0),
streams_pushed_count_(0),
streams_pushed_and_claimed_count_(0),
- streams_abandoned_count_(0) {
+ streams_abandoned_count_(0),
+ bytes_received_(0) {
// TODO(mbelshe): consider randomization of the stream_hi_water_mark.
flip_framer_.set_visitor(this);
@@ -531,6 +539,8 @@ void FlipSession::OnReadComplete(int bytes_read) {
return;
}
+ bytes_received_ += bytes_read;
+
char *data = read_buffer_->data();
while (bytes_read &&
flip_framer_.error_code() == flip::FlipFramer::FLIP_NO_ERROR) {
diff --git a/net/http/http_response_info.cc b/net/http/http_response_info.cc
index cf6a363..873d017 100644
--- a/net/http/http_response_info.cc
+++ b/net/http/http_response_info.cc
@@ -38,6 +38,9 @@ enum {
// This bit is set if the request was cancelled before completion.
RESPONSE_INFO_TRUNCATED = 1 << 12,
+ // This bit is set if the response was received via SPDY.
+ RESPONSE_INFO_WAS_SPDY = 1 << 13,
+
// TODO(darin): Add other bits to indicate alternate request methods.
// For now, we don't support storing those.
};
@@ -103,6 +106,8 @@ bool HttpResponseInfo::InitFromPickle(const Pickle& pickle,
return false;
}
+ was_fetched_via_spdy = (flags & RESPONSE_INFO_WAS_SPDY) != 0;
+
*response_truncated = (flags & RESPONSE_INFO_TRUNCATED) ? true : false;
return true;
@@ -122,6 +127,8 @@ void HttpResponseInfo::Persist(Pickle* pickle,
flags |= RESPONSE_INFO_HAS_VARY_DATA;
if (response_truncated)
flags |= RESPONSE_INFO_TRUNCATED;
+ if (was_fetched_via_spdy)
+ flags |= RESPONSE_INFO_WAS_SPDY;
pickle->WriteInt(flags);
pickle->WriteInt64(request_time.ToInternalValue());
diff --git a/net/http/http_response_info.h b/net/http/http_response_info.h
index 432ad87..a3e0123f 100644
--- a/net/http/http_response_info.h
+++ b/net/http/http_response_info.h
@@ -31,6 +31,9 @@ class HttpResponseInfo {
// reloading previously visited pages (without going over the network).
bool was_cached;
+ // True if the request was fetched over a SPDY channel.
+ bool was_fetched_via_spdy;
+
// The time at which the request was made that resulted in this response.
// For cached responses, this is the last time the cache entry was validated.
base::Time request_time;
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h
index 1b73b95..e586e28 100644
--- a/net/url_request/url_request.h
+++ b/net/url_request/url_request.h
@@ -362,6 +362,11 @@ class URLRequest {
// Indicate if this response was fetched from disk cache.
bool was_cached() const { return response_info_.was_cached; }
+ // Returns true if the URLRequest was delivered with SPDY.
+ bool was_fetched_via_spdy() const {
+ return response_info_.was_fetched_via_spdy;
+ }
+
// Get all response headers, as a HttpResponseHeaders object. See comments
// in HttpResponseHeaders class as to the format of the data.
net::HttpResponseHeaders* response_headers() const;