summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-24 23:33:14 +0000
committerrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-24 23:33:14 +0000
commit557dcbac09e083e7141b2603cf1e8fa7770e5e00 (patch)
treea9cc181047ea600d0a314abd5cc36b05ba622db3
parent321b5d3de14e9a9a5eef7257d377a784be9a9e9b (diff)
downloadchromium_src-557dcbac09e083e7141b2603cf1e8fa7770e5e00.zip
chromium_src-557dcbac09e083e7141b2603cf1e8fa7770e5e00.tar.gz
chromium_src-557dcbac09e083e7141b2603cf1e8fa7770e5e00.tar.bz2
Move SpdyFramer::set_enable_compression_default to BufferedSpdyFramer
Review URL: http://codereview.chromium.org/10209012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133806 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/http/http_network_layer.cc2
-rw-r--r--net/spdy/buffered_spdy_framer.cc12
-rw-r--r--net/spdy/buffered_spdy_framer.h2
-rw-r--r--net/spdy/spdy_framer.cc9
-rw-r--r--net/spdy/spdy_framer.h2
-rw-r--r--net/spdy/spdy_network_transaction_spdy2_unittest.cc2
-rw-r--r--net/spdy/spdy_network_transaction_spdy3_unittest.cc2
-rw-r--r--net/spdy/spdy_test_util_spdy2.cc4
-rw-r--r--net/spdy/spdy_test_util_spdy3.cc4
9 files changed, 22 insertions, 17 deletions
diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc
index 9bb5c92..0650b45 100644
--- a/net/http/http_network_layer.cc
+++ b/net/http/http_network_layer.cc
@@ -77,7 +77,7 @@ void HttpNetworkLayer::EnableSpdy(const std::string& mode) {
} else if (option == kExclude) {
HttpStreamFactory::add_forced_spdy_exclusion(value);
} else if (option == kDisableCompression) {
- SpdyFramer::set_enable_compression_default(false);
+ BufferedSpdyFramer::set_enable_compression_default(false);
} else if (option == kDisableAltProtocols) {
HttpStreamFactory::set_use_alternate_protocols(false);
} else if (option == kForceAltProtocols) {
diff --git a/net/spdy/buffered_spdy_framer.cc b/net/spdy/buffered_spdy_framer.cc
index bc8af33..b544dcb 100644
--- a/net/spdy/buffered_spdy_framer.cc
+++ b/net/spdy/buffered_spdy_framer.cc
@@ -6,6 +6,12 @@
#include "base/logging.h"
+namespace {
+
+bool g_enable_compression_default = true;
+
+} // namespace
+
namespace net {
BufferedSpdyFramer::BufferedSpdyFramer(int version)
@@ -15,6 +21,7 @@ BufferedSpdyFramer::BufferedSpdyFramer(int version)
header_buffer_valid_(false),
header_stream_id_(SpdyFramer::kInvalidStream),
frames_received_(0) {
+ spdy_framer_.set_enable_compression(g_enable_compression_default);
memset(header_buffer_, 0, sizeof(header_buffer_));
}
@@ -250,6 +257,11 @@ SpdyControlFrame* BufferedSpdyFramer::CompressControlFrame(
return spdy_framer_.CompressControlFrame(frame);
}
+// static
+void BufferedSpdyFramer::set_enable_compression_default(bool value) {
+ g_enable_compression_default = value;
+}
+
void BufferedSpdyFramer::InitHeaderStreaming(const SpdyControlFrame* frame) {
memset(header_buffer_, 0, kHeaderBufferSize);
header_buffer_used_ = 0;
diff --git a/net/spdy/buffered_spdy_framer.h b/net/spdy/buffered_spdy_framer.h
index b10f46f..6a43bc8 100644
--- a/net/spdy/buffered_spdy_framer.h
+++ b/net/spdy/buffered_spdy_framer.h
@@ -142,6 +142,8 @@ class NET_EXPORT_PRIVATE BufferedSpdyFramer
SpdyPriority GetHighestPriority() const;
bool IsCompressible(const SpdyFrame& frame) const;
SpdyControlFrame* CompressControlFrame(const SpdyControlFrame& frame);
+ // Specify if newly created SpdySessions should have compression enabled.
+ static void set_enable_compression_default(bool value);
int frames_received() const { return frames_received_; }
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc
index 319542b..ee0ee22 100644
--- a/net/spdy/spdy_framer.cc
+++ b/net/spdy/spdy_framer.cc
@@ -51,9 +51,6 @@ struct DictionaryIds {
// initialized lazily to avoid static initializers.
base::LazyInstance<DictionaryIds>::Leaky g_dictionary_ids;
-// By default is compression on or off.
-bool g_enable_compression_default = true;
-
} // namespace
const int SpdyFramer::kMinSpdyVersion = 2;
@@ -128,7 +125,7 @@ SpdyFramer::SpdyFramer(int version)
remaining_control_header_(0),
current_frame_buffer_(new char[kControlFrameBufferSize]),
current_frame_len_(0),
- enable_compression_(g_enable_compression_default),
+ enable_compression_(true),
visitor_(NULL),
display_protocol_("SPDY"),
spdy_version_(version),
@@ -1629,8 +1626,4 @@ void SpdyFramer::set_enable_compression(bool value) {
enable_compression_ = value;
}
-void SpdyFramer::set_enable_compression_default(bool value) {
- g_enable_compression_default = value;
-}
-
} // namespace net
diff --git a/net/spdy/spdy_framer.h b/net/spdy/spdy_framer.h
index fc05e90..e1ff855 100644
--- a/net/spdy/spdy_framer.h
+++ b/net/spdy/spdy_framer.h
@@ -402,8 +402,6 @@ class NET_EXPORT_PRIVATE SpdyFramer {
// For ease of testing and experimentation we can tweak compression on/off.
void set_enable_compression(bool value);
- static void set_enable_compression_default(bool value);
-
// Used only in log messages.
void set_display_protocol(const std::string& protocol) {
display_protocol_ = protocol;
diff --git a/net/spdy/spdy_network_transaction_spdy2_unittest.cc b/net/spdy/spdy_network_transaction_spdy2_unittest.cc
index 978e35e..82db48a 100644
--- a/net/spdy/spdy_network_transaction_spdy2_unittest.cc
+++ b/net/spdy/spdy_network_transaction_spdy2_unittest.cc
@@ -3496,7 +3496,7 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, PartialWrite) {
// the server. Verify that teardown is all clean.
TEST_P(SpdyNetworkTransactionSpdy2Test, DecompressFailureOnSynReply) {
// For this test, we turn on the normal compression.
- SpdyFramer::set_enable_compression_default(true);
+ BufferedSpdyFramer::set_enable_compression_default(true);
scoped_ptr<SpdyFrame> compressed(
ConstructSpdyGet(NULL, 0, true, 1, LOWEST));
diff --git a/net/spdy/spdy_network_transaction_spdy3_unittest.cc b/net/spdy/spdy_network_transaction_spdy3_unittest.cc
index 6cfe4a6..b76b324 100644
--- a/net/spdy/spdy_network_transaction_spdy3_unittest.cc
+++ b/net/spdy/spdy_network_transaction_spdy3_unittest.cc
@@ -4070,7 +4070,7 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, PartialWrite) {
// the server. Verify that teardown is all clean.
TEST_P(SpdyNetworkTransactionSpdy3Test, DecompressFailureOnSynReply) {
// For this test, we turn on the normal compression.
- SpdyFramer::set_enable_compression_default(true);
+ BufferedSpdyFramer::set_enable_compression_default(true);
scoped_ptr<SpdyFrame> compressed(
ConstructSpdyGet(NULL, 0, true, 1, LOWEST));
diff --git a/net/spdy/spdy_test_util_spdy2.cc b/net/spdy/spdy_test_util_spdy2.cc
index 3d43f12..14178df 100644
--- a/net/spdy/spdy_test_util_spdy2.cc
+++ b/net/spdy/spdy_test_util_spdy2.cc
@@ -1007,13 +1007,13 @@ SpdyTestStateHelper::SpdyTestStateHelper() {
SpdySession::set_enable_ping_based_connection_checking(false);
// Compression is per-session which makes it impossible to create
// SPDY frames with static methods.
- SpdyFramer::set_enable_compression_default(false);
+ BufferedSpdyFramer::set_enable_compression_default(false);
}
SpdyTestStateHelper::~SpdyTestStateHelper() {
SpdySession::ResetStaticSettingsToInit();
// TODO(rch): save/restore this value
- SpdyFramer::set_enable_compression_default(true);
+ BufferedSpdyFramer::set_enable_compression_default(true);
}
} // namespace test_spdy2
diff --git a/net/spdy/spdy_test_util_spdy3.cc b/net/spdy/spdy_test_util_spdy3.cc
index 764f50e..5a651f4 100644
--- a/net/spdy/spdy_test_util_spdy3.cc
+++ b/net/spdy/spdy_test_util_spdy3.cc
@@ -991,13 +991,13 @@ SpdyTestStateHelper::SpdyTestStateHelper() {
SpdySession::set_enable_ping_based_connection_checking(false);
// Compression is per-session which makes it impossible to create
// SPDY frames with static methods.
- SpdyFramer::set_enable_compression_default(false);
+ BufferedSpdyFramer::set_enable_compression_default(false);
}
SpdyTestStateHelper::~SpdyTestStateHelper() {
SpdySession::ResetStaticSettingsToInit();
// TODO(rch): save/restore this value
- SpdyFramer::set_enable_compression_default(true);
+ BufferedSpdyFramer::set_enable_compression_default(true);
}
} // namespace test_spdy3