Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Side by Side Diff: content/browser/media/media_internals_proxy.cc

Issue 12207089: Cleanup: Remove deprecated base::Value methods from contents. Use base::Value too. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/message_loop.h" 8 #include "base/message_loop.h"
9 #include "content/browser/media/media_internals_handler.h" 9 #include "content/browser/media/media_internals_handler.h"
10 #include "content/public/browser/content_browser_client.h" 10 #include "content/public/browser/content_browser_client.h"
(...skipping 19 matching lines...) Expand all
30 NotificationService::AllBrowserContextsAndSources()); 30 NotificationService::AllBrowserContextsAndSources());
31 } 31 }
32 32
33 void MediaInternalsProxy::Observe(int type, 33 void MediaInternalsProxy::Observe(int type,
34 const NotificationSource& source, 34 const NotificationSource& source,
35 const NotificationDetails& details) { 35 const NotificationDetails& details) {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
37 DCHECK_EQ(type, NOTIFICATION_RENDERER_PROCESS_TERMINATED); 37 DCHECK_EQ(type, NOTIFICATION_RENDERER_PROCESS_TERMINATED);
38 RenderProcessHost* process = Source<RenderProcessHost>(source).ptr(); 38 RenderProcessHost* process = Source<RenderProcessHost>(source).ptr();
39 CallJavaScriptFunctionOnUIThread("media.onRendererTerminated", 39 CallJavaScriptFunctionOnUIThread("media.onRendererTerminated",
40 base::Value::CreateIntegerValue(process->GetID())); 40 new base::FundamentalValue(process->GetID()));
41 } 41 }
42 42
43 void MediaInternalsProxy::Attach(MediaInternalsMessageHandler* handler) { 43 void MediaInternalsProxy::Attach(MediaInternalsMessageHandler* handler) {
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
45 handler_ = handler; 45 handler_ = handler;
46 BrowserThread::PostTask( 46 BrowserThread::PostTask(
47 BrowserThread::IO, FROM_HERE, 47 BrowserThread::IO, FROM_HERE,
48 base::Bind(&MediaInternalsProxy::ObserveMediaInternalsOnIOThread, this)); 48 base::Bind(&MediaInternalsProxy::ObserveMediaInternalsOnIOThread, this));
49 } 49 }
50 50
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return; 89 return;
90 90
91 BrowserThread::PostTask( 91 BrowserThread::PostTask(
92 BrowserThread::UI, FROM_HERE, 92 BrowserThread::UI, FROM_HERE,
93 base::Bind(&MediaInternalsProxy::AddNetEventOnUIThread, this, 93 base::Bind(&MediaInternalsProxy::AddNetEventOnUIThread, this,
94 entry.ToValue())); 94 entry.ToValue()));
95 } 95 }
96 96
97 MediaInternalsProxy::~MediaInternalsProxy() {} 97 MediaInternalsProxy::~MediaInternalsProxy() {}
98 98
99 Value* MediaInternalsProxy::GetConstants() { 99 base::Value* MediaInternalsProxy::GetConstants() {
100 DictionaryValue* event_phases = new DictionaryValue(); 100 base::DictionaryValue* event_phases = new base::DictionaryValue();
101 event_phases->SetInteger( 101 event_phases->SetInteger(
102 net::NetLog::EventPhaseToString(net::NetLog::PHASE_NONE), 102 net::NetLog::EventPhaseToString(net::NetLog::PHASE_NONE),
103 net::NetLog::PHASE_NONE); 103 net::NetLog::PHASE_NONE);
104 event_phases->SetInteger( 104 event_phases->SetInteger(
105 net::NetLog::EventPhaseToString(net::NetLog::PHASE_BEGIN), 105 net::NetLog::EventPhaseToString(net::NetLog::PHASE_BEGIN),
106 net::NetLog::PHASE_BEGIN); 106 net::NetLog::PHASE_BEGIN);
107 event_phases->SetInteger( 107 event_phases->SetInteger(
108 net::NetLog::EventPhaseToString(net::NetLog::PHASE_END), 108 net::NetLog::EventPhaseToString(net::NetLog::PHASE_END),
109 net::NetLog::PHASE_END); 109 net::NetLog::PHASE_END);
110 110
111 DictionaryValue* constants = new DictionaryValue(); 111 base::DictionaryValue* constants = new base::DictionaryValue();
112 constants->Set("eventTypes", net::NetLog::GetEventTypesAsValue()); 112 constants->Set("eventTypes", net::NetLog::GetEventTypesAsValue());
113 constants->Set("eventPhases", event_phases); 113 constants->Set("eventPhases", event_phases);
114 114
115 return constants; 115 return constants;
116 } 116 }
117 117
118 void MediaInternalsProxy::ObserveMediaInternalsOnIOThread() { 118 void MediaInternalsProxy::ObserveMediaInternalsOnIOThread() {
119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
120 update_callback_ = base::Bind(&MediaInternalsProxy::OnUpdate, 120 update_callback_ = base::Bind(&MediaInternalsProxy::OnUpdate,
121 base::Unretained(this)); 121 base::Unretained(this));
(...skipping 18 matching lines...) Expand all
140 MediaInternals::GetInstance()->SendEverything(); 140 MediaInternals::GetInstance()->SendEverything();
141 } 141 }
142 142
143 void MediaInternalsProxy::UpdateUIOnUIThread(const string16& update) { 143 void MediaInternalsProxy::UpdateUIOnUIThread(const string16& update) {
144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
145 // Don't forward updates to a destructed UI. 145 // Don't forward updates to a destructed UI.
146 if (handler_) 146 if (handler_)
147 handler_->OnUpdate(update); 147 handler_->OnUpdate(update);
148 } 148 }
149 149
150 void MediaInternalsProxy::AddNetEventOnUIThread(Value* entry) { 150 void MediaInternalsProxy::AddNetEventOnUIThread(base::Value* entry) {
151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
152 152
153 // Send the updates to the page in kMediaInternalsProxyEventDelayMilliseconds 153 // Send the updates to the page in kMediaInternalsProxyEventDelayMilliseconds
154 // if an update is not already pending. 154 // if an update is not already pending.
155 if (!pending_net_updates_.get()) { 155 if (!pending_net_updates_.get()) {
156 pending_net_updates_.reset(new ListValue()); 156 pending_net_updates_.reset(new base::ListValue());
157 MessageLoop::current()->PostDelayedTask( 157 MessageLoop::current()->PostDelayedTask(
158 FROM_HERE, 158 FROM_HERE,
159 base::Bind( 159 base::Bind(
160 &MediaInternalsProxy::SendNetEventsOnUIThread, this), 160 &MediaInternalsProxy::SendNetEventsOnUIThread, this),
161 base::TimeDelta::FromMilliseconds( 161 base::TimeDelta::FromMilliseconds(
162 kMediaInternalsProxyEventDelayMilliseconds)); 162 kMediaInternalsProxyEventDelayMilliseconds));
163 } 163 }
164 pending_net_updates_->Append(entry); 164 pending_net_updates_->Append(entry);
165 } 165 }
166 166
167 void MediaInternalsProxy::SendNetEventsOnUIThread() { 167 void MediaInternalsProxy::SendNetEventsOnUIThread() {
168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
169 CallJavaScriptFunctionOnUIThread("media.onNetUpdate", 169 CallJavaScriptFunctionOnUIThread("media.onNetUpdate",
170 pending_net_updates_.release()); 170 pending_net_updates_.release());
171 } 171 }
172 172
173 void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread( 173 void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread(
174 const std::string& function, Value* args) { 174 const std::string& function, base::Value* args) {
175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
176 scoped_ptr<Value> args_value(args); 176 scoped_ptr<base::Value> args_value(args);
177 std::vector<const Value*> args_vector; 177 std::vector<const base::Value*> args_vector;
178 args_vector.push_back(args_value.get()); 178 args_vector.push_back(args_value.get());
179 string16 update = WebUI::GetJavascriptCall(function, args_vector); 179 string16 update = WebUI::GetJavascriptCall(function, args_vector);
180 UpdateUIOnUIThread(update); 180 UpdateUIOnUIThread(update);
181 } 181 }
182 182
183 } // namespace content 183 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/media_internals.cc ('k') | content/browser/media/media_internals_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698