OLD | NEW |
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 Loading... |
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 |
OLD | NEW |