| 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 "content/browser/streams/stream_handle_impl.h" | 10 #include "content/browser/streams/stream_handle_impl.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 void Stream::RemoveWriteObserver(StreamWriteObserver* observer) { | 65 void Stream::RemoveWriteObserver(StreamWriteObserver* observer) { |
| 66 DCHECK(observer == write_observer_); | 66 DCHECK(observer == write_observer_); |
| 67 write_observer_ = NULL; | 67 write_observer_ = NULL; |
| 68 } | 68 } |
| 69 | 69 |
| 70 void Stream::AddData(scoped_refptr<net::IOBuffer> buffer, size_t size) { | 70 void Stream::AddData(scoped_refptr<net::IOBuffer> buffer, size_t size) { |
| 71 can_add_data_ = writer_->Write(buffer, size); | 71 can_add_data_ = writer_->Write(buffer, size); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void Stream::Finalize() { | 74 void Stream::Finalize() { |
| 75 writer_->Close(DOWNLOAD_INTERRUPT_REASON_NONE); | 75 writer_->Close(0 /* status */); |
| 76 writer_.reset(NULL); | 76 writer_.reset(NULL); |
| 77 | 77 |
| 78 // Continue asynchronously. | 78 // Continue asynchronously. |
| 79 base::MessageLoopProxy::current()->PostTask( | 79 base::MessageLoopProxy::current()->PostTask( |
| 80 FROM_HERE, | 80 FROM_HERE, |
| 81 base::Bind(&Stream::OnDataAvailable, weak_ptr_factory_.GetWeakPtr())); | 81 base::Bind(&Stream::OnDataAvailable, weak_ptr_factory_.GetWeakPtr())); |
| 82 } | 82 } |
| 83 | 83 |
| 84 Stream::StreamState Stream::ReadRawData(net::IOBuffer* buf, | 84 Stream::StreamState Stream::ReadRawData(net::IOBuffer* buf, |
| 85 int buf_size, | 85 int buf_size, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 if (write_observer_) | 138 if (write_observer_) |
| 139 write_observer_->OnSpaceAvailable(this); | 139 write_observer_->OnSpaceAvailable(this); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void Stream::OnDataAvailable() { | 142 void Stream::OnDataAvailable() { |
| 143 if (read_observer_) | 143 if (read_observer_) |
| 144 read_observer_->OnDataAvailable(this); | 144 read_observer_->OnDataAvailable(this); |
| 145 } | 145 } |
| 146 | 146 |
| 147 } // namespace content | 147 } // namespace content |
| OLD | NEW |