Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 2821573002: Merge M58: "Don't histogram paint time after ending or seeking." (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 AsWeakPtr(), BUFFERING_HAVE_ENOUGH)); 545 AsWeakPtr(), BUFFERING_HAVE_ENOUGH));
546 } 546 }
547 return; 547 return;
548 } 548 }
549 549
550 // Call this before setting |seeking_| so that the current media time can be 550 // Call this before setting |seeking_| so that the current media time can be
551 // recorded by the reporter. 551 // recorded by the reporter.
552 if (watch_time_reporter_) 552 if (watch_time_reporter_)
553 watch_time_reporter_->OnSeeking(); 553 watch_time_reporter_->OnSeeking();
554 554
555 // Clear any new frame processed callbacks on seek; otherwise we'll end up
556 // logging a time long after the seek completes.
557 frame_time_report_cb_.Cancel();
558
555 // TODO(sandersd): Move |seeking_| to PipelineController. 559 // TODO(sandersd): Move |seeking_| to PipelineController.
556 // TODO(sandersd): Do we want to reset the idle timer here? 560 // TODO(sandersd): Do we want to reset the idle timer here?
557 delegate_->SetIdle(delegate_id_, false); 561 delegate_->SetIdle(delegate_id_, false);
558 ended_ = false; 562 ended_ = false;
559 seeking_ = true; 563 seeking_ = true;
560 seek_time_ = time; 564 seek_time_ = time;
561 if (paused_) 565 if (paused_)
562 paused_time_ = time; 566 paused_time_ = time;
563 pipeline_controller_.Seek(time, time_updated); 567 pipeline_controller_.Seek(time, time_updated);
564 568
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 DVLOG(1) << __func__; 1247 DVLOG(1) << __func__;
1244 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1248 DCHECK(main_task_runner_->BelongsToCurrentThread());
1245 1249
1246 // Ignore state changes until we've completed all outstanding operations. 1250 // Ignore state changes until we've completed all outstanding operations.
1247 if (!pipeline_controller_.IsStable()) 1251 if (!pipeline_controller_.IsStable())
1248 return; 1252 return;
1249 1253
1250 ended_ = true; 1254 ended_ = true;
1251 client_->timeChanged(); 1255 client_->timeChanged();
1252 1256
1257 // Clear any new frame processed callbacks on end; otherwise we'll end up
1258 // logging a time long after playback ends.
1259 frame_time_report_cb_.Cancel();
1260
1253 // We don't actually want this to run until |client_| calls seek() or pause(), 1261 // We don't actually want this to run until |client_| calls seek() or pause(),
1254 // but that should have already happened in timeChanged() and so this is 1262 // but that should have already happened in timeChanged() and so this is
1255 // expected to be a no-op. 1263 // expected to be a no-op.
1256 UpdatePlayState(); 1264 UpdatePlayState();
1257 } 1265 }
1258 1266
1259 void WebMediaPlayerImpl::OnMetadata(PipelineMetadata metadata) { 1267 void WebMediaPlayerImpl::OnMetadata(PipelineMetadata metadata) {
1260 DVLOG(1) << __func__; 1268 DVLOG(1) << __func__;
1261 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1269 DCHECK(main_task_runner_->BelongsToCurrentThread());
1262 1270
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 video_locked_when_paused_when_hidden_ = false; 1481 video_locked_when_paused_when_hidden_ = false;
1474 1482
1475 if (watch_time_reporter_) 1483 if (watch_time_reporter_)
1476 watch_time_reporter_->OnShown(); 1484 watch_time_reporter_->OnShown();
1477 1485
1478 // Only track the time to the first frame if playing or about to play because 1486 // Only track the time to the first frame if playing or about to play because
1479 // of being shown and only for videos we would optimize background playback 1487 // of being shown and only for videos we would optimize background playback
1480 // for. 1488 // for.
1481 if ((!paused_ && IsBackgroundOptimizationCandidate()) || 1489 if ((!paused_ && IsBackgroundOptimizationCandidate()) ||
1482 paused_when_hidden_) { 1490 paused_when_hidden_) {
1483 VideoFrameCompositor::OnNewProcessedFrameCB new_processed_frame_cb = 1491 frame_time_report_cb_.Reset(
1484 BindToCurrentLoop(base::Bind( 1492 base::Bind(&WebMediaPlayerImpl::ReportTimeFromForegroundToFirstFrame,
1485 &WebMediaPlayerImpl::ReportTimeFromForegroundToFirstFrame, 1493 AsWeakPtr(), base::TimeTicks::Now()));
1486 AsWeakPtr(), base::TimeTicks::Now()));
1487 compositor_task_runner_->PostTask( 1494 compositor_task_runner_->PostTask(
1488 FROM_HERE, 1495 FROM_HERE,
1489 base::Bind(&VideoFrameCompositor::SetOnNewProcessedFrameCallback, 1496 base::Bind(&VideoFrameCompositor::SetOnNewProcessedFrameCallback,
1490 base::Unretained(compositor_), new_processed_frame_cb)); 1497 base::Unretained(compositor_),
1498 BindToCurrentLoop(frame_time_report_cb_.callback())));
1491 } 1499 }
1492 1500
1493 EnableVideoTrackIfNeeded(); 1501 EnableVideoTrackIfNeeded();
1494 1502
1495 if (paused_when_hidden_) { 1503 if (paused_when_hidden_) {
1496 paused_when_hidden_ = false; 1504 paused_when_hidden_ = false;
1497 OnPlay(); // Calls UpdatePlayState() so return afterwards. 1505 OnPlay(); // Calls UpdatePlayState() so return afterwards.
1498 return; 1506 return;
1499 } 1507 }
1500 1508
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
2338 2346
2339 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { 2347 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) {
2340 DCHECK(data_source_ || chunk_demuxer_); 2348 DCHECK(data_source_ || chunk_demuxer_);
2341 if (data_source_) 2349 if (data_source_)
2342 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); 2350 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration);
2343 else 2351 else
2344 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); 2352 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration);
2345 } 2353 }
2346 2354
2347 } // namespace media 2355 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698