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

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

Issue 14335017: content: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 | Annotate | Revision Log
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/message_loop.h" 8 #include "base/message_loop.h"
9 #include "content/browser/media/media_internals_handler.h" 9 #include "content/browser/media/media_internals_handler.h"
10 #include "content/public/browser/content_browser_client.h" 10 #include "content/public/browser/content_browser_client.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 handler_->OnUpdate(update); 147 handler_->OnUpdate(update);
148 } 148 }
149 149
150 void MediaInternalsProxy::AddNetEventOnUIThread(base::Value* entry) { 150 void MediaInternalsProxy::AddNetEventOnUIThread(base::Value* entry) {
151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
152 152
153 // Send the updates to the page in kMediaInternalsProxyEventDelayMilliseconds 153 // Send the updates to the page in kMediaInternalsProxyEventDelayMilliseconds
154 // if an update is not already pending. 154 // if an update is not already pending.
155 if (!pending_net_updates_) { 155 if (!pending_net_updates_) {
156 pending_net_updates_.reset(new base::ListValue()); 156 pending_net_updates_.reset(new base::ListValue());
157 MessageLoop::current()->PostDelayedTask( 157 base::MessageLoop::current()->PostDelayedTask(
158 FROM_HERE, 158 FROM_HERE,
159 base::Bind( 159 base::Bind(&MediaInternalsProxy::SendNetEventsOnUIThread, this),
160 &MediaInternalsProxy::SendNetEventsOnUIThread, this),
161 base::TimeDelta::FromMilliseconds( 160 base::TimeDelta::FromMilliseconds(
162 kMediaInternalsProxyEventDelayMilliseconds)); 161 kMediaInternalsProxyEventDelayMilliseconds));
163 } 162 }
164 pending_net_updates_->Append(entry); 163 pending_net_updates_->Append(entry);
165 } 164 }
166 165
167 void MediaInternalsProxy::SendNetEventsOnUIThread() { 166 void MediaInternalsProxy::SendNetEventsOnUIThread() {
168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
169 CallJavaScriptFunctionOnUIThread("media.onNetUpdate", 168 CallJavaScriptFunctionOnUIThread("media.onNetUpdate",
170 pending_net_updates_.release()); 169 pending_net_updates_.release());
171 } 170 }
172 171
173 void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread( 172 void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread(
174 const std::string& function, base::Value* args) { 173 const std::string& function, base::Value* args) {
175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
176 scoped_ptr<base::Value> args_value(args); 175 scoped_ptr<base::Value> args_value(args);
177 std::vector<const base::Value*> args_vector; 176 std::vector<const base::Value*> args_vector;
178 args_vector.push_back(args_value.get()); 177 args_vector.push_back(args_value.get());
179 string16 update = WebUI::GetJavascriptCall(function, args_vector); 178 string16 update = WebUI::GetJavascriptCall(function, args_vector);
180 UpdateUIOnUIThread(update); 179 UpdateUIOnUIThread(update);
181 } 180 }
182 181
183 } // namespace content 182 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_scheduler_unittest.cc ('k') | content/browser/media/media_internals_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698