| 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" |
| 11 #include "content/browser/streams/stream_read_observer.h" | 11 #include "content/browser/streams/stream_read_observer.h" |
| 12 #include "content/browser/streams/stream_registry.h" | 12 #include "content/browser/streams/stream_registry.h" |
| 13 #include "content/browser/streams/stream_write_observer.h" | 13 #include "content/browser/streams/stream_write_observer.h" |
| 14 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 // Start throttling the connection at about 1MB. | 17 // Start throttling the connection at about 1MB. |
| 18 const size_t kDeferSizeThreshold = 40 * 32768; | 18 const size_t kDeferSizeThreshold = 40 * 32768; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 Stream::Stream(StreamRegistry* registry, | 23 Stream::Stream(StreamRegistry* registry, |
| 24 StreamWriteObserver* write_observer, | 24 StreamWriteObserver* write_observer, |
| 25 const GURL& security_origin, | |
| 26 const GURL& url) | 25 const GURL& url) |
| 27 : data_bytes_read_(0), | 26 : data_bytes_read_(0), |
| 28 can_add_data_(true), | 27 can_add_data_(true), |
| 29 security_origin_(security_origin), | |
| 30 url_(url), | 28 url_(url), |
| 31 data_length_(0), | 29 data_length_(0), |
| 32 registry_(registry), | 30 registry_(registry), |
| 33 read_observer_(NULL), | 31 read_observer_(NULL), |
| 34 write_observer_(write_observer), | 32 write_observer_(write_observer), |
| 35 stream_handle_(NULL), | 33 stream_handle_(NULL), |
| 36 weak_ptr_factory_(this) { | 34 weak_ptr_factory_(this) { |
| 37 CreateByteStream(base::MessageLoopProxy::current(), | 35 CreateByteStream(base::MessageLoopProxy::current(), |
| 38 base::MessageLoopProxy::current(), | 36 base::MessageLoopProxy::current(), |
| 39 kDeferSizeThreshold, | 37 kDeferSizeThreshold, |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 if (write_observer_) | 138 if (write_observer_) |
| 141 write_observer_->OnSpaceAvailable(this); | 139 write_observer_->OnSpaceAvailable(this); |
| 142 } | 140 } |
| 143 | 141 |
| 144 void Stream::OnDataAvailable() { | 142 void Stream::OnDataAvailable() { |
| 145 if (read_observer_) | 143 if (read_observer_) |
| 146 read_observer_->OnDataAvailable(this); | 144 read_observer_->OnDataAvailable(this); |
| 147 } | 145 } |
| 148 | 146 |
| 149 } // namespace content | 147 } // namespace content |
| 150 | |
| OLD | NEW |