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

Unified Diff: net/filter/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: 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/stream_source.h
diff --git a/net/filter/stream_source.h b/net/filter/stream_source.h
new file mode 100644
index 0000000000000000000000000000000000000000..c9241cb717552d1144363a4c249fc9875fe302ba
--- /dev/null
+++ b/net/filter/stream_source.h
@@ -0,0 +1,59 @@
+// 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.
+
+#ifndef NET_FILTER_STREAM_SOURCE_H
+#define NET_FILTER_STREAM_SOURCE_H
+
+#include "base/callback.h"
+#include "net/base/io_buffer.h"
+#include "net/base/net_errors.h"
+
+namespace net {
+
+class SdchStreamSourceDelegate;
+
+// The StreamSource class implements a producer of bytes. Sources often
+// incorporate a previous source from which they read undecoded input. Those
+// which incorporate a previous source take ownership of the previous source
+// when they are created.
+class StreamSource {
+ public:
+ virtual ~StreamSource(){};
mmenke 2016/02/18 22:58:28 Remove semi-colon
xunjieli 2016/03/03 23:00:09 Done.
+ typedef base::Callback<void(net::Error, size_t)> OnReadCompleteCallback;
+
+ // Reads bytes from this source. This method can either complete synchronously
+ // or asynchronously. If it completes synchronously, it:
+ // - Returns an Error other than ERR_IO_PENDING
+ // - Writes |*bytes_read| with the count of bytes read
+ // - Writes bytes into |*dest_buffer|
+ // - Does not call |callback|
+ // If it completes asynchronously, it:
+ // - Returns ERR_IO_PENDING
+ // - Does not write |*bytes_read|
+ // - Calls |callback| when it does complete, with an error code and a count
+ // of bytes read, which are them placed into |*dest_buffer|.
+ // This method takes a reference to |*dest_buffer| if it completes
+ // asynchronously to ensure it does not get freed mid-read.
+ virtual net::Error Read(IOBuffer* dest_buffer,
+ size_t buffer_size,
+ size_t* bytes_read,
+ const OnReadCompleteCallback& callback) = 0;
+
+ // Returns how many bytes total have been returned by Read() of |this|.
+ virtual size_t GetBytesOutput() const = 0;
mmenke 2016/02/18 22:58:28 Is this method really needed? Can't the URLReques
+
+ // This method constructs a chain of StreamSources from a vector of
+ // Content-Type values and an SdchStreamSourceDelegate. If any of the
+ // constructed
+ // StreamSources are SdchStreamSources, they will be constructed with
+ // |delegate|.
+ static scoped_ptr<StreamSource> BuildSourceChain(
+ scoped_ptr<StreamSource> previous,
+ const std::vector<std::string>& type,
+ SdchStreamSourceDelegate* delegate);
+};
+
+} // namespace net
+
+#endif // NET_FILTER_STREAM_SOURCE_H

Powered by Google App Engine
This is Rietveld 408576698