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

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

Issue 2891933004: Remove raw base::DictionaryValue::Set in //content (Closed)
Patch Set: Created 3 years, 7 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 29 matching lines...) Expand all
40 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, 40 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED,
41 NotificationService::AllBrowserContextsAndSources()); 41 NotificationService::AllBrowserContextsAndSources());
42 } 42 }
43 43
44 void MediaInternalsProxy::Observe(int type, 44 void MediaInternalsProxy::Observe(int type,
45 const NotificationSource& source, 45 const NotificationSource& source,
46 const NotificationDetails& details) { 46 const NotificationDetails& details) {
47 DCHECK_CURRENTLY_ON(BrowserThread::UI); 47 DCHECK_CURRENTLY_ON(BrowserThread::UI);
48 DCHECK_EQ(type, NOTIFICATION_RENDERER_PROCESS_TERMINATED); 48 DCHECK_EQ(type, NOTIFICATION_RENDERER_PROCESS_TERMINATED);
49 RenderProcessHost* process = Source<RenderProcessHost>(source).ptr(); 49 RenderProcessHost* process = Source<RenderProcessHost>(source).ptr();
50 CallJavaScriptFunctionOnUIThread("media.onRendererTerminated", 50 CallJavaScriptFunctionOnUIThread(
51 new base::Value(process->GetID())); 51 "media.onRendererTerminated",
52 base::MakeUnique<base::Value>(process->GetID()));
52 } 53 }
53 54
54 void MediaInternalsProxy::Attach(MediaInternalsMessageHandler* handler) { 55 void MediaInternalsProxy::Attach(MediaInternalsMessageHandler* handler) {
55 DCHECK_CURRENTLY_ON(BrowserThread::UI); 56 DCHECK_CURRENTLY_ON(BrowserThread::UI);
56 57
57 handler_ = handler; 58 handler_ = handler;
58 update_callback_ = base::Bind(&MediaInternalsProxy::UpdateUIOnUIThread, this); 59 update_callback_ = base::Bind(&MediaInternalsProxy::UpdateUIOnUIThread, this);
59 MediaInternals::GetInstance()->AddUpdateCallback(update_callback_); 60 MediaInternals::GetInstance()->AddUpdateCallback(update_callback_);
60 61
61 BrowserThread::PostTask( 62 BrowserThread::PostTask(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 return; 103 return;
103 104
104 BrowserThread::PostTask( 105 BrowserThread::PostTask(
105 BrowserThread::UI, FROM_HERE, 106 BrowserThread::UI, FROM_HERE,
106 base::Bind(&MediaInternalsProxy::AddNetEventOnUIThread, this, 107 base::Bind(&MediaInternalsProxy::AddNetEventOnUIThread, this,
107 base::Passed(entry.ToValue()))); 108 base::Passed(entry.ToValue())));
108 } 109 }
109 110
110 MediaInternalsProxy::~MediaInternalsProxy() {} 111 MediaInternalsProxy::~MediaInternalsProxy() {}
111 112
112 base::Value* MediaInternalsProxy::GetConstants() { 113 std::unique_ptr<base::Value> MediaInternalsProxy::GetConstants() {
113 base::DictionaryValue* event_phases = new base::DictionaryValue(); 114 auto event_phases = base::MakeUnique<base::DictionaryValue>();
114 event_phases->SetInteger( 115 event_phases->SetInteger(
115 net::NetLog::EventPhaseToString(net::NetLogEventPhase::NONE), 116 net::NetLog::EventPhaseToString(net::NetLogEventPhase::NONE),
116 static_cast<int>(net::NetLogEventPhase::NONE)); 117 static_cast<int>(net::NetLogEventPhase::NONE));
117 event_phases->SetInteger( 118 event_phases->SetInteger(
118 net::NetLog::EventPhaseToString(net::NetLogEventPhase::BEGIN), 119 net::NetLog::EventPhaseToString(net::NetLogEventPhase::BEGIN),
119 static_cast<int>(net::NetLogEventPhase::BEGIN)); 120 static_cast<int>(net::NetLogEventPhase::BEGIN));
120 event_phases->SetInteger( 121 event_phases->SetInteger(
121 net::NetLog::EventPhaseToString(net::NetLogEventPhase::END), 122 net::NetLog::EventPhaseToString(net::NetLogEventPhase::END),
122 static_cast<int>(net::NetLogEventPhase::END)); 123 static_cast<int>(net::NetLogEventPhase::END));
123 124
124 base::DictionaryValue* constants = new base::DictionaryValue(); 125 auto constants = base::MakeUnique<base::DictionaryValue>();
125 constants->Set("eventTypes", net::NetLog::GetEventTypesAsValue()); 126 constants->Set("eventTypes", net::NetLog::GetEventTypesAsValue());
126 constants->Set("eventPhases", event_phases); 127 constants->Set("eventPhases", std::move(event_phases));
127 128
128 return constants; 129 return std::move(constants);
129 } 130 }
130 131
131 void MediaInternalsProxy::ObserveMediaInternalsOnIOThread() { 132 void MediaInternalsProxy::ObserveMediaInternalsOnIOThread() {
132 DCHECK_CURRENTLY_ON(BrowserThread::IO); 133 DCHECK_CURRENTLY_ON(BrowserThread::IO);
133 if (GetContentClient()->browser()->GetNetLog()) { 134 if (GetContentClient()->browser()->GetNetLog()) {
134 net::NetLog* net_log = GetContentClient()->browser()->GetNetLog(); 135 net::NetLog* net_log = GetContentClient()->browser()->GetNetLog();
135 net_log->DeprecatedAddObserver( 136 net_log->DeprecatedAddObserver(
136 this, net::NetLogCaptureMode::IncludeCookiesAndCredentials()); 137 this, net::NetLogCaptureMode::IncludeCookiesAndCredentials());
137 } 138 }
138 } 139 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 base::Bind(&MediaInternalsProxy::SendNetEventsOnUIThread, this), 173 base::Bind(&MediaInternalsProxy::SendNetEventsOnUIThread, this),
173 base::TimeDelta::FromMilliseconds( 174 base::TimeDelta::FromMilliseconds(
174 kMediaInternalsProxyEventDelayMilliseconds)); 175 kMediaInternalsProxyEventDelayMilliseconds));
175 } 176 }
176 pending_net_updates_->Append(std::move(entry)); 177 pending_net_updates_->Append(std::move(entry));
177 } 178 }
178 179
179 void MediaInternalsProxy::SendNetEventsOnUIThread() { 180 void MediaInternalsProxy::SendNetEventsOnUIThread() {
180 DCHECK_CURRENTLY_ON(BrowserThread::UI); 181 DCHECK_CURRENTLY_ON(BrowserThread::UI);
181 CallJavaScriptFunctionOnUIThread("media.onNetUpdate", 182 CallJavaScriptFunctionOnUIThread("media.onNetUpdate",
182 pending_net_updates_.release()); 183 std::move(pending_net_updates_));
183 } 184 }
184 185
185 void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread( 186 void MediaInternalsProxy::CallJavaScriptFunctionOnUIThread(
186 const std::string& function, base::Value* args) { 187 const std::string& function,
188 std::unique_ptr<base::Value> args) {
187 DCHECK_CURRENTLY_ON(BrowserThread::UI); 189 DCHECK_CURRENTLY_ON(BrowserThread::UI);
188 std::unique_ptr<base::Value> args_value(args);
189 std::vector<const base::Value*> args_vector; 190 std::vector<const base::Value*> args_vector;
190 args_vector.push_back(args_value.get()); 191 args_vector.push_back(args.get());
191 base::string16 update = WebUI::GetJavascriptCall(function, args_vector); 192 base::string16 update = WebUI::GetJavascriptCall(function, args_vector);
192 UpdateUIOnUIThread(update); 193 UpdateUIOnUIThread(update);
193 } 194 }
194 195
195 } // namespace content 196 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/media_internals_proxy.h ('k') | content/browser/net/network_errors_listing_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698