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 "media/base/media_log.h" | 8 #include "media/base/media_log.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... | |
35 read_size_(0), | 35 read_size_(0), |
36 read_buffer_(NULL), | 36 read_buffer_(NULL), |
37 intermediate_read_buffer_(new uint8[kInitialReadBufferSize]), | 37 intermediate_read_buffer_(new uint8[kInitialReadBufferSize]), |
38 intermediate_read_buffer_size_(kInitialReadBufferSize), | 38 intermediate_read_buffer_size_(kInitialReadBufferSize), |
39 render_loop_(render_loop), | 39 render_loop_(render_loop), |
40 stop_signal_received_(false), | 40 stop_signal_received_(false), |
41 stopped_on_render_loop_(false), | 41 stopped_on_render_loop_(false), |
42 media_is_paused_(true), | 42 media_is_paused_(true), |
43 media_has_played_(false), | 43 media_has_played_(false), |
44 preload_(media::AUTO), | 44 preload_(media::AUTO), |
45 using_range_request_(true), | 45 using_range_request_(true), |
acolwell GONE FROM CHROMIUM
2012/03/14 18:24:49
I think this can be removed now.
Ami GONE FROM CHROMIUM
2012/03/14 19:37:20
Done.
| |
46 cache_miss_retries_left_(kNumCacheMissRetries), | 46 cache_miss_retries_left_(kNumCacheMissRetries), |
47 bitrate_(0), | 47 bitrate_(0), |
48 playback_rate_(0.0), | 48 playback_rate_(0.0), |
49 media_log_(media_log) { | 49 media_log_(media_log) { |
50 } | 50 } |
51 | 51 |
52 BufferedDataSource::~BufferedDataSource() {} | 52 BufferedDataSource::~BufferedDataSource() {} |
53 | 53 |
54 // A factory method to create BufferedResourceLoader using the read parameters. | 54 // A factory method to create BufferedResourceLoader using the read parameters. |
55 // This method can be overrided to inject mock BufferedResourceLoader object | 55 // This method can be overrided to inject mock BufferedResourceLoader object |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 // TODO(hclam): Needs more thinking about supporting servers without range | 385 // TODO(hclam): Needs more thinking about supporting servers without range |
386 // request or their partial response is not complete. | 386 // request or their partial response is not complete. |
387 total_bytes_ = instance_size; | 387 total_bytes_ = instance_size; |
388 streaming_ = (instance_size == kPositionNotSpecified) || | 388 streaming_ = (instance_size == kPositionNotSpecified) || |
389 !loader_->range_supported(); | 389 !loader_->range_supported(); |
390 } else { | 390 } else { |
391 // TODO(hclam): In case of failure, we can retry several times. | 391 // TODO(hclam): In case of failure, we can retry several times. |
392 loader_->Stop(); | 392 loader_->Stop(); |
393 } | 393 } |
394 | 394 |
395 if (error == net::ERR_INVALID_RESPONSE && using_range_request_) { | |
396 // Assuming that the Range header was causing the problem. Retry without | |
397 // the Range header. | |
398 using_range_request_ = false; | |
399 loader_.reset(CreateResourceLoader(kPositionNotSpecified, | |
400 kPositionNotSpecified)); | |
401 loader_->Start( | |
402 base::Bind(&BufferedDataSource::HttpInitialStartCallback, this), | |
403 base::Bind(&BufferedDataSource::NetworkEventCallback, this), | |
404 frame_); | |
405 return; | |
406 } | |
407 | |
408 // Reference to prevent destruction while inside the |initialize_cb_| | 395 // Reference to prevent destruction while inside the |initialize_cb_| |
409 // call. This is a temporary fix to prevent crashes caused by holding the | 396 // call. This is a temporary fix to prevent crashes caused by holding the |
410 // lock and running the destructor. | 397 // lock and running the destructor. |
411 // TODO: Review locking in this class and figure out a way to run the callback | 398 // TODO: Review locking in this class and figure out a way to run the callback |
412 // w/o the lock. | 399 // w/o the lock. |
413 scoped_refptr<BufferedDataSource> destruction_guard(this); | 400 scoped_refptr<BufferedDataSource> destruction_guard(this); |
414 { | 401 { |
415 // We need to prevent calling to filter host and running the callback if | 402 // We need to prevent calling to filter host and running the callback if |
416 // we have received the stop signal. We need to lock down the whole callback | 403 // we have received the stop signal. We need to lock down the whole callback |
417 // method to prevent bad things from happening. The reason behind this is | 404 // method to prevent bad things from happening. The reason behind this is |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 | 594 |
608 if (!host()) | 595 if (!host()) |
609 return; | 596 return; |
610 | 597 |
611 if (total_bytes_ != kPositionNotSpecified) | 598 if (total_bytes_ != kPositionNotSpecified) |
612 host()->SetTotalBytes(total_bytes_); | 599 host()->SetTotalBytes(total_bytes_); |
613 host()->SetBufferedBytes(buffered_bytes_); | 600 host()->SetBufferedBytes(buffered_bytes_); |
614 } | 601 } |
615 | 602 |
616 } // namespace webkit_media | 603 } // namespace webkit_media |
OLD | NEW |