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 return loader_.get() ? loader_->HasSingleOrigin() : true; | |
Ami GONE FROM CHROMIUM
2012/03/27 05:16:19
(predates your CL, but)
Is it right to default ope
scherkus (not reviewing)
2012/03/27 14:10:06
Good catch!
Technically we can get a false value
| |
114 } | |
115 | |
116 void BufferedDataSource::Abort() { | |
117 DCHECK(MessageLoop::current() == render_loop_); | |
118 | |
119 CleanupTask(); | |
120 frame_ = NULL; | |
121 } | |
122 | |
110 ///////////////////////////////////////////////////////////////////////////// | 123 ///////////////////////////////////////////////////////////////////////////// |
111 // media::Filter implementation. | 124 // media::Filter implementation. |
112 void BufferedDataSource::Stop(const base::Closure& closure) { | 125 void BufferedDataSource::Stop(const base::Closure& closure) { |
113 { | 126 { |
114 base::AutoLock auto_lock(lock_); | 127 base::AutoLock auto_lock(lock_); |
115 stop_signal_received_ = true; | 128 stop_signal_received_ = true; |
116 } | 129 } |
117 if (!closure.is_null()) | 130 if (!closure.is_null()) |
118 closure.Run(); | 131 closure.Run(); |
119 | 132 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 return true; | 180 return true; |
168 } | 181 } |
169 *size_out = 0; | 182 *size_out = 0; |
170 return false; | 183 return false; |
171 } | 184 } |
172 | 185 |
173 bool BufferedDataSource::IsStreaming() { | 186 bool BufferedDataSource::IsStreaming() { |
174 return streaming_; | 187 return streaming_; |
175 } | 188 } |
176 | 189 |
177 bool BufferedDataSource::HasSingleOrigin() { | |
178 DCHECK(MessageLoop::current() == render_loop_); | |
179 return loader_.get() ? loader_->HasSingleOrigin() : true; | |
180 } | |
181 | |
182 void BufferedDataSource::Abort() { | |
183 DCHECK(MessageLoop::current() == render_loop_); | |
184 | |
185 CleanupTask(); | |
186 frame_ = NULL; | |
187 } | |
188 | |
189 ///////////////////////////////////////////////////////////////////////////// | 190 ///////////////////////////////////////////////////////////////////////////// |
190 // Render thread tasks. | 191 // Render thread tasks. |
191 void BufferedDataSource::ReadTask( | 192 void BufferedDataSource::ReadTask( |
192 int64 position, | 193 int64 position, |
193 int read_size, | 194 int read_size, |
194 uint8* buffer) { | 195 uint8* buffer) { |
195 DCHECK(MessageLoop::current() == render_loop_); | 196 DCHECK(MessageLoop::current() == render_loop_); |
196 { | 197 { |
197 base::AutoLock auto_lock(lock_); | 198 base::AutoLock auto_lock(lock_); |
198 if (stopped_on_render_loop_) | 199 if (stopped_on_render_loop_) |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 | 588 |
588 if (!host()) | 589 if (!host()) |
589 return; | 590 return; |
590 | 591 |
591 if (total_bytes_ != kPositionNotSpecified) | 592 if (total_bytes_ != kPositionNotSpecified) |
592 host()->SetTotalBytes(total_bytes_); | 593 host()->SetTotalBytes(total_bytes_); |
593 host()->SetBufferedBytes(buffered_bytes_); | 594 host()->SetBufferedBytes(buffered_bytes_); |
594 } | 595 } |
595 | 596 |
596 } // namespace webkit_media | 597 } // namespace webkit_media |
OLD | NEW |