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/message_loop.h" | 8 #include "base/message_loop/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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 // Ask MediaInternals for all its data. | 63 // Ask MediaInternals for all its data. |
64 BrowserThread::PostTask( | 64 BrowserThread::PostTask( |
65 BrowserThread::IO, FROM_HERE, | 65 BrowserThread::IO, FROM_HERE, |
66 base::Bind(&MediaInternalsProxy::GetEverythingOnIOThread, this)); | 66 base::Bind(&MediaInternalsProxy::GetEverythingOnIOThread, this)); |
67 | 67 |
68 // Send the page names for constants. | 68 // Send the page names for constants. |
69 CallJavaScriptFunctionOnUIThread("media.onReceiveConstants", GetConstants()); | 69 CallJavaScriptFunctionOnUIThread("media.onReceiveConstants", GetConstants()); |
70 } | 70 } |
71 | 71 |
72 void MediaInternalsProxy::OnUpdate(const string16& update) { | 72 void MediaInternalsProxy::OnUpdate(const base::string16& update) { |
73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
74 BrowserThread::PostTask( | 74 BrowserThread::PostTask( |
75 BrowserThread::UI, FROM_HERE, | 75 BrowserThread::UI, FROM_HERE, |
76 base::Bind(&MediaInternalsProxy::UpdateUIOnUIThread, this, update)); | 76 base::Bind(&MediaInternalsProxy::UpdateUIOnUIThread, this, update)); |
77 } | 77 } |
78 | 78 |
79 void MediaInternalsProxy::OnAddEntry(const net::NetLog::Entry& entry) { | 79 void MediaInternalsProxy::OnAddEntry(const net::NetLog::Entry& entry) { |
80 bool is_event_interesting = false; | 80 bool is_event_interesting = false; |
81 for (size_t i = 0; i < arraysize(kNetEventTypeFilter); i++) { | 81 for (size_t i = 0; i < arraysize(kNetEventTypeFilter); i++) { |
82 if (entry.type() == kNetEventTypeFilter[i]) { | 82 if (entry.type() == kNetEventTypeFilter[i]) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 net::NetLog* net_log = GetContentClient()->browser()->GetNetLog(); | 133 net::NetLog* net_log = GetContentClient()->browser()->GetNetLog(); |
134 net_log->RemoveThreadSafeObserver(this); | 134 net_log->RemoveThreadSafeObserver(this); |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 void MediaInternalsProxy::GetEverythingOnIOThread() { | 138 void MediaInternalsProxy::GetEverythingOnIOThread() { |
139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
140 MediaInternals::GetInstance()->SendEverything(); | 140 MediaInternals::GetInstance()->SendEverything(); |
141 } | 141 } |
142 | 142 |
143 void MediaInternalsProxy::UpdateUIOnUIThread(const string16& update) { | 143 void MediaInternalsProxy::UpdateUIOnUIThread(const base::string16& update) { |
144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
145 // Don't forward updates to a destructed UI. | 145 // Don't forward updates to a destructed UI. |
146 if (handler_) | 146 if (handler_) |
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 |
(...skipping 14 matching lines...) Expand all Loading... |
168 CallJavaScriptFunctionOnUIThread("media.onNetUpdate", | 168 CallJavaScriptFunctionOnUIThread("media.onNetUpdate", |
169 pending_net_updates_.release()); | 169 pending_net_updates_.release()); |
170 } | 170 } |
171 | 171 |
172 void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread( | 172 void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread( |
173 const std::string& function, base::Value* args) { | 173 const std::string& function, base::Value* args) { |
174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
175 scoped_ptr<base::Value> args_value(args); | 175 scoped_ptr<base::Value> args_value(args); |
176 std::vector<const base::Value*> args_vector; | 176 std::vector<const base::Value*> args_vector; |
177 args_vector.push_back(args_value.get()); | 177 args_vector.push_back(args_value.get()); |
178 string16 update = WebUI::GetJavascriptCall(function, args_vector); | 178 base::string16 update = WebUI::GetJavascriptCall(function, args_vector); |
179 UpdateUIOnUIThread(update); | 179 UpdateUIOnUIThread(update); |
180 } | 180 } |
181 | 181 |
182 } // namespace content | 182 } // namespace content |
OLD | NEW |