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

Unified Diff: net/filter/mock_source_stream.cc

Issue 2604233002: Fix bug in deflate code. (Closed)
Patch Set: Revert bypassing replay state Created 3 years, 12 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/filter/mock_source_stream.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/filter/mock_source_stream.cc
diff --git a/net/filter/mock_source_stream.cc b/net/filter/mock_source_stream.cc
index bdf56c6a4e1f18b9a0b48cb2ca913eb1b7ea7611..7dceef28c7111671cb330e9403107353ea17df32 100644
--- a/net/filter/mock_source_stream.cc
+++ b/net/filter/mock_source_stream.cc
@@ -6,18 +6,21 @@
#include "base/logging.h"
#include "net/base/io_buffer.h"
+#include "testing/gtest/include/gtest/gtest.h"
namespace net {
MockSourceStream::MockSourceStream()
: SourceStream(SourceStream::TYPE_NONE),
+ read_one_byte_at_a_time_(false),
awaiting_completion_(false),
dest_buffer_(nullptr),
dest_buffer_size_(0) {}
MockSourceStream::~MockSourceStream() {
DCHECK(!awaiting_completion_);
- DCHECK(results_.empty());
+ // All data should have been consumed.
+ EXPECT_TRUE(results_.empty());
}
int MockSourceStream::Read(IOBuffer* dest_buffer,
@@ -58,10 +61,24 @@ void MockSourceStream::AddReadResult(const char* data,
int len,
Error error,
Mode mode) {
- // The read result must be between 0 and 32k (inclusive) because the read
- // buffer used in FilterSourceStream is 32k.
- DCHECK_GE(32 * 1024, len);
- DCHECK_LE(0, len);
+ if (error != OK) {
+ // Doesn't make any sense to have both an error and data.
+ DCHECK_EQ(len, 0);
+ } else {
+ // The read result must be between 0 and 32k (inclusive) because the read
+ // buffer used in FilterSourceStream is 32k.
+ DCHECK_GE(32 * 1024, len);
+ DCHECK_LE(0, len);
+ }
+
+ if (len > 0 && read_one_byte_at_a_time_) {
+ for (int i = 0; i < len; ++i) {
+ QueuedResult result(data + i, 1, OK, mode);
+ results_.push(result);
+ }
+ return;
+ }
+
QueuedResult result(data, len, error, mode);
results_.push(result);
}
« no previous file with comments | « net/filter/mock_source_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698