OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/process_util.h" | 7 #include "base/process_util.h" |
8 #include "chrome/renderer/media/data_source_impl.h" | 8 #include "chrome/renderer/media/data_source_impl.h" |
9 #include "chrome/renderer/render_view.h" | 9 #include "chrome/renderer/render_view.h" |
10 #include "chrome/renderer/webmediaplayer_delegate_impl.h" | 10 #include "chrome/renderer/webmediaplayer_delegate_impl.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 | 209 |
210 void DataSourceImpl::OnInitialize(std::string uri) { | 210 void DataSourceImpl::OnInitialize(std::string uri) { |
211 uri_ = uri; | 211 uri_ = uri; |
212 // Create the resource loader bridge. | 212 // Create the resource loader bridge. |
213 resource_loader_bridge_ = | 213 resource_loader_bridge_ = |
214 RenderThread::current()->resource_dispatcher()->CreateBridge( | 214 RenderThread::current()->resource_dispatcher()->CreateBridge( |
215 "GET", | 215 "GET", |
216 GURL(uri), | 216 GURL(uri), |
217 GURL(uri), | 217 GURL(uri), |
218 GURL(), // TODO(hclam): provide referer here. | 218 GURL(), // TODO(hclam): provide referer here. |
219 "null", // TODO(abarth): provide frame_origin | 219 "null", // TODO(abarth): provide frame_origin |
220 "null", // TODO(abarth): provide main_frame_origin | 220 "null", // TODO(abarth): provide main_frame_origin |
221 std::string(), // Provide no header. | 221 std::string(), // Provide no header. |
222 // Prefer to load from cache, also enable downloading the file, the | 222 // Prefer to load from cache, also enable downloading the file, the |
223 // resource will be saved to a single response data file if it's possible. | 223 // resource will be saved to a single response data file if it's possible. |
224 net::LOAD_PREFERRING_CACHE | net::LOAD_ENABLE_DOWNLOAD_FILE, | 224 net::LOAD_PREFERRING_CACHE | net::LOAD_ENABLE_DOWNLOAD_FILE, |
225 base::GetCurrentProcId(), | 225 base::GetCurrentProcId(), |
226 ResourceType::MEDIA, | 226 ResourceType::MEDIA, |
227 0, | 227 0, |
228 delegate_->view()->routing_id()); | 228 delegate_->view()->routing_id()); |
229 // Start the resource loading. | 229 // Start the resource loading. |
230 resource_loader_bridge_->Start(this); | 230 resource_loader_bridge_->Start(this); |
231 } | 231 } |
232 | 232 |
233 void DataSourceImpl::ReleaseRendererResources() { | 233 void DataSourceImpl::ReleaseRendererResources() { |
234 DCHECK(MessageLoop::current() == render_loop_); | 234 DCHECK(MessageLoop::current() == render_loop_); |
235 if (resource_loader_bridge_) { | 235 if (resource_loader_bridge_) { |
236 resource_loader_bridge_->Cancel(); | 236 resource_loader_bridge_->Cancel(); |
237 resource_loader_bridge_ = NULL; | 237 resource_loader_bridge_ = NULL; |
238 } | 238 } |
239 resource_release_event_.Signal(); | 239 resource_release_event_.Signal(); |
240 } | 240 } |
241 | 241 |
242 void DataSourceImpl::OnDownloadProgress(uint64 position, uint64 size) { | 242 void DataSourceImpl::OnDownloadProgress(uint64 position, uint64 size) { |
243 { | 243 { |
244 AutoLock auto_lock(lock_); | 244 AutoLock auto_lock(lock_); |
245 downloaded_bytes_ = position; | 245 downloaded_bytes_ = position; |
246 if (!total_bytes_known_) { | 246 if (!total_bytes_known_) { |
247 if (size == kuint64max) | 247 if (size == kuint64max) { |
248 total_bytes_ = position; | 248 total_bytes_ = position; |
249 else { | 249 } else { |
250 total_bytes_ = size; | 250 total_bytes_ = size; |
251 total_bytes_known_ = true; | 251 total_bytes_known_ = true; |
252 } | 252 } |
253 } | 253 } |
254 } | 254 } |
255 download_event_.Signal(); | 255 download_event_.Signal(); |
256 } | 256 } |
257 | 257 |
258 void DataSourceImpl::OnUploadProgress(uint64 position, uint64 size) { | 258 void DataSourceImpl::OnUploadProgress(uint64 position, uint64 size) { |
259 // We don't care about upload progress. | 259 // We don't care about upload progress. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 host_->Error(media::PIPELINE_ERROR_NETWORK); | 301 host_->Error(media::PIPELINE_ERROR_NETWORK); |
302 } else { | 302 } else { |
303 // TODO(hclam): notify end of stream to pipeline. | 303 // TODO(hclam): notify end of stream to pipeline. |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 std::string DataSourceImpl::GetURLForDebugging() { | 307 std::string DataSourceImpl::GetURLForDebugging() { |
308 return uri_; | 308 return uri_; |
309 } | 309 } |
310 | 310 |
311 const media::MediaFormat* DataSourceImpl::GetMediaFormat() { | 311 const media::MediaFormat& DataSourceImpl::media_format() { |
312 return &media_format_; | 312 return media_format_; |
313 } | 313 } |
OLD | NEW |