| 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_event_type.h" |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| 26 static const int kMediaInternalsProxyEventDelayMilliseconds = 100; | 27 static const int kMediaInternalsProxyEventDelayMilliseconds = 100; |
| 27 | 28 |
| 28 static const net::NetLog::EventType kNetEventTypeFilter[] = { | 29 static const net::NetLogEventType kNetEventTypeFilter[] = { |
| 29 net::NetLog::TYPE_DISK_CACHE_ENTRY_IMPL, | 30 net::NetLogEventType::DISK_CACHE_ENTRY_IMPL, |
| 30 net::NetLog::TYPE_SPARSE_READ, | 31 net::NetLogEventType::SPARSE_READ, |
| 31 net::NetLog::TYPE_SPARSE_WRITE, | 32 net::NetLogEventType::SPARSE_WRITE, |
| 32 net::NetLog::TYPE_URL_REQUEST_START_JOB, | 33 net::NetLogEventType::URL_REQUEST_START_JOB, |
| 33 net::NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS, | 34 net::NetLogEventType::HTTP_TRANSACTION_READ_RESPONSE_HEADERS, |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 MediaInternalsProxy::MediaInternalsProxy() { | 37 MediaInternalsProxy::MediaInternalsProxy() { |
| 37 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 38 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 38 NotificationService::AllBrowserContextsAndSources()); | 39 NotificationService::AllBrowserContextsAndSources()); |
| 39 } | 40 } |
| 40 | 41 |
| 41 void MediaInternalsProxy::Observe(int type, | 42 void MediaInternalsProxy::Observe(int type, |
| 42 const NotificationSource& source, | 43 const NotificationSource& source, |
| 43 const NotificationDetails& details) { | 44 const NotificationDetails& details) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 BrowserThread::UI, FROM_HERE, | 103 BrowserThread::UI, FROM_HERE, |
| 103 base::Bind(&MediaInternalsProxy::AddNetEventOnUIThread, this, | 104 base::Bind(&MediaInternalsProxy::AddNetEventOnUIThread, this, |
| 104 base::Passed(entry.ToValue()))); | 105 base::Passed(entry.ToValue()))); |
| 105 } | 106 } |
| 106 | 107 |
| 107 MediaInternalsProxy::~MediaInternalsProxy() {} | 108 MediaInternalsProxy::~MediaInternalsProxy() {} |
| 108 | 109 |
| 109 base::Value* MediaInternalsProxy::GetConstants() { | 110 base::Value* MediaInternalsProxy::GetConstants() { |
| 110 base::DictionaryValue* event_phases = new base::DictionaryValue(); | 111 base::DictionaryValue* event_phases = new base::DictionaryValue(); |
| 111 event_phases->SetInteger( | 112 event_phases->SetInteger( |
| 112 net::NetLog::EventPhaseToString(net::NetLog::PHASE_NONE), | 113 net::NetLog::EventPhaseToString(net::NetLogEventPhase::NONE), |
| 113 net::NetLog::PHASE_NONE); | 114 static_cast<int>(net::NetLogEventPhase::NONE)); |
| 114 event_phases->SetInteger( | 115 event_phases->SetInteger( |
| 115 net::NetLog::EventPhaseToString(net::NetLog::PHASE_BEGIN), | 116 net::NetLog::EventPhaseToString(net::NetLogEventPhase::BEGIN), |
| 116 net::NetLog::PHASE_BEGIN); | 117 static_cast<int>(net::NetLogEventPhase::BEGIN)); |
| 117 event_phases->SetInteger( | 118 event_phases->SetInteger( |
| 118 net::NetLog::EventPhaseToString(net::NetLog::PHASE_END), | 119 net::NetLog::EventPhaseToString(net::NetLogEventPhase::END), |
| 119 net::NetLog::PHASE_END); | 120 static_cast<int>(net::NetLogEventPhase::END)); |
| 120 | 121 |
| 121 base::DictionaryValue* constants = new base::DictionaryValue(); | 122 base::DictionaryValue* constants = new base::DictionaryValue(); |
| 122 constants->Set("eventTypes", net::NetLog::GetEventTypesAsValue()); | 123 constants->Set("eventTypes", net::NetLog::GetEventTypesAsValue()); |
| 123 constants->Set("eventPhases", event_phases); | 124 constants->Set("eventPhases", event_phases); |
| 124 | 125 |
| 125 return constants; | 126 return constants; |
| 126 } | 127 } |
| 127 | 128 |
| 128 void MediaInternalsProxy::ObserveMediaInternalsOnIOThread() { | 129 void MediaInternalsProxy::ObserveMediaInternalsOnIOThread() { |
| 129 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 130 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 const std::string& function, base::Value* args) { | 184 const std::string& function, base::Value* args) { |
| 184 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 185 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 185 std::unique_ptr<base::Value> args_value(args); | 186 std::unique_ptr<base::Value> args_value(args); |
| 186 std::vector<const base::Value*> args_vector; | 187 std::vector<const base::Value*> args_vector; |
| 187 args_vector.push_back(args_value.get()); | 188 args_vector.push_back(args_value.get()); |
| 188 base::string16 update = WebUI::GetJavascriptCall(function, args_vector); | 189 base::string16 update = WebUI::GetJavascriptCall(function, args_vector); |
| 189 UpdateUIOnUIThread(update); | 190 UpdateUIOnUIThread(update); |
| 190 } | 191 } |
| 191 | 192 |
| 192 } // namespace content | 193 } // namespace content |
| OLD | NEW |