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

Side by Side Diff: content/browser/streams/stream.h

Issue 22908008: Limit the total memory usage for Stream instances (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: creis's comments 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 | « content/browser/fileapi/fileapi_message_filter.cc ('k') | content/browser/streams/stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_STREAMS_STREAM_H_ 5 #ifndef CONTENT_BROWSER_STREAMS_STREAM_H_
6 #define CONTENT_BROWSER_STREAMS_STREAM_H_ 6 #define CONTENT_BROWSER_STREAMS_STREAM_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 scoped_ptr<StreamHandle> CreateHandle(const GURL& original_url, 75 scoped_ptr<StreamHandle> CreateHandle(const GURL& original_url,
76 const std::string& mime_type); 76 const std::string& mime_type);
77 void CloseHandle(); 77 void CloseHandle();
78 78
79 // Indicates whether there is space in the buffer to add more data. 79 // Indicates whether there is space in the buffer to add more data.
80 bool can_add_data() const { return can_add_data_; } 80 bool can_add_data() const { return can_add_data_; }
81 81
82 const GURL& url() const { return url_; } 82 const GURL& url() const { return url_; }
83 83
84 // For StreamRegistry to remember the last memory usage reported to it.
85 size_t last_total_buffered_bytes() const {
86 return last_total_buffered_bytes_;
87 }
88
84 private: 89 private:
85 friend class base::RefCountedThreadSafe<Stream>; 90 friend class base::RefCountedThreadSafe<Stream>;
86 91
87 virtual ~Stream(); 92 virtual ~Stream();
88 93
89 void OnSpaceAvailable(); 94 void OnSpaceAvailable();
90 void OnDataAvailable(); 95 void OnDataAvailable();
91 96
97 void Abort();
98
92 size_t data_bytes_read_; 99 size_t data_bytes_read_;
93 bool can_add_data_; 100 bool can_add_data_;
94 101
95 GURL url_; 102 GURL url_;
96 103
97 scoped_refptr<net::IOBuffer> data_; 104 scoped_refptr<net::IOBuffer> data_;
98 size_t data_length_; 105 size_t data_length_;
99 106
107 // Last value returned by writer_->TotalBufferedBytes() in AddData(). Stored
108 // in order to check memory usage.
109 size_t last_total_buffered_bytes_;
110
100 scoped_ptr<ByteStreamWriter> writer_; 111 scoped_ptr<ByteStreamWriter> writer_;
101 scoped_ptr<ByteStreamReader> reader_; 112 scoped_ptr<ByteStreamReader> reader_;
102 113
103 StreamRegistry* registry_; 114 StreamRegistry* registry_;
104 StreamReadObserver* read_observer_; 115 StreamReadObserver* read_observer_;
105 StreamWriteObserver* write_observer_; 116 StreamWriteObserver* write_observer_;
106 117
107 StreamHandleImpl* stream_handle_; 118 StreamHandleImpl* stream_handle_;
108 119
109 base::WeakPtrFactory<Stream> weak_ptr_factory_; 120 base::WeakPtrFactory<Stream> weak_ptr_factory_;
110 DISALLOW_COPY_AND_ASSIGN(Stream); 121 DISALLOW_COPY_AND_ASSIGN(Stream);
111 }; 122 };
112 123
113 } // namespace content 124 } // namespace content
114 125
115 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_ 126 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_
OLDNEW
« no previous file with comments | « content/browser/fileapi/fileapi_message_filter.cc ('k') | content/browser/streams/stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698