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

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

Issue 7284037: Adding MediaStreamManager. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Added DeviceRequest dtor, needed for clang. Created 9 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_device_settings.h" 5 #include "content/browser/renderer_host/media/media_stream_device_settings.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/task.h" 8 #include "base/task.h"
9 #include "content/browser/browser_thread.h" 9 #include "content/browser/browser_thread.h"
10 #include "content/browser/renderer_host/media/media_stream_settings_requester.h" 10 #include "content/browser/renderer_host/media/media_stream_settings_requester.h"
(...skipping 26 matching lines...) Expand all
37 }; 37 };
38 38
39 MediaStreamDeviceSettings::MediaStreamDeviceSettings( 39 MediaStreamDeviceSettings::MediaStreamDeviceSettings(
40 SettingsRequester* requester) 40 SettingsRequester* requester)
41 : requester_(requester) { 41 : requester_(requester) {
42 DCHECK(requester_); 42 DCHECK(requester_);
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
44 } 44 }
45 45
46 MediaStreamDeviceSettings::~MediaStreamDeviceSettings() { 46 MediaStreamDeviceSettings::~MediaStreamDeviceSettings() {
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
48 STLDeleteValues(&requests_); 47 STLDeleteValues(&requests_);
49 } 48 }
50 49
51 void MediaStreamDeviceSettings::RequestCaptureDeviceUsage( 50 void MediaStreamDeviceSettings::RequestCaptureDeviceUsage(
52 const std::string& label, int render_process_id, int render_view_id, 51 const std::string& label, int render_process_id, int render_view_id,
53 const StreamOptions& request_options, const std::string& security_origin) { 52 const StreamOptions& request_options, const std::string& security_origin) {
54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
55 54
56 if (requests_.find(label) != requests_.end()) { 55 if (requests_.find(label) != requests_.end()) {
57 // Request with this id already exists. 56 // Request with this id already exists.
58 requester_->Error(label); 57 requester_->SettingsError(label);
59 return; 58 return;
60 } 59 }
61 60
62 // Create a new request. 61 // Create a new request.
63 requests_.insert(std::make_pair(label, new SettingsRequest(render_process_id, 62 requests_.insert(std::make_pair(label, new SettingsRequest(render_process_id,
64 render_view_id, 63 render_view_id,
65 security_origin, 64 security_origin,
66 request_options))); 65 request_options)));
67 // Ask for available devices. 66 // Ask for available devices.
68 if (request_options.audio) { 67 if (request_options.audio) {
69 requester_->GetDevices(label, kAudioCapture); 68 requester_->GetDevices(label, kAudioCapture);
70 } 69 }
71 if (request_options.video_option != StreamOptions::kNoCamera) { 70 if (request_options.video_option != StreamOptions::kNoCamera) {
72 requester_->GetDevices(label, kVideoCapture); 71 requester_->GetDevices(label, kVideoCapture);
73 } 72 }
74 } 73 }
75 74
76 void MediaStreamDeviceSettings::AvailableDevices( 75 void MediaStreamDeviceSettings::AvailableDevices(
77 const std::string& label, MediaStreamType stream_type, 76 const std::string& label, MediaStreamType stream_type,
78 const StreamDeviceInfoArray& devices) { 77 const StreamDeviceInfoArray& devices) {
79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
80 79
81 SettingsRequests::iterator request_it = requests_.find(label); 80 SettingsRequests::iterator request_it = requests_.find(label);
82 if (request_it == requests_.end()) { 81 if (request_it == requests_.end()) {
83 // Request with this id doesn't exist. 82 // Request with this id doesn't exist.
84 requester_->Error(label); 83 requester_->SettingsError(label);
85 return; 84 return;
86 } 85 }
87 86
88 // Add the answer for the request. 87 // Add the answer for the request.
89 SettingsRequest* request = request_it->second; 88 SettingsRequest* request = request_it->second;
90 request->devices[stream_type] = devices; 89 request->devices[stream_type] = devices;
91 90
92 // Check if we're done. 91 // Check if we're done.
93 size_t num_media_requests = 0; 92 size_t num_media_requests = 0;
94 if (request->options.audio) { 93 if (request->options.audio) {
(...skipping 25 matching lines...) Expand all
120 } 119 }
121 } 120 }
122 // Post result and delete request. 121 // Post result and delete request.
123 requester_->DevicesAccepted(label, devices_to_use); 122 requester_->DevicesAccepted(label, devices_to_use);
124 requests_.erase(request_it); 123 requests_.erase(request_it);
125 delete request; 124 delete request;
126 } 125 }
127 } 126 }
128 127
129 } // namespace media_stream 128 } // namespace media_stream
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698