| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "content/browser/media/media_internals_handler.h" | 17 #include "content/browser/media/media_internals_handler.h" |
| 18 #include "content/public/browser/content_browser_client.h" | 18 #include "content/public/browser/content_browser_client.h" |
| 19 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 20 #include "content/public/browser/notification_types.h" | 20 #include "content/public/browser/notification_types.h" |
| 21 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
| 22 #include "content/public/browser/web_ui.h" | 22 #include "content/public/browser/web_ui.h" |
| 23 #include "net/log/net_log_capture_mode.h" |
| 24 #include "net/log/net_log_entry.h" |
| 23 #include "net/log/net_log_event_type.h" | 25 #include "net/log/net_log_event_type.h" |
| 24 | 26 |
| 25 namespace content { | 27 namespace content { |
| 26 | 28 |
| 27 static const int kMediaInternalsProxyEventDelayMilliseconds = 100; | 29 static const int kMediaInternalsProxyEventDelayMilliseconds = 100; |
| 28 | 30 |
| 29 static const net::NetLogEventType kNetEventTypeFilter[] = { | 31 static const net::NetLogEventType kNetEventTypeFilter[] = { |
| 30 net::NetLogEventType::DISK_CACHE_ENTRY_IMPL, | 32 net::NetLogEventType::DISK_CACHE_ENTRY_IMPL, |
| 31 net::NetLogEventType::SPARSE_READ, | 33 net::NetLogEventType::SPARSE_READ, |
| 32 net::NetLogEventType::SPARSE_WRITE, | 34 net::NetLogEventType::SPARSE_WRITE, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 82 |
| 81 // Ask MediaInternals for its data on IO thread. | 83 // Ask MediaInternals for its data on IO thread. |
| 82 BrowserThread::PostTask( | 84 BrowserThread::PostTask( |
| 83 BrowserThread::IO, FROM_HERE, | 85 BrowserThread::IO, FROM_HERE, |
| 84 base::Bind(&MediaInternalsProxy::GetEverythingOnIOThread, this)); | 86 base::Bind(&MediaInternalsProxy::GetEverythingOnIOThread, this)); |
| 85 | 87 |
| 86 // Send the page names for constants. | 88 // Send the page names for constants. |
| 87 CallJavaScriptFunctionOnUIThread("media.onReceiveConstants", GetConstants()); | 89 CallJavaScriptFunctionOnUIThread("media.onReceiveConstants", GetConstants()); |
| 88 } | 90 } |
| 89 | 91 |
| 90 void MediaInternalsProxy::OnAddEntry(const net::NetLog::Entry& entry) { | 92 void MediaInternalsProxy::OnAddEntry(const net::NetLogEntry& entry) { |
| 91 bool is_event_interesting = false; | 93 bool is_event_interesting = false; |
| 92 for (size_t i = 0; i < arraysize(kNetEventTypeFilter); i++) { | 94 for (size_t i = 0; i < arraysize(kNetEventTypeFilter); i++) { |
| 93 if (entry.type() == kNetEventTypeFilter[i]) { | 95 if (entry.type() == kNetEventTypeFilter[i]) { |
| 94 is_event_interesting = true; | 96 is_event_interesting = true; |
| 95 break; | 97 break; |
| 96 } | 98 } |
| 97 } | 99 } |
| 98 | 100 |
| 99 if (!is_event_interesting) | 101 if (!is_event_interesting) |
| 100 return; | 102 return; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 const std::string& function, base::Value* args) { | 186 const std::string& function, base::Value* args) { |
| 185 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 187 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 186 std::unique_ptr<base::Value> args_value(args); | 188 std::unique_ptr<base::Value> args_value(args); |
| 187 std::vector<const base::Value*> args_vector; | 189 std::vector<const base::Value*> args_vector; |
| 188 args_vector.push_back(args_value.get()); | 190 args_vector.push_back(args_value.get()); |
| 189 base::string16 update = WebUI::GetJavascriptCall(function, args_vector); | 191 base::string16 update = WebUI::GetJavascriptCall(function, args_vector); |
| 190 UpdateUIOnUIThread(update); | 192 UpdateUIOnUIThread(update); |
| 191 } | 193 } |
| 192 | 194 |
| 193 } // namespace content | 195 } // namespace content |
| OLD | NEW |