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

Unified Diff: content/browser/media/media_internals.cc

Issue 1169983003: media-internals: Store updates when cannot update. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/media/media_internals.h ('k') | content/browser/media/media_internals_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/media_internals.cc
diff --git a/content/browser/media/media_internals.cc b/content/browser/media/media_internals.cc
index 7f4d62ec96203080e2d9dc8065a1a2ff204c0560..ae4e67b82c0fe930f07a9099057bb8ef0f9a96df 100644
--- a/content/browser/media/media_internals.cc
+++ b/content/browser/media/media_internals.cc
@@ -321,7 +321,7 @@ void MediaInternals::MediaInternalsUMAHandler::Observe(
// by both SavePlayerState & LogAndClearPlayersInRenderer from different
// threads.
// Using base::Unretained() on MediaInternalsUMAHandler is safe since
- // it is owned by MediaInternals and share the same lifetime
+ // it is owned by MediaInternals and shares the same lifetime.
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&MediaInternalsUMAHandler::LogAndClearPlayersInRenderer,
@@ -450,6 +450,7 @@ void MediaInternals::MediaInternalsUMAHandler::LogAndClearPlayersInRenderer(
ReportUMAForPipelineStatus(it->second);
players_it->second.erase(it++);
}
+ renderer_info_.erase(players_it);
}
MediaInternals* MediaInternals::GetInstance() {
@@ -497,6 +498,9 @@ void MediaInternals::OnMediaEvents(
if (CanUpdate())
SendUpdate(SerializeUpdate("media.onMediaEvent", &dict));
+ else
+ SaveUpdate(SerializeUpdate("media.onMediaEvent", &dict));
+
uma_handler_->SavePlayerState(*event, render_process_id);
}
}
@@ -527,6 +531,14 @@ bool MediaInternals::CanUpdate() {
return can_update_;
}
+void MediaInternals::SendHistoricalMediaEvents() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ base::AutoLock auto_lock(lock_);
+ for (const auto& update : pending_updates_)
+ SendUpdate(update);
+ pending_updates_.clear();
+}
+
void MediaInternals::SendAudioStreamData() {
base::string16 audio_stream_update;
{
@@ -601,6 +613,17 @@ void MediaInternals::SendUpdate(const base::string16& update) {
update_callbacks_[i].Run(update);
}
+void MediaInternals::SaveUpdate(const base::string16& update) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ static const size_t kMaxNumUpdates = 2048;
DaleCurtis 2015/06/09 16:41:32 Usually just const at function scope.
xhwang 2015/06/09 20:37:57 Done.
+
+ base::AutoLock auto_lock(lock_);
+ if (pending_updates_.size() >= kMaxNumUpdates)
+ pending_updates_.pop_front();
+ pending_updates_.push_back(update);
+}
+
void MediaInternals::SendAudioLogUpdate(AudioLogUpdateType type,
const std::string& cache_key,
const std::string& function,
« no previous file with comments | « content/browser/media/media_internals.h ('k') | content/browser/media/media_internals_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698