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 #include "content/browser/streams/stream.h" | 5 #include "content/browser/streams/stream.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 void Stream::AddData(const char* data, size_t size) { | 102 void Stream::AddData(const char* data, size_t size) { |
103 if (!writer_.get()) | 103 if (!writer_.get()) |
104 return; | 104 return; |
105 | 105 |
106 scoped_refptr<net::IOBuffer> io_buffer(new net::IOBuffer(size)); | 106 scoped_refptr<net::IOBuffer> io_buffer(new net::IOBuffer(size)); |
107 memcpy(io_buffer->data(), data, size); | 107 memcpy(io_buffer->data(), data, size); |
108 AddData(io_buffer, size); | 108 AddData(io_buffer, size); |
109 } | 109 } |
110 | 110 |
| 111 void Stream::Flush() { |
| 112 if (!writer_.get()) |
| 113 return; |
| 114 writer_->Flush(); |
| 115 } |
| 116 |
111 void Stream::Finalize() { | 117 void Stream::Finalize() { |
112 if (!writer_.get()) | 118 if (!writer_.get()) |
113 return; | 119 return; |
114 | 120 |
115 writer_->Close(0); | 121 writer_->Close(0); |
116 writer_.reset(); | 122 writer_.reset(); |
117 | 123 |
118 // Continue asynchronously. | 124 // Continue asynchronously. |
119 base::MessageLoopProxy::current()->PostTask( | 125 base::MessageLoopProxy::current()->PostTask( |
120 FROM_HERE, | 126 FROM_HERE, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 read_observer_->OnDataAvailable(this); | 194 read_observer_->OnDataAvailable(this); |
189 } | 195 } |
190 | 196 |
191 void Stream::ClearBuffer() { | 197 void Stream::ClearBuffer() { |
192 data_ = NULL; | 198 data_ = NULL; |
193 data_length_ = 0; | 199 data_length_ = 0; |
194 data_bytes_read_ = 0; | 200 data_bytes_read_ = 0; |
195 } | 201 } |
196 | 202 |
197 } // namespace content | 203 } // namespace content |
OLD | NEW |