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

Unified Diff: net/filter/brotli_stream_source.h

Issue 1662763002: [ON HOLD] Implement pull-based design for content decoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor common logic Created 4 years, 10 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
Index: net/filter/brotli_stream_source.h
diff --git a/net/filter/brotli_stream_source.h b/net/filter/brotli_stream_source.h
new file mode 100644
index 0000000000000000000000000000000000000000..c904f61409ffa0c48c3d7c123e9a1b351c0fb693
--- /dev/null
+++ b/net/filter/brotli_stream_source.h
@@ -0,0 +1,54 @@
+// Copyright 2016 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 "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "net/filter/stream_source.h"
+#include "third_party/brotli/dec/decode.h"
+
+#ifndef NET_FILTER_BROTLI_STREAM_SOURCE_H__
+#define NET_FILTER_BROTLI_STREAM_SOURCE_H__
+namespace net {
+
+class BlockBuffer;
+
+class BrotliStreamSource : public StreamSource {
+ public:
+ BrotliStreamSource(scoped_ptr<StreamSource> previous);
+ ~BrotliStreamSource() override;
+
+ private:
+ // Reported in UMA and must be kept in sync with the histograms.xml file.
+ enum class DecodingStatus : int {
+ DECODING_IN_PROGRESS = 0,
+ DECODING_DONE,
+ DECODING_ERROR,
+
+ DECODING_STATUS_COUNT
+ // DECODING_STATUS_COUNT must always be the last element in this enum.
+ };
+ // StreamSource implementation
+ net::Error ReadInternal(IOBuffer* dest_buffer,
+ size_t buffer_size,
+ size_t* bytes_read) override;
+ static void* AllocateMemory(void* opaque, size_t size);
+ static void FreeMemory(void* opaque, void* address);
+ void* AllocateMemoryInternal(size_t size);
+
+ void FreeMemoryInternal(void* address);
+
+ BrotliState* brotli_state_;
+
+ DecodingStatus decoding_status_;
+
+ size_t used_memory_;
+ size_t used_memory_maximum_;
+ size_t produced_bytes_;
+ size_t consumed_bytes_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrotliStreamSource);
+};
+
+#endif // NET_FILTER_BROTLI_STREAM_SOURCE_H__
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698