OLD | NEW |
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_ui_controller.h" | 5 #include "content/browser/renderer_host/media/media_stream_ui_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 } // namespace | 65 } // namespace |
66 | 66 |
67 // UI request contains all data needed to keep track of requests between the | 67 // UI request contains all data needed to keep track of requests between the |
68 // different calls. | 68 // different calls. |
69 class MediaStreamRequestForUI : public MediaStreamRequest { | 69 class MediaStreamRequestForUI : public MediaStreamRequest { |
70 public: | 70 public: |
71 MediaStreamRequestForUI(int render_pid, | 71 MediaStreamRequestForUI(int render_pid, |
72 int render_vid, | 72 int render_vid, |
73 const GURL& origin, | 73 const GURL& origin, |
74 const StreamOptions& options) | 74 const StreamOptions& options, |
75 : MediaStreamRequest(render_pid, render_vid, origin, options.audio_type, | 75 MediaStreamRequestType request_type) |
76 options.video_type), | 76 : MediaStreamRequest(render_pid, render_vid, origin, request_type, |
| 77 options.audio_type, options.video_type), |
77 posted_task(false) { | 78 posted_task(false) { |
78 DCHECK(IsAudioMediaType(options.audio_type) || | 79 DCHECK(IsAudioMediaType(options.audio_type) || |
79 IsVideoMediaType(options.video_type)); | 80 IsVideoMediaType(options.video_type)); |
80 } | 81 } |
81 | 82 |
82 ~MediaStreamRequestForUI() {} | 83 ~MediaStreamRequestForUI() {} |
83 | 84 |
84 // Whether or not a task was posted to make the call to | 85 // Whether or not a task was posted to make the call to |
85 // RequestMediaAccessPermission, to make sure that we never post twice to it. | 86 // RequestMediaAccessPermission, to make sure that we never post twice to it. |
86 bool posted_task; | 87 bool posted_task; |
(...skipping 30 matching lines...) Expand all Loading... |
117 | 118 |
118 MediaStreamUIController::~MediaStreamUIController() { | 119 MediaStreamUIController::~MediaStreamUIController() { |
119 DCHECK(requests_.empty()); | 120 DCHECK(requests_.empty()); |
120 } | 121 } |
121 | 122 |
122 void MediaStreamUIController::MakeUIRequest( | 123 void MediaStreamUIController::MakeUIRequest( |
123 const std::string& label, | 124 const std::string& label, |
124 int render_process_id, | 125 int render_process_id, |
125 int render_view_id, | 126 int render_view_id, |
126 const StreamOptions& request_options, | 127 const StreamOptions& request_options, |
127 const GURL& security_origin) { | 128 const GURL& security_origin, MediaStreamRequestType request_type) { |
128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
129 | 130 |
130 // Create a new request. | 131 // Create a new request. |
131 if (!requests_.insert( | 132 if (!requests_.insert( |
132 std::make_pair(label, new MediaStreamRequestForUI( | 133 std::make_pair(label, new MediaStreamRequestForUI( |
133 render_process_id, render_view_id, security_origin, | 134 render_process_id, render_view_id, security_origin, |
134 request_options))).second) { | 135 request_options, request_type))).second) { |
135 NOTREACHED(); | 136 NOTREACHED(); |
136 } | 137 } |
137 | 138 |
138 if (use_fake_ui_) { | 139 if (use_fake_ui_) { |
139 PostRequestToFakeUI(label); | 140 PostRequestToFakeUI(label); |
140 return; | 141 return; |
141 } | 142 } |
142 | 143 |
143 // The UI can handle only one request at the time, do not post the | 144 // The UI can handle only one request at the time, do not post the |
144 // request to the view if the UI is handling any other request. | 145 // request to the view if the UI is handling any other request. |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 } | 337 } |
337 } | 338 } |
338 | 339 |
339 BrowserThread::PostTask( | 340 BrowserThread::PostTask( |
340 BrowserThread::IO, FROM_HERE, | 341 BrowserThread::IO, FROM_HERE, |
341 base::Bind(&MediaStreamUIController::PostResponse, | 342 base::Bind(&MediaStreamUIController::PostResponse, |
342 weak_ptr_factory_.GetWeakPtr(), label, devices_to_use)); | 343 weak_ptr_factory_.GetWeakPtr(), label, devices_to_use)); |
343 } | 344 } |
344 | 345 |
345 } // namespace content | 346 } // namespace content |
OLD | NEW |