OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "media/base/download_rate_monitor.h" | 5 #include "media/base/download_rate_monitor.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 start_ = end_; | 67 start_ = end_; |
68 end_ = BufferingPoint(); | 68 end_ = BufferingPoint(); |
69 } | 69 } |
70 | 70 |
71 DownloadRateMonitor::DownloadRateMonitor() { | 71 DownloadRateMonitor::DownloadRateMonitor() { |
72 Reset(); | 72 Reset(); |
73 } | 73 } |
74 | 74 |
75 void DownloadRateMonitor::Start( | 75 void DownloadRateMonitor::Start( |
76 const base::Closure& canplaythrough_cb, int media_bitrate) { | 76 const base::Closure& canplaythrough_cb, int media_bitrate) { |
77 DCHECK(stopped_); | |
78 canplaythrough_cb_ = canplaythrough_cb; | 77 canplaythrough_cb_ = canplaythrough_cb; |
79 stopped_ = false; | 78 stopped_ = false; |
80 bitrate_ = media_bitrate; | 79 bitrate_ = media_bitrate; |
81 current_sample_.Reset(); | 80 current_sample_.Reset(); |
82 buffered_bytes_ = 0; | 81 buffered_bytes_ = 0; |
83 | 82 |
84 NotifyCanPlayThroughIfNeeded(); | 83 NotifyCanPlayThroughIfNeeded(); |
85 } | 84 } |
86 | 85 |
87 void DownloadRateMonitor::SetBufferedBytes( | 86 void DownloadRateMonitor::SetBufferedBytes( |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 240 } |
242 | 241 |
243 void DownloadRateMonitor::NotifyCanPlayThroughIfNeeded() { | 242 void DownloadRateMonitor::NotifyCanPlayThroughIfNeeded() { |
244 if (ShouldNotifyCanPlayThrough() && !canplaythrough_cb_.is_null()) { | 243 if (ShouldNotifyCanPlayThrough() && !canplaythrough_cb_.is_null()) { |
245 canplaythrough_cb_.Run(); | 244 canplaythrough_cb_.Run(); |
246 has_notified_can_play_through_ = true; | 245 has_notified_can_play_through_ = true; |
247 } | 246 } |
248 } | 247 } |
249 | 248 |
250 } // namespace media | 249 } // namespace media |
OLD | NEW |