diff options
author | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-02 01:00:57 +0000 |
---|---|---|
committer | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-02 01:00:57 +0000 |
commit | f3da152dfaa23bf58475e17d5f3d207806ae4705 (patch) | |
tree | bb00680a185d4038731ed16e92e1d16a24f29dd9 /net/http | |
parent | aa3c64b26eced83e5f7544d7243061e5c39e8d18 (diff) | |
download | chromium_src-f3da152dfaa23bf58475e17d5f3d207806ae4705.zip chromium_src-f3da152dfaa23bf58475e17d5f3d207806ae4705.tar.gz chromium_src-f3da152dfaa23bf58475e17d5f3d207806ae4705.tar.bz2 |
Rename CapturingNetLog::Entry to CapturingNetLog::CaptureEntry,
and have it keep its own copy of a NetLog Entry's parameters.
This is in preparation for a NetLog refactoring that will result
in NetLog parameters lasting no longer than the function call,
to avoid always having to copy all parameters.
This does make CapturingNetLogs much less efficient themselves,
but they should not be used in production code, anyways.
TEST=NONE
BUG=126243
Review URL: https://chromiumcodereview.appspot.com/10442085
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r-- | net/http/http_auth_handler_unittest.cc | 2 | ||||
-rw-r--r-- | net/http/http_cache_unittest.cc | 6 | ||||
-rw-r--r-- | net/http/http_network_transaction_spdy2_unittest.cc | 45 | ||||
-rw-r--r-- | net/http/http_network_transaction_spdy3_unittest.cc | 45 |
4 files changed, 66 insertions, 32 deletions
diff --git a/net/http/http_auth_handler_unittest.cc b/net/http/http_auth_handler_unittest.cc index 79aa2bc..ee07437 100644 --- a/net/http/http_auth_handler_unittest.cc +++ b/net/http/http_auth_handler_unittest.cc @@ -48,7 +48,7 @@ TEST(HttpAuthHandlerTest, NetLog) { if (async) test_callback.WaitForResult(); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; capturing_net_log.GetEntries(&entries); EXPECT_EQ(2u, entries.size()); diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index 08065f6..cd47a1a 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -436,7 +436,7 @@ TEST(HttpCache, SimpleGETNoDiskCache) { // Check that the NetLog was filled as expected. // (We attempted to both Open and Create entries, but both failed). - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); EXPECT_EQ(6u, entries.size()); @@ -579,7 +579,7 @@ TEST(HttpCache, SimpleGET_LoadOnlyFromCache_Hit) { log.bound()); // Check that the NetLog was filled as expected. - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); EXPECT_EQ(8u, entries.size()); @@ -710,7 +710,7 @@ TEST(HttpCache, SimpleGET_LoadBypassCache) { RunTransactionTestWithLog(cache.http_cache(), transaction, log.bound()); // Check that the NetLog was filled as expected. - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); EXPECT_EQ(8u, entries.size()); diff --git a/net/http/http_network_transaction_spdy2_unittest.cc b/net/http/http_network_transaction_spdy2_unittest.cc index 7ede328..ddd5367 100644 --- a/net/http/http_network_transaction_spdy2_unittest.cc +++ b/net/http/http_network_transaction_spdy2_unittest.cc @@ -13,8 +13,10 @@ #include "base/compiler_specific.h" #include "base/file_path.h" #include "base/file_util.h" +#include "base/json/json_writer.h" #include "base/memory/scoped_ptr.h" #include "base/metrics/histogram.h" +#include "base/string_util.h" #include "base/test/test_file_util.h" #include "base/utf_string_conversions.h" #include "net/base/auth.h" @@ -111,6 +113,21 @@ int GetIdleSocketCountInSSLSocketPool(net::HttpNetworkSession* session) { net::HttpNetworkSession::NORMAL_SOCKET_POOL)->IdleSocketCount(); } +// Takes in a Value created from a NetLogHttpResponseParameter, and returns +// a JSONified list of headers as a single string. Uses single quotes instead +// of double quotes for easier comparison. Returns false on failure. +bool GetHeaders(DictionaryValue* params, std::string* headers) { + if (!params) + return false; + ListValue* header_list; + if (!params->GetList("headers", &header_list)) + return false; + std::string double_quote_headers; + base::JSONWriter::Write(header_list, &double_quote_headers); + ReplaceChars(double_quote_headers, "\"", "'", headers); + return true; +} + } // namespace namespace net { @@ -242,7 +259,7 @@ class HttpNetworkTransactionSpdy2Test : public PlatformTest { rv = ReadTransaction(trans.get(), &out.response_data); EXPECT_EQ(OK, rv); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); size_t pos = ExpectLogContainsSomewhere( entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, @@ -252,13 +269,13 @@ class HttpNetworkTransactionSpdy2Test : public PlatformTest { NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS, NetLog::PHASE_NONE); - CapturingNetLog::Entry entry = entries[pos]; - NetLogHttpRequestParameter* request_params = - static_cast<NetLogHttpRequestParameter*>(entry.extra_parameters.get()); - EXPECT_EQ("GET / HTTP/1.1\r\n", request_params->GetLine()); - EXPECT_EQ("Host: www.google.com\r\n" - "Connection: keep-alive\r\n\r\n", - request_params->GetHeaders().ToString()); + std::string line; + EXPECT_TRUE(entries[pos].GetStringValue("line", &line)); + EXPECT_EQ("GET / HTTP/1.1\r\n", line); + + std::string headers; + EXPECT_TRUE(GetHeaders(entries[pos].params.get(), &headers)); + EXPECT_EQ("['Host: www.google.com','Connection: keep-alive']", headers); return out; } @@ -1777,7 +1794,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyNoKeepAlive) { rv = callback1.WaitForResult(); EXPECT_EQ(OK, rv); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); size_t pos = ExpectLogContainsSomewhere( entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, @@ -1878,7 +1895,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthProxyKeepAlive) { rv = callback1.WaitForResult(); EXPECT_EQ(OK, rv); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); size_t pos = ExpectLogContainsSomewhere( entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, @@ -2072,7 +2089,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, rv = callback1.WaitForResult(); EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); size_t pos = ExpectLogContainsSomewhere( entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, @@ -4987,7 +5004,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, BasicAuthSpdyProxy) { rv = callback1.WaitForResult(); EXPECT_EQ(OK, rv); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); size_t pos = ExpectLogContainsSomewhere( entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, @@ -8878,7 +8895,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGet) { rv = callback1.WaitForResult(); EXPECT_EQ(OK, rv); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); size_t pos = ExpectLogContainsSomewhere( entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, @@ -8942,7 +8959,7 @@ TEST_F(HttpNetworkTransactionSpdy2Test, ProxyTunnelGetHangup) { rv = callback1.WaitForResult(); EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); size_t pos = ExpectLogContainsSomewhere( entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, diff --git a/net/http/http_network_transaction_spdy3_unittest.cc b/net/http/http_network_transaction_spdy3_unittest.cc index 992a9d2..4465a1c 100644 --- a/net/http/http_network_transaction_spdy3_unittest.cc +++ b/net/http/http_network_transaction_spdy3_unittest.cc @@ -13,8 +13,10 @@ #include "base/compiler_specific.h" #include "base/file_path.h" #include "base/file_util.h" +#include "base/json/json_writer.h" #include "base/memory/scoped_ptr.h" #include "base/metrics/histogram.h" +#include "base/string_util.h" #include "base/test/test_file_util.h" #include "base/utf_string_conversions.h" #include "net/base/auth.h" @@ -166,6 +168,21 @@ HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { return new HttpNetworkSession(params); } +// Takes in a Value created from a NetLogHttpResponseParameter, and returns +// a JSONified list of headers as a single string. Uses single quotes instead +// of double quotes for easier comparison. Returns false on failure. +bool GetHeaders(DictionaryValue* params, std::string* headers) { + if (!params) + return false; + ListValue* header_list; + if (!params->GetList("headers", &header_list)) + return false; + std::string double_quote_headers; + base::JSONWriter::Write(header_list, &double_quote_headers); + ReplaceChars(double_quote_headers, "\"", "'", headers); + return true; +} + } // namespace class HttpNetworkTransactionSpdy3Test : public PlatformTest { @@ -242,7 +259,7 @@ class HttpNetworkTransactionSpdy3Test : public PlatformTest { rv = ReadTransaction(trans.get(), &out.response_data); EXPECT_EQ(OK, rv); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); size_t pos = ExpectLogContainsSomewhere( entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, @@ -252,13 +269,13 @@ class HttpNetworkTransactionSpdy3Test : public PlatformTest { NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS, NetLog::PHASE_NONE); - CapturingNetLog::Entry entry = entries[pos]; - NetLogHttpRequestParameter* request_params = - static_cast<NetLogHttpRequestParameter*>(entry.extra_parameters.get()); - EXPECT_EQ("GET / HTTP/1.1\r\n", request_params->GetLine()); - EXPECT_EQ("Host: www.google.com\r\n" - "Connection: keep-alive\r\n\r\n", - request_params->GetHeaders().ToString()); + std::string line; + EXPECT_TRUE(entries[pos].GetStringValue("line", &line)); + EXPECT_EQ("GET / HTTP/1.1\r\n", line); + + std::string headers; + EXPECT_TRUE(GetHeaders(entries[pos].params.get(), &headers)); + EXPECT_EQ("['Host: www.google.com','Connection: keep-alive']", headers); return out; } @@ -1777,7 +1794,7 @@ TEST_F(HttpNetworkTransactionSpdy3Test, BasicAuthProxyNoKeepAlive) { rv = callback1.WaitForResult(); EXPECT_EQ(OK, rv); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); size_t pos = ExpectLogContainsSomewhere( entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, @@ -1878,7 +1895,7 @@ TEST_F(HttpNetworkTransactionSpdy3Test, BasicAuthProxyKeepAlive) { rv = callback1.WaitForResult(); EXPECT_EQ(OK, rv); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); size_t pos = ExpectLogContainsSomewhere( entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, @@ -2072,7 +2089,7 @@ TEST_F(HttpNetworkTransactionSpdy3Test, rv = callback1.WaitForResult(); EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); size_t pos = ExpectLogContainsSomewhere( entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, @@ -4987,7 +5004,7 @@ TEST_F(HttpNetworkTransactionSpdy3Test, BasicAuthSpdyProxy) { rv = callback1.WaitForResult(); EXPECT_EQ(OK, rv); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); size_t pos = ExpectLogContainsSomewhere( entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, @@ -8877,7 +8894,7 @@ TEST_F(HttpNetworkTransactionSpdy3Test, ProxyTunnelGet) { rv = callback1.WaitForResult(); EXPECT_EQ(OK, rv); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); size_t pos = ExpectLogContainsSomewhere( entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, @@ -8941,7 +8958,7 @@ TEST_F(HttpNetworkTransactionSpdy3Test, ProxyTunnelGetHangup) { rv = callback1.WaitForResult(); EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); - net::CapturingNetLog::EntryList entries; + net::CapturingNetLog::CapturedEntryList entries; log.GetEntries(&entries); size_t pos = ExpectLogContainsSomewhere( entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, |