| 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 "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" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 DictionaryValue* constants = new DictionaryValue(); | 120 DictionaryValue* constants = new DictionaryValue(); |
| 121 constants->Set("eventTypes", net::NetLog::GetEventTypesAsValue()); | 121 constants->Set("eventTypes", net::NetLog::GetEventTypesAsValue()); |
| 122 constants->Set("eventPhases", event_phases); | 122 constants->Set("eventPhases", event_phases); |
| 123 | 123 |
| 124 return constants; | 124 return constants; |
| 125 } | 125 } |
| 126 | 126 |
| 127 void MediaInternalsProxy::ObserveMediaInternalsOnIOThread() { | 127 void MediaInternalsProxy::ObserveMediaInternalsOnIOThread() { |
| 128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 129 io_thread_->globals()->media.media_internals->AddObserver(this); | 129 MediaInternals::GetInstance()->AddObserver(this); |
| 130 io_thread_->net_log()->AddThreadSafeObserver(this, | 130 io_thread_->net_log()->AddThreadSafeObserver(this, |
| 131 net::NetLog::LOG_ALL_BUT_BYTES); | 131 net::NetLog::LOG_ALL_BUT_BYTES); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void MediaInternalsProxy::StopObservingMediaInternalsOnIOThread() { | 134 void MediaInternalsProxy::StopObservingMediaInternalsOnIOThread() { |
| 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 136 io_thread_->globals()->media.media_internals->RemoveObserver(this); | 136 MediaInternals::GetInstance()->RemoveObserver(this); |
| 137 io_thread_->net_log()->RemoveThreadSafeObserver(this); | 137 io_thread_->net_log()->RemoveThreadSafeObserver(this); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void MediaInternalsProxy::GetEverythingOnIOThread() { | 140 void MediaInternalsProxy::GetEverythingOnIOThread() { |
| 141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 142 io_thread_->globals()->media.media_internals->SendEverything(); | 142 MediaInternals::GetInstance()->SendEverything(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void MediaInternalsProxy::UpdateUIOnUIThread(const string16& update) { | 145 void MediaInternalsProxy::UpdateUIOnUIThread(const string16& update) { |
| 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 147 // Don't forward updates to a destructed UI. | 147 // Don't forward updates to a destructed UI. |
| 148 if (handler_) | 148 if (handler_) |
| 149 handler_->OnUpdate(update); | 149 handler_->OnUpdate(update); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void MediaInternalsProxy::AddNetEventOnUIThread(Value* entry) { | 152 void MediaInternalsProxy::AddNetEventOnUIThread(Value* entry) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 174 | 174 |
| 175 void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread( | 175 void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread( |
| 176 const std::string& function, Value* args) { | 176 const std::string& function, Value* args) { |
| 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 178 scoped_ptr<Value> args_value(args); | 178 scoped_ptr<Value> args_value(args); |
| 179 std::vector<const Value*> args_vector; | 179 std::vector<const Value*> args_vector; |
| 180 args_vector.push_back(args_value.get()); | 180 args_vector.push_back(args_value.get()); |
| 181 string16 update = content::WebUI::GetJavascriptCall(function, args_vector); | 181 string16 update = content::WebUI::GetJavascriptCall(function, args_vector); |
| 182 UpdateUIOnUIThread(update); | 182 UpdateUIOnUIThread(update); |
| 183 } | 183 } |
| OLD | NEW |