OLD | NEW |
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 Loading... |
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_ |
OLD | NEW |