OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/media/buffered_data_source.h" | 5 #include "webkit/media/buffered_data_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" |
8 #include "media/base/media_log.h" | 9 #include "media/base/media_log.h" |
9 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
10 | 11 |
11 using WebKit::WebFrame; | 12 using WebKit::WebFrame; |
12 | 13 |
13 namespace webkit_media { | 14 namespace webkit_media { |
14 | 15 |
15 // BufferedDataSource has an intermediate buffer, this value governs the initial | 16 // BufferedDataSource has an intermediate buffer, this value governs the initial |
16 // size of that buffer. It is set to 32KB because this is a typical read size | 17 // size of that buffer. It is set to 32KB because this is a typical read size |
17 // of FFmpeg. | 18 // of FFmpeg. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // the full range of the resource to obtain the instance size because | 101 // the full range of the resource to obtain the instance size because |
101 // we won't be served HTTP headers. | 102 // we won't be served HTTP headers. |
102 loader_.reset(CreateResourceLoader(kPositionNotSpecified, | 103 loader_.reset(CreateResourceLoader(kPositionNotSpecified, |
103 kPositionNotSpecified)); | 104 kPositionNotSpecified)); |
104 loader_->Start( | 105 loader_->Start( |
105 base::Bind(&BufferedDataSource::NonHttpInitialStartCallback, this), | 106 base::Bind(&BufferedDataSource::NonHttpInitialStartCallback, this), |
106 base::Bind(&BufferedDataSource::NetworkEventCallback, this), | 107 base::Bind(&BufferedDataSource::NetworkEventCallback, this), |
107 frame_); | 108 frame_); |
108 } | 109 } |
109 | 110 |
| 111 bool BufferedDataSource::HasSingleOrigin() { |
| 112 DCHECK(MessageLoop::current() == render_loop_); |
| 113 DCHECK(initialize_cb_.is_null() && loader_.get()) |
| 114 << "Initialize() must complete before calling HasSingleOrigin()"; |
| 115 return loader_->HasSingleOrigin(); |
| 116 } |
| 117 |
| 118 void BufferedDataSource::Abort() { |
| 119 DCHECK(MessageLoop::current() == render_loop_); |
| 120 |
| 121 CleanupTask(); |
| 122 frame_ = NULL; |
| 123 } |
| 124 |
110 ///////////////////////////////////////////////////////////////////////////// | 125 ///////////////////////////////////////////////////////////////////////////// |
111 // media::Filter implementation. | 126 // media::Filter implementation. |
112 void BufferedDataSource::Stop(const base::Closure& closure) { | 127 void BufferedDataSource::Stop(const base::Closure& closure) { |
113 { | 128 { |
114 base::AutoLock auto_lock(lock_); | 129 base::AutoLock auto_lock(lock_); |
115 stop_signal_received_ = true; | 130 stop_signal_received_ = true; |
116 } | 131 } |
117 if (!closure.is_null()) | 132 if (!closure.is_null()) |
118 closure.Run(); | 133 closure.Run(); |
119 | 134 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 return true; | 181 return true; |
167 } | 182 } |
168 *size_out = 0; | 183 *size_out = 0; |
169 return false; | 184 return false; |
170 } | 185 } |
171 | 186 |
172 bool BufferedDataSource::IsStreaming() { | 187 bool BufferedDataSource::IsStreaming() { |
173 return streaming_; | 188 return streaming_; |
174 } | 189 } |
175 | 190 |
176 bool BufferedDataSource::HasSingleOrigin() { | |
177 DCHECK(MessageLoop::current() == render_loop_); | |
178 return loader_.get() ? loader_->HasSingleOrigin() : true; | |
179 } | |
180 | |
181 void BufferedDataSource::Abort() { | |
182 DCHECK(MessageLoop::current() == render_loop_); | |
183 | |
184 CleanupTask(); | |
185 frame_ = NULL; | |
186 } | |
187 | |
188 ///////////////////////////////////////////////////////////////////////////// | 191 ///////////////////////////////////////////////////////////////////////////// |
189 // Render thread tasks. | 192 // Render thread tasks. |
190 void BufferedDataSource::ReadTask( | 193 void BufferedDataSource::ReadTask( |
191 int64 position, | 194 int64 position, |
192 int read_size, | 195 int read_size, |
193 uint8* buffer) { | 196 uint8* buffer) { |
194 DCHECK(MessageLoop::current() == render_loop_); | 197 DCHECK(MessageLoop::current() == render_loop_); |
195 { | 198 { |
196 base::AutoLock auto_lock(lock_); | 199 base::AutoLock auto_lock(lock_); |
197 if (stopped_on_render_loop_) | 200 if (stopped_on_render_loop_) |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 | 589 |
587 if (!host()) | 590 if (!host()) |
588 return; | 591 return; |
589 | 592 |
590 if (total_bytes_ != kPositionNotSpecified) | 593 if (total_bytes_ != kPositionNotSpecified) |
591 host()->SetTotalBytes(total_bytes_); | 594 host()->SetTotalBytes(total_bytes_); |
592 host()->SetBufferedBytes(buffered_bytes_); | 595 host()->SetBufferedBytes(buffered_bytes_); |
593 } | 596 } |
594 | 597 |
595 } // namespace webkit_media | 598 } // namespace webkit_media |
OLD | NEW |