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

Side by Side Diff: content/browser/renderer_host/media/media_stream_manager.cc

Issue 1545243002: Convert Pass()→std::move() in //content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/renderer_host/media/media_stream_manager.h" 5 #include "content/browser/renderer_host/media/media_stream_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10
11 #include <cctype> 10 #include <cctype>
12 #include <list> 11 #include <list>
12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/power_monitor/power_monitor.h" 20 #include "base/power_monitor/power_monitor.h"
21 #include "base/profiler/scoped_tracker.h" 21 #include "base/profiler/scoped_tracker.h"
22 #include "base/rand_util.h" 22 #include "base/rand_util.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 user_gesture, 272 user_gesture,
273 request_type, 273 request_type,
274 "", 274 "",
275 "", 275 "",
276 audio_type_, 276 audio_type_,
277 video_type_)); 277 video_type_));
278 } 278 }
279 279
280 bool HasUIRequest() const { return ui_request_.get() != nullptr; } 280 bool HasUIRequest() const { return ui_request_.get() != nullptr; }
281 scoped_ptr<MediaStreamRequest> DetachUIRequest() { 281 scoped_ptr<MediaStreamRequest> DetachUIRequest() {
282 return ui_request_.Pass(); 282 return std::move(ui_request_);
283 } 283 }
284 284
285 // Update the request state and notify observers. 285 // Update the request state and notify observers.
286 void SetState(MediaStreamType stream_type, MediaRequestState new_state) { 286 void SetState(MediaStreamType stream_type, MediaRequestState new_state) {
287 if (stream_type == NUM_MEDIA_TYPES) { 287 if (stream_type == NUM_MEDIA_TYPES) {
288 for (int i = MEDIA_NO_SERVICE + 1; i < NUM_MEDIA_TYPES; ++i) { 288 for (int i = MEDIA_NO_SERVICE + 1; i < NUM_MEDIA_TYPES; ++i) {
289 const MediaStreamType stream_type = static_cast<MediaStreamType>(i); 289 const MediaStreamType stream_type = static_cast<MediaStreamType>(i);
290 state_[stream_type] = new_state; 290 state_[stream_type] = new_state;
291 } 291 }
292 } else { 292 } else {
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 } 1139 }
1140 if (video_enumeration_cache_.valid) { 1140 if (video_enumeration_cache_.valid) {
1141 for (const StreamDeviceInfo& device_info : 1141 for (const StreamDeviceInfo& device_info :
1142 video_enumeration_cache_.devices) { 1142 video_enumeration_cache_.devices) {
1143 devices.push_back(device_info.device); 1143 devices.push_back(device_info.device);
1144 } 1144 }
1145 } 1145 }
1146 1146
1147 fake_ui_->SetAvailableDevices(devices); 1147 fake_ui_->SetAvailableDevices(devices);
1148 1148
1149 request->ui_proxy = fake_ui_.Pass(); 1149 request->ui_proxy = std::move(fake_ui_);
1150 } else { 1150 } else {
1151 request->ui_proxy = MediaStreamUIProxy::Create(); 1151 request->ui_proxy = MediaStreamUIProxy::Create();
1152 } 1152 }
1153 1153
1154 request->ui_proxy->RequestAccess( 1154 request->ui_proxy->RequestAccess(
1155 request->DetachUIRequest(), 1155 request->DetachUIRequest(),
1156 base::Bind(&MediaStreamManager::HandleAccessRequestResponse, 1156 base::Bind(&MediaStreamManager::HandleAccessRequestResponse,
1157 base::Unretained(this), label)); 1157 base::Unretained(this), label));
1158 } 1158 }
1159 1159
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 DeviceRequest* request, 1388 DeviceRequest* request,
1389 content::MediaStreamRequestResult result) { 1389 content::MediaStreamRequestResult result) {
1390 if (request->requester) 1390 if (request->requester)
1391 request->requester->StreamGenerationFailed( 1391 request->requester->StreamGenerationFailed(
1392 request->requesting_frame_id, 1392 request->requesting_frame_id,
1393 request->page_request_id, 1393 request->page_request_id,
1394 result); 1394 result);
1395 1395
1396 if (request->request_type == MEDIA_DEVICE_ACCESS && 1396 if (request->request_type == MEDIA_DEVICE_ACCESS &&
1397 !request->callback.is_null()) { 1397 !request->callback.is_null()) {
1398 request->callback.Run(MediaStreamDevices(), request->ui_proxy.Pass()); 1398 request->callback.Run(MediaStreamDevices(), std::move(request->ui_proxy));
1399 } 1399 }
1400 1400
1401 DeleteRequest(label); 1401 DeleteRequest(label);
1402 } 1402 }
1403 1403
1404 void MediaStreamManager::FinalizeOpenDevice(const std::string& label, 1404 void MediaStreamManager::FinalizeOpenDevice(const std::string& label,
1405 DeviceRequest* request) { 1405 DeviceRequest* request) {
1406 const StreamDeviceInfoArray& requested_devices = request->devices; 1406 const StreamDeviceInfoArray& requested_devices = request->devices;
1407 request->requester->DeviceOpened(request->requesting_frame_id, 1407 request->requester->DeviceOpened(request->requesting_frame_id,
1408 request->page_request_id, 1408 request->page_request_id,
(...skipping 13 matching lines...) Expand all
1422 if (request->security_origin.is_valid()) { 1422 if (request->security_origin.is_valid()) {
1423 for (StreamDeviceInfo& device_info : request->devices) 1423 for (StreamDeviceInfo& device_info : request->devices)
1424 TranslateDeviceIdToSourceId(request, &device_info.device); 1424 TranslateDeviceIdToSourceId(request, &device_info.device);
1425 } else { 1425 } else {
1426 request->devices.clear(); 1426 request->devices.clear();
1427 } 1427 }
1428 1428
1429 if (use_fake_ui_) { 1429 if (use_fake_ui_) {
1430 if (!fake_ui_) 1430 if (!fake_ui_)
1431 fake_ui_.reset(new FakeMediaStreamUIProxy()); 1431 fake_ui_.reset(new FakeMediaStreamUIProxy());
1432 request->ui_proxy = fake_ui_.Pass(); 1432 request->ui_proxy = std::move(fake_ui_);
1433 } else { 1433 } else {
1434 request->ui_proxy = MediaStreamUIProxy::Create(); 1434 request->ui_proxy = MediaStreamUIProxy::Create();
1435 } 1435 }
1436 1436
1437 // Output label permissions are based on input permission. 1437 // Output label permissions are based on input permission.
1438 const MediaStreamType type = 1438 const MediaStreamType type =
1439 request->audio_type() == MEDIA_DEVICE_AUDIO_CAPTURE || 1439 request->audio_type() == MEDIA_DEVICE_AUDIO_CAPTURE ||
1440 request->audio_type() == MEDIA_DEVICE_AUDIO_OUTPUT 1440 request->audio_type() == MEDIA_DEVICE_AUDIO_OUTPUT
1441 ? MEDIA_DEVICE_AUDIO_CAPTURE 1441 ? MEDIA_DEVICE_AUDIO_CAPTURE
1442 : MEDIA_DEVICE_VIDEO_CAPTURE; 1442 : MEDIA_DEVICE_VIDEO_CAPTURE;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 // enumeration requests and uncomment the following line: 1500 // enumeration requests and uncomment the following line:
1501 // 1501 //
1502 // DeleteRequest(label); 1502 // DeleteRequest(label);
1503 } 1503 }
1504 1504
1505 void MediaStreamManager::FinalizeMediaAccessRequest( 1505 void MediaStreamManager::FinalizeMediaAccessRequest(
1506 const std::string& label, 1506 const std::string& label,
1507 DeviceRequest* request, 1507 DeviceRequest* request,
1508 const MediaStreamDevices& devices) { 1508 const MediaStreamDevices& devices) {
1509 if (!request->callback.is_null()) 1509 if (!request->callback.is_null())
1510 request->callback.Run(devices, request->ui_proxy.Pass()); 1510 request->callback.Run(devices, std::move(request->ui_proxy));
1511 1511
1512 // Delete the request since it is done. 1512 // Delete the request since it is done.
1513 DeleteRequest(label); 1513 DeleteRequest(label);
1514 } 1514 }
1515 1515
1516 void MediaStreamManager::InitializeDeviceManagersOnIOThread() { 1516 void MediaStreamManager::InitializeDeviceManagersOnIOThread() {
1517 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1517 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1518 // Store a pointer to |this| on the IO thread to avoid having to jump to the 1518 // Store a pointer to |this| on the IO thread to avoid having to jump to the
1519 // UI thread to fetch a pointer to the MSM. In particular on Android, it can 1519 // UI thread to fetch a pointer to the MSM. In particular on Android, it can
1520 // be problematic to post to a UI thread from arbitrary worker threads since 1520 // be problematic to post to a UI thread from arbitrary worker threads since
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 } 1752 }
1753 1753
1754 void MediaStreamManager::OnResume() { 1754 void MediaStreamManager::OnResume() {
1755 SendMessageToNativeLog("Power state resumed."); 1755 SendMessageToNativeLog("Power state resumed.");
1756 } 1756 }
1757 1757
1758 void MediaStreamManager::UseFakeUIForTests( 1758 void MediaStreamManager::UseFakeUIForTests(
1759 scoped_ptr<FakeMediaStreamUIProxy> fake_ui) { 1759 scoped_ptr<FakeMediaStreamUIProxy> fake_ui) {
1760 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1760 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1761 use_fake_ui_ = true; 1761 use_fake_ui_ = true;
1762 fake_ui_ = fake_ui.Pass(); 1762 fake_ui_ = std::move(fake_ui);
1763 } 1763 }
1764 1764
1765 void MediaStreamManager::RegisterNativeLogCallback( 1765 void MediaStreamManager::RegisterNativeLogCallback(
1766 int renderer_host_id, 1766 int renderer_host_id,
1767 const base::Callback<void(const std::string&)>& callback) { 1767 const base::Callback<void(const std::string&)>& callback) {
1768 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 1768 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
1769 base::Bind(&MediaStreamManager::DoNativeLogCallbackRegistration, 1769 base::Bind(&MediaStreamManager::DoNativeLogCallbackRegistration,
1770 base::Unretained(this), renderer_host_id, callback)); 1770 base::Unretained(this), renderer_host_id, callback));
1771 } 1771 }
1772 1772
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2073 const std::string& device_guid, 2073 const std::string& device_guid,
2074 const std::string& raw_unique_id) { 2074 const std::string& raw_unique_id) {
2075 DCHECK(security_origin.is_valid()); 2075 DCHECK(security_origin.is_valid());
2076 DCHECK(!raw_unique_id.empty()); 2076 DCHECK(!raw_unique_id.empty());
2077 std::string guid_from_raw_device_id = 2077 std::string guid_from_raw_device_id =
2078 GetHMACForMediaDeviceID(sc, security_origin, raw_unique_id); 2078 GetHMACForMediaDeviceID(sc, security_origin, raw_unique_id);
2079 return guid_from_raw_device_id == device_guid; 2079 return guid_from_raw_device_id == device_guid;
2080 } 2080 }
2081 2081
2082 } // namespace content 2082 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698