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

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

Issue 2568303002: Report WMPI components memory usage to UMA (Closed)
Patch Set: nits Created 4 years 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 | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | 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 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 base::Bind(&WebMediaPlayerImpl::FinishMemoryUsageReport, AsWeakPtr())); 1925 base::Bind(&WebMediaPlayerImpl::FinishMemoryUsageReport, AsWeakPtr()));
1926 } else { 1926 } else {
1927 FinishMemoryUsageReport(0); 1927 FinishMemoryUsageReport(0);
1928 } 1928 }
1929 } 1929 }
1930 1930
1931 void WebMediaPlayerImpl::FinishMemoryUsageReport(int64_t demuxer_memory_usage) { 1931 void WebMediaPlayerImpl::FinishMemoryUsageReport(int64_t demuxer_memory_usage) {
1932 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1932 DCHECK(main_task_runner_->BelongsToCurrentThread());
1933 1933
1934 const PipelineStatistics stats = pipeline_.GetStatistics(); 1934 const PipelineStatistics stats = pipeline_.GetStatistics();
1935 const int64_t data_source_memory_usage =
1936 data_source_ ? data_source_->GetMemoryUsage() : 0;
1935 const int64_t current_memory_usage = 1937 const int64_t current_memory_usage =
1936 stats.audio_memory_usage + stats.video_memory_usage + 1938 stats.audio_memory_usage + stats.video_memory_usage +
1937 (data_source_ ? data_source_->GetMemoryUsage() : 0) + 1939 data_source_memory_usage + demuxer_memory_usage;
1938 demuxer_memory_usage;
1939 1940
1940 // Note, this isn't entirely accurate, there may be VideoFrames held by the 1941 // Note, this isn't entirely accurate, there may be VideoFrames held by the
1941 // compositor or other resources that we're unaware of. 1942 // compositor or other resources that we're unaware of.
1942 1943
1943 DVLOG(2) << "Memory Usage -- Audio: " << stats.audio_memory_usage 1944 DVLOG(2) << "Memory Usage -- Audio: " << stats.audio_memory_usage
1944 << ", Video: " << stats.video_memory_usage << ", DataSource: " 1945 << ", Video: " << stats.video_memory_usage
1945 << (data_source_ ? data_source_->GetMemoryUsage() : 0) 1946 << ", DataSource: " << data_source_memory_usage
1946 << ", Demuxer: " << demuxer_memory_usage; 1947 << ", Demuxer: " << demuxer_memory_usage;
1947 1948
1948 const int64_t delta = current_memory_usage - last_reported_memory_usage_; 1949 const int64_t delta = current_memory_usage - last_reported_memory_usage_;
1949 last_reported_memory_usage_ = current_memory_usage; 1950 last_reported_memory_usage_ = current_memory_usage;
1950 adjust_allocated_memory_cb_.Run(delta); 1951 adjust_allocated_memory_cb_.Run(delta);
1952
1953 if (hasAudio()) {
1954 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Audio",
1955 stats.audio_memory_usage / 1024);
1956 }
1957 if (hasVideo()) {
1958 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Video",
1959 stats.video_memory_usage / 1024);
1960 }
1961 if (data_source_) {
1962 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.DataSource",
1963 data_source_memory_usage / 1024);
1964 }
1965 if (demuxer_) {
1966 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Demuxer",
1967 demuxer_memory_usage / 1024);
1968 }
1951 } 1969 }
1952 1970
1953 void WebMediaPlayerImpl::ScheduleIdlePauseTimer() { 1971 void WebMediaPlayerImpl::ScheduleIdlePauseTimer() {
1954 // Only schedule the pause timer if we're playing and are suspended. 1972 // Only schedule the pause timer if we're playing and are suspended.
1955 if (paused_ || !pipeline_controller_.IsSuspended()) 1973 if (paused_ || !pipeline_controller_.IsSuspended())
1956 return; 1974 return;
1957 1975
1958 #if defined(OS_ANDROID) 1976 #if defined(OS_ANDROID)
1959 // Remote players will be suspended and locally paused. 1977 // Remote players will be suspended and locally paused.
1960 if (isRemote()) 1978 if (isRemote())
(...skipping 18 matching lines...) Expand all
1979 watch_time_reporter_->OnShown(); 1997 watch_time_reporter_->OnShown();
1980 } 1998 }
1981 1999
1982 bool WebMediaPlayerImpl::IsHidden() const { 2000 bool WebMediaPlayerImpl::IsHidden() const {
1983 DCHECK(main_task_runner_->BelongsToCurrentThread()); 2001 DCHECK(main_task_runner_->BelongsToCurrentThread());
1984 2002
1985 return delegate_ && delegate_->IsHidden(); 2003 return delegate_ && delegate_->IsHidden();
1986 } 2004 }
1987 2005
1988 } // namespace media 2006 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698