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

Side by Side Diff: content/browser/media/media_internals_proxy.cc

Issue 1169983003: media-internals: Store updates when cannot update. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed 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 unified diff | Download patch
« no previous file with comments | « content/browser/media/media_internals.cc ('k') | media/base/media_log.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/media/media_internals_proxy.h" 5 #include "content/browser/media/media_internals_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 BrowserThread::PostTask( 63 BrowserThread::PostTask(
64 BrowserThread::IO, FROM_HERE, 64 BrowserThread::IO, FROM_HERE,
65 base::Bind( 65 base::Bind(
66 &MediaInternalsProxy::StopObservingMediaInternalsOnIOThread, this)); 66 &MediaInternalsProxy::StopObservingMediaInternalsOnIOThread, this));
67 } 67 }
68 68
69 void MediaInternalsProxy::GetEverything() { 69 void MediaInternalsProxy::GetEverything() {
70 DCHECK_CURRENTLY_ON(BrowserThread::UI); 70 DCHECK_CURRENTLY_ON(BrowserThread::UI);
71 71
72 // Ask MediaInternals for all its data. 72 MediaInternals::GetInstance()->SendHistoricalMediaEvents();
73
74 // Ask MediaInternals for its data on IO thread.
73 BrowserThread::PostTask( 75 BrowserThread::PostTask(
74 BrowserThread::IO, FROM_HERE, 76 BrowserThread::IO, FROM_HERE,
75 base::Bind(&MediaInternalsProxy::GetEverythingOnIOThread, this)); 77 base::Bind(&MediaInternalsProxy::GetEverythingOnIOThread, this));
76 78
77 // Send the page names for constants. 79 // Send the page names for constants.
78 CallJavaScriptFunctionOnUIThread("media.onReceiveConstants", GetConstants()); 80 CallJavaScriptFunctionOnUIThread("media.onReceiveConstants", GetConstants());
79 } 81 }
80 82
81 void MediaInternalsProxy::OnAddEntry(const net::NetLog::Entry& entry) { 83 void MediaInternalsProxy::OnAddEntry(const net::NetLog::Entry& entry) {
82 bool is_event_interesting = false; 84 bool is_event_interesting = false;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void MediaInternalsProxy::StopObservingMediaInternalsOnIOThread() { 131 void MediaInternalsProxy::StopObservingMediaInternalsOnIOThread() {
130 DCHECK_CURRENTLY_ON(BrowserThread::IO); 132 DCHECK_CURRENTLY_ON(BrowserThread::IO);
131 if (GetContentClient()->browser()->GetNetLog()) { 133 if (GetContentClient()->browser()->GetNetLog()) {
132 net::NetLog* net_log = GetContentClient()->browser()->GetNetLog(); 134 net::NetLog* net_log = GetContentClient()->browser()->GetNetLog();
133 net_log->DeprecatedRemoveObserver(this); 135 net_log->DeprecatedRemoveObserver(this);
134 } 136 }
135 } 137 }
136 138
137 void MediaInternalsProxy::GetEverythingOnIOThread() { 139 void MediaInternalsProxy::GetEverythingOnIOThread() {
138 DCHECK_CURRENTLY_ON(BrowserThread::IO); 140 DCHECK_CURRENTLY_ON(BrowserThread::IO);
141 // TODO(xhwang): Investigate whether we can update on UI thread directly.
139 MediaInternals::GetInstance()->SendAudioStreamData(); 142 MediaInternals::GetInstance()->SendAudioStreamData();
140 MediaInternals::GetInstance()->SendVideoCaptureDeviceCapabilities(); 143 MediaInternals::GetInstance()->SendVideoCaptureDeviceCapabilities();
141 } 144 }
142 145
143 void MediaInternalsProxy::UpdateUIOnUIThread(const base::string16& update) { 146 void MediaInternalsProxy::UpdateUIOnUIThread(const base::string16& update) {
144 DCHECK_CURRENTLY_ON(BrowserThread::UI); 147 DCHECK_CURRENTLY_ON(BrowserThread::UI);
145 // Don't forward updates to a destructed UI. 148 // Don't forward updates to a destructed UI.
146 if (handler_) 149 if (handler_)
147 handler_->OnUpdate(update); 150 handler_->OnUpdate(update);
148 } 151 }
(...skipping 24 matching lines...) Expand all
173 const std::string& function, base::Value* args) { 176 const std::string& function, base::Value* args) {
174 DCHECK_CURRENTLY_ON(BrowserThread::UI); 177 DCHECK_CURRENTLY_ON(BrowserThread::UI);
175 scoped_ptr<base::Value> args_value(args); 178 scoped_ptr<base::Value> args_value(args);
176 std::vector<const base::Value*> args_vector; 179 std::vector<const base::Value*> args_vector;
177 args_vector.push_back(args_value.get()); 180 args_vector.push_back(args_value.get());
178 base::string16 update = WebUI::GetJavascriptCall(function, args_vector); 181 base::string16 update = WebUI::GetJavascriptCall(function, args_vector);
179 UpdateUIOnUIThread(update); 182 UpdateUIOnUIThread(update);
180 } 183 }
181 184
182 } // namespace content 185 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/media_internals.cc ('k') | media/base/media_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698