Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Unified Diff: net/spdy/spdy_framer.cc

Issue 11194068: Linux: fix build with system zlib. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/infinite_cache.cc ('k') | net/spdy/spdy_framer_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_framer.cc
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc
index 6559f5951d76704c9b76bd5de775083a69d53485..0d9049d52eb0bd498dd138483c705dc7c780e3de 100644
--- a/net/spdy/spdy_framer.cc
+++ b/net/spdy/spdy_framer.cc
@@ -661,6 +661,10 @@ void SpdyFramer::WriteHeaderBlock(SpdyFrameBuilder* frame,
}
}
+// TODO(phajdan.jr): Clean up after we no longer need
+// to workaround http://crbug.com/139744.
+#if !defined(USE_SYSTEM_ZLIB)
+
// These constants are used by zlib to differentiate between normal data and
// cookie data. Cookie data is handled specially by zlib when compressing.
enum ZDataClass {
@@ -819,6 +823,7 @@ void SpdyFramer::WriteHeaderBlockToZ(const SpdyHeaderBlock* headers,
DCHECK_EQ(Z_OK, rv);
z->clas = kZStandardData;
}
+#endif // !defined(USE_SYSTEM_ZLIB)
size_t SpdyFramer::ProcessControlFrameBeforeHeaderBlock(const char* data,
size_t len) {
@@ -1476,7 +1481,14 @@ SpdyDataFrame* SpdyFramer::CreateDataFrame(
// The following compression setting are based on Brian Olson's analysis. See
// https://groups.google.com/group/spdy-dev/browse_thread/thread/dfaf498542fac792
// for more details.
+#if defined(USE_SYSTEM_ZLIB)
+// System zlib is not expected to have workaround for http://crbug.com/139744,
+// so disable compression in that case.
+// TODO(phajdan.jr): Remove the special case when it's no longer necessary.
+static const int kCompressorLevel = 0;
+#else // !defined(USE_SYSTEM_ZLIB)
static const int kCompressorLevel = 9;
+#endif // !defined(USE_SYSTEM_ZLIB)
static const int kCompressorWindowSizeInBits = 11;
static const int kCompressorMemLevel = 1;
@@ -1625,10 +1637,27 @@ SpdyControlFrame* SpdyFramer::CompressControlFrame(
memcpy(new_frame->data(), frame.data(),
frame.length() + SpdyFrame::kHeaderSize);
+ // TODO(phajdan.jr): Clean up after we no longer need
+ // to workaround http://crbug.com/139744.
+#if defined(USE_SYSTEM_ZLIB)
+ compressor->next_in = reinterpret_cast<Bytef*>(const_cast<char*>(payload));
+ compressor->avail_in = payload_length;
+#endif // defined(USE_SYSTEM_ZLIB)
compressor->next_out = reinterpret_cast<Bytef*>(new_frame->data()) +
header_length;
compressor->avail_out = compressed_max_size;
+ // TODO(phajdan.jr): Clean up after we no longer need
+ // to workaround http://crbug.com/139744.
+#if defined(USE_SYSTEM_ZLIB)
+ int rv = deflate(compressor, Z_SYNC_FLUSH);
+ if (rv != Z_OK) { // How can we know that it compressed everything?
+ // This shouldn't happen, right?
+ LOG(WARNING) << "deflate failure: " << rv;
+ return NULL;
+ }
+#else // !defined(USE_SYSTEM_ZLIB)
WriteHeaderBlockToZ(headers, compressor);
+#endif // !defined(USE_SYSTEM_ZLIB)
int compressed_size = compressed_max_size - compressor->avail_out;
// We trust zlib. Also, we can't do anything about it.
« no previous file with comments | « net/http/infinite_cache.cc ('k') | net/spdy/spdy_framer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698