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

Side by Side Diff: content/browser/byte_stream.h

Issue 22908008: Limit the total memory usage for Stream instances (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/byte_stream.cc » ('j') | content/browser/byte_stream.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_BYTE_STREAM_H_ 5 #ifndef CONTENT_BROWSER_BYTE_STREAM_H_
6 #define CONTENT_BROWSER_BYTE_STREAM_H_ 6 #define CONTENT_BROWSER_BYTE_STREAM_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // full to having space available. The callback will always be 146 // full to having space available. The callback will always be
147 // called on the task runner associated with the ByteStreamWriter. 147 // called on the task runner associated with the ByteStreamWriter.
148 // This callback will only be called if a call to Write has previously 148 // This callback will only be called if a call to Write has previously
149 // returned false (i.e. the ByteStream has been filled). 149 // returned false (i.e. the ByteStream has been filled).
150 // Multiple calls to this function are supported, though note that it 150 // Multiple calls to this function are supported, though note that it
151 // is the callers responsibility to handle races with space becoming 151 // is the callers responsibility to handle races with space becoming
152 // available (i.e. in the case of that race either of the before 152 // available (i.e. in the case of that race either of the before
153 // or after callbacks may be called). 153 // or after callbacks may be called).
154 // The callback will not be called after ByteStreamWriter destruction. 154 // The callback will not be called after ByteStreamWriter destruction.
155 virtual void RegisterCallback(const base::Closure& source_callback) = 0; 155 virtual void RegisterCallback(const base::Closure& source_callback) = 0;
156
157 // Returns the number of bytes sent to the reader but not yet reported by
158 // the reader as read.
159 virtual size_t TotalBufferedBytes() const = 0;
kinuko 2013/08/14 09:32:23 nit: GetTotalBufferedBytes() per naming convention
tyoshino (SeeGerritForStatus) 2013/08/15 04:15:33 Done.
156 }; 160 };
157 161
158 class CONTENT_EXPORT ByteStreamReader { 162 class CONTENT_EXPORT ByteStreamReader {
159 public: 163 public:
160 // Inverse of the fraction of the stream buffer that must be empty before 164 // Inverse of the fraction of the stream buffer that must be empty before
161 // a notification is send to paired Writer that there's more room. 165 // a notification is send to paired Writer that there's more room.
162 static const int kFractionReadBeforeWindowUpdate; 166 static const int kFractionReadBeforeWindowUpdate;
163 167
164 enum StreamState { STREAM_EMPTY, STREAM_HAS_DATA, STREAM_COMPLETE }; 168 enum StreamState { STREAM_EMPTY, STREAM_HAS_DATA, STREAM_COMPLETE };
165 169
(...skipping 24 matching lines...) Expand all
190 CONTENT_EXPORT void CreateByteStream( 194 CONTENT_EXPORT void CreateByteStream(
191 scoped_refptr<base::SequencedTaskRunner> input_task_runner, 195 scoped_refptr<base::SequencedTaskRunner> input_task_runner,
192 scoped_refptr<base::SequencedTaskRunner> output_task_runner, 196 scoped_refptr<base::SequencedTaskRunner> output_task_runner,
193 size_t buffer_size, 197 size_t buffer_size,
194 scoped_ptr<ByteStreamWriter>* input, 198 scoped_ptr<ByteStreamWriter>* input,
195 scoped_ptr<ByteStreamReader>* output); 199 scoped_ptr<ByteStreamReader>* output);
196 200
197 } // namespace content 201 } // namespace content
198 202
199 #endif // CONTENT_BROWSER_BYTE_STREAM_H_ 203 #endif // CONTENT_BROWSER_BYTE_STREAM_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/byte_stream.cc » ('j') | content/browser/byte_stream.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698