Chromium Code Reviews| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 CallJavaScriptFunctionOnUIThread("media.onReceiveConstants", GetConstants()); | 73 CallJavaScriptFunctionOnUIThread("media.onReceiveConstants", GetConstants()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void MediaInternalsProxy::OnUpdate(const string16& update) { | 76 void MediaInternalsProxy::OnUpdate(const string16& update) { |
| 77 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 77 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 78 BrowserThread::PostTask( | 78 BrowserThread::PostTask( |
| 79 BrowserThread::UI, FROM_HERE, | 79 BrowserThread::UI, FROM_HERE, |
| 80 base::Bind(&MediaInternalsProxy::UpdateUIOnUIThread, this, update)); | 80 base::Bind(&MediaInternalsProxy::UpdateUIOnUIThread, this, update)); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void MediaInternalsProxy::OnAddEntry(net::NetLog::EventType type, | 83 void MediaInternalsProxy::OnAddEntry(const net::NetLog::Entry& entry) { |
| 84 const base::TimeTicks& time, | |
| 85 const net::NetLog::Source& source, | |
| 86 net::NetLog::EventPhase phase, | |
| 87 net::NetLog::EventParameters* params) { | |
| 88 bool is_event_interesting = false; | 84 bool is_event_interesting = false; |
| 89 for (size_t i = 0; i < arraysize(kNetEventTypeFilter); i++) { | 85 for (size_t i = 0; i < arraysize(kNetEventTypeFilter); i++) { |
| 90 if (type == kNetEventTypeFilter[i]) { | 86 if (entry.type() == kNetEventTypeFilter[i]) { |
| 91 is_event_interesting = true; | 87 is_event_interesting = true; |
| 92 break; | 88 break; |
| 93 } | 89 } |
| 94 } | 90 } |
| 95 | 91 |
| 96 if (!is_event_interesting) | 92 if (!is_event_interesting) |
| 97 return; | 93 return; |
| 98 | 94 |
| 99 BrowserThread::PostTask( | 95 BrowserThread::PostTask( |
| 100 BrowserThread::UI, FROM_HERE, | 96 BrowserThread::UI, FROM_HERE, |
| 101 base::Bind(&MediaInternalsProxy::AddNetEventOnUIThread, this, | 97 base::Bind(&MediaInternalsProxy::AddNetEventOnUIThread, this, |
| 102 net::NetLog::EntryToDictionaryValue(type, time, source, phase, | 98 base::Owned(entry.ToValue()))); |
|
eroman
2012/06/06 21:27:11
IMPORTANT: You sure about this? Looks like ownersh
mmenke
2012/06/07 19:20:46
You're right. I was thinking of it as one of the
| |
| 103 params, false))); | |
| 104 } | 99 } |
| 105 | 100 |
| 106 MediaInternalsProxy::~MediaInternalsProxy() {} | 101 MediaInternalsProxy::~MediaInternalsProxy() {} |
| 107 | 102 |
| 108 Value* MediaInternalsProxy::GetConstants() { | 103 Value* MediaInternalsProxy::GetConstants() { |
| 109 DictionaryValue* event_phases = new DictionaryValue(); | 104 DictionaryValue* event_phases = new DictionaryValue(); |
| 110 event_phases->SetInteger( | 105 event_phases->SetInteger( |
| 111 net::NetLog::EventPhaseToString(net::NetLog::PHASE_NONE), | 106 net::NetLog::EventPhaseToString(net::NetLog::PHASE_NONE), |
| 112 net::NetLog::PHASE_NONE); | 107 net::NetLog::PHASE_NONE); |
| 113 event_phases->SetInteger( | 108 event_phases->SetInteger( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 | 169 |
| 175 void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread( | 170 void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread( |
| 176 const std::string& function, Value* args) { | 171 const std::string& function, Value* args) { |
| 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 178 scoped_ptr<Value> args_value(args); | 173 scoped_ptr<Value> args_value(args); |
| 179 std::vector<const Value*> args_vector; | 174 std::vector<const Value*> args_vector; |
| 180 args_vector.push_back(args_value.get()); | 175 args_vector.push_back(args_value.get()); |
| 181 string16 update = content::WebUI::GetJavascriptCall(function, args_vector); | 176 string16 update = content::WebUI::GetJavascriptCall(function, args_vector); |
| 182 UpdateUIOnUIThread(update); | 177 UpdateUIOnUIThread(update); |
| 183 } | 178 } |
| OLD | NEW |