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_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "content/browser/streams/stream_handle_impl.h" | 10 #include "content/browser/streams/stream_handle_impl.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Continue asynchronously. | 80 // Continue asynchronously. |
81 base::MessageLoopProxy::current()->PostTask( | 81 base::MessageLoopProxy::current()->PostTask( |
82 FROM_HERE, | 82 FROM_HERE, |
83 base::Bind(&Stream::OnDataAvailable, weak_ptr_factory_.GetWeakPtr())); | 83 base::Bind(&Stream::OnDataAvailable, weak_ptr_factory_.GetWeakPtr())); |
84 } | 84 } |
85 | 85 |
86 Stream::StreamState Stream::ReadRawData(net::IOBuffer* buf, | 86 Stream::StreamState Stream::ReadRawData(net::IOBuffer* buf, |
87 int buf_size, | 87 int buf_size, |
88 int* bytes_read) { | 88 int* bytes_read) { |
89 *bytes_read = 0; | 89 *bytes_read = 0; |
90 if (!data_) { | 90 if (!data_.get()) { |
91 data_length_ = 0; | 91 data_length_ = 0; |
92 data_bytes_read_ = 0; | 92 data_bytes_read_ = 0; |
93 ByteStreamReader::StreamState state = reader_->Read(&data_, &data_length_); | 93 ByteStreamReader::StreamState state = reader_->Read(&data_, &data_length_); |
94 switch (state) { | 94 switch (state) { |
95 case ByteStreamReader::STREAM_HAS_DATA: | 95 case ByteStreamReader::STREAM_HAS_DATA: |
96 break; | 96 break; |
97 case ByteStreamReader::STREAM_COMPLETE: | 97 case ByteStreamReader::STREAM_COMPLETE: |
98 registry_->UnregisterStream(url()); | 98 registry_->UnregisterStream(url()); |
99 return STREAM_COMPLETE; | 99 return STREAM_COMPLETE; |
100 case ByteStreamReader::STREAM_EMPTY: | 100 case ByteStreamReader::STREAM_EMPTY: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 write_observer_->OnSpaceAvailable(this); | 141 write_observer_->OnSpaceAvailable(this); |
142 } | 142 } |
143 | 143 |
144 void Stream::OnDataAvailable() { | 144 void Stream::OnDataAvailable() { |
145 if (read_observer_) | 145 if (read_observer_) |
146 read_observer_->OnDataAvailable(this); | 146 read_observer_->OnDataAvailable(this); |
147 } | 147 } |
148 | 148 |
149 } // namespace content | 149 } // namespace content |
150 | 150 |
OLD | NEW |