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

Side by Side Diff: chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc

Issue 1833053004: [Extensions] Convert APIs to use movable types [10] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/extensions/api/webrtc_audio_private/webrtc_audio_privat e_api.h" 5 #include "chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_privat e_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 InitDeviceIDSalt(); 218 InitDeviceIDSalt();
219 GetOutputDeviceNames(); 219 GetOutputDeviceNames();
220 220
221 return true; 221 return true;
222 } 222 }
223 223
224 void WebrtcAudioPrivateGetSinksFunction::OnOutputDeviceNames( 224 void WebrtcAudioPrivateGetSinksFunction::OnOutputDeviceNames(
225 scoped_ptr<AudioDeviceNames> raw_ids) { 225 scoped_ptr<AudioDeviceNames> raw_ids) {
226 DCHECK_CURRENTLY_ON(BrowserThread::IO); 226 DCHECK_CURRENTLY_ON(BrowserThread::IO);
227 227
228 std::vector<linked_ptr<wap::SinkInfo> > results; 228 std::vector<wap::SinkInfo> results;
229 for (AudioDeviceNames::const_iterator it = raw_ids->begin(); 229 for (const media::AudioDeviceName& name : *raw_ids) {
230 it != raw_ids->end(); 230 wap::SinkInfo info;
231 ++it) { 231 info.sink_id = CalculateHMACImpl(name.unique_id);
232 linked_ptr<wap::SinkInfo> info(new wap::SinkInfo); 232 info.sink_label = name.device_name;
233 info->sink_id = CalculateHMACImpl(it->unique_id);
234 info->sink_label = it->device_name;
235 // TODO(joi): Add other parameters. 233 // TODO(joi): Add other parameters.
236 results.push_back(info); 234 results.push_back(std::move(info));
237 } 235 }
238 236
239 // It's safe to directly set the results here (from a thread other 237 // It's safe to directly set the results here (from a thread other
240 // than the UI thread, on which an AsyncExtensionFunction otherwise 238 // than the UI thread, on which an AsyncExtensionFunction otherwise
241 // normally runs) because there is one instance of this object per 239 // normally runs) because there is one instance of this object per
242 // function call, no actor outside of this object is modifying the 240 // function call, no actor outside of this object is modifying the
243 // results_ member, and the different method invocations on this 241 // results_ member, and the different method invocations on this
244 // object run strictly in sequence; first RunAsync on the UI thread, 242 // object run strictly in sequence; first RunAsync on the UI thread,
245 // then DoQuery on the audio IO thread, then DoneOnUIThread on the 243 // then DoQuery on the audio IO thread, then DoneOnUIThread on the
246 // UI thread. 244 // UI thread.
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 results_.reset(wap::GetAssociatedSink::Results::Create("").release()); 495 results_.reset(wap::GetAssociatedSink::Results::Create("").release());
498 } else { 496 } else {
499 results_.reset( 497 results_.reset(
500 wap::GetAssociatedSink::Results::Create(associated_sink_id).release()); 498 wap::GetAssociatedSink::Results::Create(associated_sink_id).release());
501 } 499 }
502 500
503 SendResponse(true); 501 SendResponse(true);
504 } 502 }
505 503
506 } // namespace extensions 504 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698