OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer/media/buffered_data_source_host_impl.h" | 5 #include "content/renderer/media/buffered_data_source_host_impl.h" |
6 | 6 |
7 namespace content { | 7 namespace content { |
8 | 8 |
9 BufferedDataSourceHostImpl::BufferedDataSourceHostImpl() | 9 BufferedDataSourceHostImpl::BufferedDataSourceHostImpl() |
10 : total_bytes_(0), | 10 : total_bytes_(0), |
(...skipping 17 matching lines...) Expand all Loading... |
28 if (position < 0.01) | 28 if (position < 0.01) |
29 return base::TimeDelta(); | 29 return base::TimeDelta(); |
30 if (position > 0.99) | 30 if (position > 0.99) |
31 return duration; | 31 return duration; |
32 return base::TimeDelta::FromMilliseconds( | 32 return base::TimeDelta::FromMilliseconds( |
33 static_cast<int64>(position * duration.InMilliseconds())); | 33 static_cast<int64>(position * duration.InMilliseconds())); |
34 } | 34 } |
35 | 35 |
36 void BufferedDataSourceHostImpl::AddBufferedTimeRanges( | 36 void BufferedDataSourceHostImpl::AddBufferedTimeRanges( |
37 media::Ranges<base::TimeDelta>* buffered_time_ranges, | 37 media::Ranges<base::TimeDelta>* buffered_time_ranges, |
38 base::TimeDelta media_duration) { | 38 base::TimeDelta media_duration) const { |
39 if (total_bytes_ && buffered_byte_ranges_.size()) { | 39 if (total_bytes_ && buffered_byte_ranges_.size()) { |
40 for (size_t i = 0; i < buffered_byte_ranges_.size(); ++i) { | 40 for (size_t i = 0; i < buffered_byte_ranges_.size(); ++i) { |
41 int64 start = buffered_byte_ranges_.start(i); | 41 int64 start = buffered_byte_ranges_.start(i); |
42 int64 end = buffered_byte_ranges_.end(i); | 42 int64 end = buffered_byte_ranges_.end(i); |
43 buffered_time_ranges->Add( | 43 buffered_time_ranges->Add( |
44 TimeForByteOffset(start, total_bytes_, media_duration), | 44 TimeForByteOffset(start, total_bytes_, media_duration), |
45 TimeForByteOffset(end, total_bytes_, media_duration)); | 45 TimeForByteOffset(end, total_bytes_, media_duration)); |
46 } | 46 } |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 bool BufferedDataSourceHostImpl::DidLoadingProgress() { | 50 bool BufferedDataSourceHostImpl::DidLoadingProgress() { |
51 bool ret = did_loading_progress_; | 51 bool ret = did_loading_progress_; |
52 did_loading_progress_ = false; | 52 did_loading_progress_ = false; |
53 return ret; | 53 return ret; |
54 } | 54 } |
55 | 55 |
56 } // namespace content | 56 } // namespace content |
OLD | NEW |