summaryrefslogtreecommitdiffstats
path: root/net/spdy
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-07 17:33:21 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-07 17:33:21 +0000
commit23dcb606cfbbc8abb5c4d97ead47bbc4e7c53c62 (patch)
tree7ebbb744403518076296cded2d776194b18ace91 /net/spdy
parent6ac890424996a3338b53cd0032ab9435c1e4677b (diff)
downloadchromium_src-23dcb606cfbbc8abb5c4d97ead47bbc4e7c53c62.zip
chromium_src-23dcb606cfbbc8abb5c4d97ead47bbc4e7c53c62.tar.gz
chromium_src-23dcb606cfbbc8abb5c4d97ead47bbc4e7c53c62.tar.bz2
Add SPDY request headers to DevTools.
R=eroman@chromium.org, yurys@chromium.org BUG=73945 Review URL: https://chromiumcodereview.appspot.com/10870080 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155413 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy')
-rw-r--r--net/spdy/buffered_spdy_framer.h1
-rw-r--r--net/spdy/spdy_framer.h5
-rw-r--r--net/spdy/spdy_header_block.cc51
-rw-r--r--net/spdy/spdy_header_block.h36
-rw-r--r--net/spdy/spdy_header_block_unittest.cc31
-rw-r--r--net/spdy/spdy_http_stream.cc20
-rw-r--r--net/spdy/spdy_http_utils.h1
-rw-r--r--net/spdy/spdy_session.h1
-rw-r--r--net/spdy/spdy_stream.h1
-rw-r--r--net/spdy/spdy_websocket_stream.h1
10 files changed, 126 insertions, 22 deletions
diff --git a/net/spdy/buffered_spdy_framer.h b/net/spdy/buffered_spdy_framer.h
index 39a2d0e..aa4163e 100644
--- a/net/spdy/buffered_spdy_framer.h
+++ b/net/spdy/buffered_spdy_framer.h
@@ -12,6 +12,7 @@
#include "base/memory/scoped_ptr.h"
#include "net/base/net_export.h"
#include "net/spdy/spdy_framer.h"
+#include "net/spdy/spdy_header_block.h"
#include "net/spdy/spdy_protocol.h"
namespace net {
diff --git a/net/spdy/spdy_framer.h b/net/spdy/spdy_framer.h
index 93f60e7..21100b0 100644
--- a/net/spdy/spdy_framer.h
+++ b/net/spdy/spdy_framer.h
@@ -16,6 +16,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/sys_byteorder.h"
#include "net/base/net_export.h"
+#include "net/spdy/spdy_header_block.h"
#include "net/spdy/spdy_protocol.h"
typedef struct z_stream_s z_stream; // Forward declaration for zlib.
@@ -43,10 +44,6 @@ class TestSpdyVisitor;
} // namespace test
-// A datastructure for holding a set of headers from either a
-// SYN_STREAM or SYN_REPLY frame.
-typedef std::map<std::string, std::string> SpdyHeaderBlock;
-
// A datastructure for holding the ID and flag fields for SETTINGS.
// Conveniently handles converstion to/from wire format.
class NET_EXPORT_PRIVATE SettingsFlagsAndId {
diff --git a/net/spdy/spdy_header_block.cc b/net/spdy/spdy_header_block.cc
new file mode 100644
index 0000000..dcb62da
--- /dev/null
+++ b/net/spdy/spdy_header_block.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 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/spdy/spdy_header_block.h"
+
+#include "base/values.h"
+
+namespace net {
+
+Value* SpdyHeaderBlockNetLogCallback(
+ const SpdyHeaderBlock* headers,
+ NetLog::LogLevel /* log_level */) {
+ DictionaryValue* dict = new DictionaryValue();
+ DictionaryValue* headers_dict = new DictionaryValue();
+ for (SpdyHeaderBlock::const_iterator it = headers->begin();
+ it != headers->end(); ++it) {
+ headers_dict->SetWithoutPathExpansion(
+ it->first, new StringValue(it->second));
+ }
+ dict->Set("headers", headers_dict);
+ return dict;
+}
+
+bool SpdyHeaderBlockFromNetLogParam(
+ const base::Value* event_param,
+ SpdyHeaderBlock* headers) {
+ headers->clear();
+
+ const base::DictionaryValue* dict;
+ const base::DictionaryValue* header_dict;
+
+ if (!event_param ||
+ !event_param->GetAsDictionary(&dict) ||
+ !dict->GetDictionary("headers", &header_dict)) {
+ return false;
+ }
+
+ for (base::DictionaryValue::key_iterator it = header_dict->begin_keys();
+ it != header_dict->end_keys();
+ ++it) {
+ std::string value;
+ if (!header_dict->GetString(*it, &(*headers)[*it])) {
+ headers->clear();
+ return false;
+ }
+ }
+ return true;
+}
+
+} // namespace net
diff --git a/net/spdy/spdy_header_block.h b/net/spdy/spdy_header_block.h
new file mode 100644
index 0000000..8ae8fa3
--- /dev/null
+++ b/net/spdy/spdy_header_block.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 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.
+
+#ifndef NET_SPDY_SPDY_HEADER_BLOCK_H_
+#define NET_SPDY_SPDY_HEADER_BLOCK_H_
+
+#include <map>
+#include <string>
+
+#include "net/base/net_export.h"
+#include "net/base/net_log.h"
+
+namespace net {
+
+// A data structure for holding a set of headers from either a
+// SYN_STREAM or SYN_REPLY frame.
+typedef std::map<std::string, std::string> SpdyHeaderBlock;
+
+// Converts a SpdyHeaderBlock into NetLog event parameters. Caller takes
+// ownership of returned value.
+NET_EXPORT base::Value* SpdyHeaderBlockNetLogCallback(
+ const SpdyHeaderBlock* headers,
+ NetLog::LogLevel log_level);
+
+// Converts NetLog event parameters into a SPDY header block and writes them
+// to |headers|. |event_param| must have been created by
+// SpdyHeaderBlockNetLogCallback. On failure, returns false and clears
+// |headers|.
+NET_EXPORT bool SpdyHeaderBlockFromNetLogParam(
+ const base::Value* event_param,
+ SpdyHeaderBlock* headers);
+
+} // namespace net
+
+#endif // NET_SPDY_SPDY_HEADER_BLOCK_H_
diff --git a/net/spdy/spdy_header_block_unittest.cc b/net/spdy/spdy_header_block_unittest.cc
new file mode 100644
index 0000000..3cfef16
--- /dev/null
+++ b/net/spdy/spdy_header_block_unittest.cc
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 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/spdy/spdy_header_block.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
+#include "net/base/net_log.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+namespace {
+
+TEST(SpdyHeaderBlockTest, ToNetLogParamAndBackAgain) {
+ SpdyHeaderBlock headers;
+ headers["A"] = "a";
+ headers["B"] = "b";
+
+ scoped_ptr<Value> event_param(
+ SpdyHeaderBlockNetLogCallback(&headers, NetLog::LOG_ALL_BUT_BYTES));
+
+ SpdyHeaderBlock headers2;
+ ASSERT_TRUE(SpdyHeaderBlockFromNetLogParam(event_param.get(), &headers2));
+ EXPECT_EQ(headers, headers2);
+}
+
+} // namespace
+
+} // namespace net
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc
index 31c20ef..f642dc4 100644
--- a/net/spdy/spdy_http_stream.cc
+++ b/net/spdy/spdy_http_stream.cc
@@ -23,28 +23,12 @@
#include "net/http/http_request_info.h"
#include "net/http/http_response_info.h"
#include "net/http/http_util.h"
+#include "net/spdy/spdy_header_block.h"
#include "net/spdy/spdy_http_utils.h"
#include "net/spdy/spdy_session.h"
namespace net {
-namespace {
-
-Value* NetLogSpdySendRequestCallback(const SpdyHeaderBlock* headers,
- NetLog::LogLevel /* log_level */) {
- DictionaryValue* dict = new DictionaryValue();
- ListValue* headers_list = new ListValue();
- for (SpdyHeaderBlock::const_iterator it = headers->begin();
- it != headers->end(); ++it) {
- headers_list->Append(new StringValue(base::StringPrintf(
- "%s: %s", it->first.c_str(), it->second.c_str())));
- }
- dict->Set("headers", headers_list);
- return dict;
-}
-
-} // namespace
-
SpdyHttpStream::SpdyHttpStream(SpdySession* spdy_session,
bool direct)
: ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
@@ -221,7 +205,7 @@ int SpdyHttpStream::SendRequest(const HttpRequestHeaders& request_headers,
direct_);
stream_->net_log().AddEvent(
NetLog::TYPE_HTTP_TRANSACTION_SPDY_SEND_REQUEST_HEADERS,
- base::Bind(&NetLogSpdySendRequestCallback, headers.get()));
+ base::Bind(&SpdyHeaderBlockNetLogCallback, headers.get()));
stream_->set_spdy_headers(headers.Pass());
stream_->SetRequestTime(request_time);
diff --git a/net/spdy/spdy_http_utils.h b/net/spdy/spdy_http_utils.h
index 314ead0..fabf4a28 100644
--- a/net/spdy/spdy_http_utils.h
+++ b/net/spdy/spdy_http_utils.h
@@ -9,6 +9,7 @@
#include "net/base/net_export.h"
#include "net/base/request_priority.h"
#include "net/spdy/spdy_framer.h"
+#include "net/spdy/spdy_header_block.h"
namespace net {
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h
index 597f640..a9081fd6 100644
--- a/net/spdy/spdy_session.h
+++ b/net/spdy/spdy_session.h
@@ -27,6 +27,7 @@
#include "net/socket/stream_socket.h"
#include "net/spdy/buffered_spdy_framer.h"
#include "net/spdy/spdy_credential_state.h"
+#include "net/spdy/spdy_header_block.h"
#include "net/spdy/spdy_io_buffer.h"
#include "net/spdy/spdy_protocol.h"
#include "net/spdy/spdy_session_pool.h"
diff --git a/net/spdy/spdy_stream.h b/net/spdy/spdy_stream.h
index e368bab..a346782 100644
--- a/net/spdy/spdy_stream.h
+++ b/net/spdy/spdy_stream.h
@@ -22,6 +22,7 @@
#include "net/base/ssl_client_cert_type.h"
#include "net/socket/ssl_client_socket.h"
#include "net/spdy/spdy_framer.h"
+#include "net/spdy/spdy_header_block.h"
#include "net/spdy/spdy_protocol.h"
#include "net/spdy/spdy_session.h"
diff --git a/net/spdy/spdy_websocket_stream.h b/net/spdy/spdy_websocket_stream.h
index a3a2314..5ab4c48 100644
--- a/net/spdy/spdy_websocket_stream.h
+++ b/net/spdy/spdy_websocket_stream.h
@@ -13,6 +13,7 @@
#include "net/base/completion_callback.h"
#include "net/base/request_priority.h"
#include "net/spdy/spdy_framer.h"
+#include "net/spdy/spdy_header_block.h"
#include "net/spdy/spdy_stream.h"
namespace net {