| 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/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 BrowserThread::PostTask( | 63 BrowserThread::PostTask( |
| 64 BrowserThread::IO, FROM_HERE, | 64 BrowserThread::IO, FROM_HERE, |
| 65 base::Bind( | 65 base::Bind( |
| 66 &MediaInternalsProxy::StopObservingMediaInternalsOnIOThread, this)); | 66 &MediaInternalsProxy::StopObservingMediaInternalsOnIOThread, this)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void MediaInternalsProxy::GetEverything() { | 69 void MediaInternalsProxy::GetEverything() { |
| 70 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 70 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 71 | 71 |
| 72 // Ask MediaInternals for all its data. | 72 MediaInternals::GetInstance()->SendHistoricalMediaEvents(); |
| 73 |
| 74 // Ask MediaInternals for its data on IO thread. |
| 73 BrowserThread::PostTask( | 75 BrowserThread::PostTask( |
| 74 BrowserThread::IO, FROM_HERE, | 76 BrowserThread::IO, FROM_HERE, |
| 75 base::Bind(&MediaInternalsProxy::GetEverythingOnIOThread, this)); | 77 base::Bind(&MediaInternalsProxy::GetEverythingOnIOThread, this)); |
| 76 | 78 |
| 77 // Send the page names for constants. | 79 // Send the page names for constants. |
| 78 CallJavaScriptFunctionOnUIThread("media.onReceiveConstants", GetConstants()); | 80 CallJavaScriptFunctionOnUIThread("media.onReceiveConstants", GetConstants()); |
| 79 } | 81 } |
| 80 | 82 |
| 81 void MediaInternalsProxy::OnAddEntry(const net::NetLog::Entry& entry) { | 83 void MediaInternalsProxy::OnAddEntry(const net::NetLog::Entry& entry) { |
| 82 bool is_event_interesting = false; | 84 bool is_event_interesting = false; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 void MediaInternalsProxy::StopObservingMediaInternalsOnIOThread() { | 131 void MediaInternalsProxy::StopObservingMediaInternalsOnIOThread() { |
| 130 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 132 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 131 if (GetContentClient()->browser()->GetNetLog()) { | 133 if (GetContentClient()->browser()->GetNetLog()) { |
| 132 net::NetLog* net_log = GetContentClient()->browser()->GetNetLog(); | 134 net::NetLog* net_log = GetContentClient()->browser()->GetNetLog(); |
| 133 net_log->DeprecatedRemoveObserver(this); | 135 net_log->DeprecatedRemoveObserver(this); |
| 134 } | 136 } |
| 135 } | 137 } |
| 136 | 138 |
| 137 void MediaInternalsProxy::GetEverythingOnIOThread() { | 139 void MediaInternalsProxy::GetEverythingOnIOThread() { |
| 138 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 140 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 141 // TODO(xhwang): Investigate whether we can update on UI thread directly. |
| 139 MediaInternals::GetInstance()->SendAudioStreamData(); | 142 MediaInternals::GetInstance()->SendAudioStreamData(); |
| 140 MediaInternals::GetInstance()->SendVideoCaptureDeviceCapabilities(); | 143 MediaInternals::GetInstance()->SendVideoCaptureDeviceCapabilities(); |
| 141 } | 144 } |
| 142 | 145 |
| 143 void MediaInternalsProxy::UpdateUIOnUIThread(const base::string16& update) { | 146 void MediaInternalsProxy::UpdateUIOnUIThread(const base::string16& update) { |
| 144 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 147 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 145 // Don't forward updates to a destructed UI. | 148 // Don't forward updates to a destructed UI. |
| 146 if (handler_) | 149 if (handler_) |
| 147 handler_->OnUpdate(update); | 150 handler_->OnUpdate(update); |
| 148 } | 151 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 173 const std::string& function, base::Value* args) { | 176 const std::string& function, base::Value* args) { |
| 174 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 177 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 175 scoped_ptr<base::Value> args_value(args); | 178 scoped_ptr<base::Value> args_value(args); |
| 176 std::vector<const base::Value*> args_vector; | 179 std::vector<const base::Value*> args_vector; |
| 177 args_vector.push_back(args_value.get()); | 180 args_vector.push_back(args_value.get()); |
| 178 base::string16 update = WebUI::GetJavascriptCall(function, args_vector); | 181 base::string16 update = WebUI::GetJavascriptCall(function, args_vector); |
| 179 UpdateUIOnUIThread(update); | 182 UpdateUIOnUIThread(update); |
| 180 } | 183 } |
| 181 | 184 |
| 182 } // namespace content | 185 } // namespace content |
| OLD | NEW |