| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/webui/media/media_internals_proxy.h" | 5 #include "chrome/browser/ui/webui/media/media_internals_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/io_thread.h" | 9 #include "chrome/browser/io_thread.h" |
| 10 #include "chrome/browser/media/media_internals.h" | 10 #include "chrome/browser/media/media_internals.h" |
| 11 #include "chrome/browser/ui/webui/media/media_internals_handler.h" | 11 #include "chrome/browser/ui/webui/media/media_internals_handler.h" |
| 12 #include "content/common/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
| 13 #include "content/browser/renderer_host/render_process_host.h" | 13 #include "content/browser/renderer_host/render_process_host.h" |
| 14 #include "content/public/browser/notification_types.h" | 14 #include "content/public/browser/notification_types.h" |
| 15 | 15 |
| 16 static const int kMediaInternalsProxyEventDelayMilliseconds = 100; | 16 static const int kMediaInternalsProxyEventDelayMilliseconds = 100; |
| 17 | 17 |
| 18 static const net::NetLog::EventType kNetEventTypeFilter[] = { | 18 static const net::NetLog::EventType kNetEventTypeFilter[] = { |
| 19 net::NetLog::TYPE_DISK_CACHE_ENTRY_IMPL, | 19 net::NetLog::TYPE_DISK_CACHE_ENTRY_IMPL, |
| 20 net::NetLog::TYPE_SPARSE_READ, | 20 net::NetLog::TYPE_SPARSE_READ, |
| 21 net::NetLog::TYPE_SPARSE_WRITE, | 21 net::NetLog::TYPE_SPARSE_WRITE, |
| 22 net::NetLog::TYPE_URL_REQUEST_START_JOB, | 22 net::NetLog::TYPE_URL_REQUEST_START_JOB, |
| 23 net::NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS, | 23 net::NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS, |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 MediaInternalsProxy::MediaInternalsProxy() | 26 MediaInternalsProxy::MediaInternalsProxy() |
| 27 : ThreadSafeObserverImpl(net::NetLog::LOG_ALL_BUT_BYTES) { | 27 : ThreadSafeObserverImpl(net::NetLog::LOG_ALL_BUT_BYTES) { |
| 28 io_thread_ = g_browser_process->io_thread(); | 28 io_thread_ = g_browser_process->io_thread(); |
| 29 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 29 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 30 NotificationService::AllBrowserContextsAndSources()); | 30 content::NotificationService::AllBrowserContextsAndSources()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void MediaInternalsProxy::Observe(int type, | 33 void MediaInternalsProxy::Observe(int type, |
| 34 const content::NotificationSource& source, | 34 const content::NotificationSource& source, |
| 35 const content::NotificationDetails& details) { | 35 const content::NotificationDetails& details) { |
| 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 37 DCHECK_EQ(type, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED); | 37 DCHECK_EQ(type, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED); |
| 38 RenderProcessHost* process = content::Source<RenderProcessHost>(source).ptr(); | 38 RenderProcessHost* process = content::Source<RenderProcessHost>(source).ptr(); |
| 39 CallJavaScriptFunctionOnUIThread("media.onRendererTerminated", | 39 CallJavaScriptFunctionOnUIThread("media.onRendererTerminated", |
| 40 base::Value::CreateIntegerValue(process->id())); | 40 base::Value::CreateIntegerValue(process->id())); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread( | 179 void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread( |
| 180 const std::string& function, Value* args) { | 180 const std::string& function, Value* args) { |
| 181 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 181 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 182 scoped_ptr<Value> args_value(args); | 182 scoped_ptr<Value> args_value(args); |
| 183 std::vector<const Value*> args_vector; | 183 std::vector<const Value*> args_vector; |
| 184 args_vector.push_back(args_value.get()); | 184 args_vector.push_back(args_value.get()); |
| 185 string16 update = WebUI::GetJavascriptCall(function, args_vector); | 185 string16 update = WebUI::GetJavascriptCall(function, args_vector); |
| 186 UpdateUIOnUIThread(update); | 186 UpdateUIOnUIThread(update); |
| 187 } | 187 } |
| OLD | NEW |