| 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), | 75 MediaStreamRequestType request_type) |
| 76 : MediaStreamRequest(render_pid, render_vid, origin, request_type), |
| 76 wait_for_audio(IsAudioMediaType(options.audio_type)), | 77 wait_for_audio(IsAudioMediaType(options.audio_type)), |
| 77 wait_for_video(IsVideoMediaType(options.video_type)), | 78 wait_for_video(IsVideoMediaType(options.video_type)), |
| 78 posted_task(false) { | 79 posted_task(false) { |
| 79 DCHECK(wait_for_audio || wait_for_video); | 80 DCHECK(wait_for_audio || wait_for_video); |
| 80 } | 81 } |
| 81 | 82 |
| 82 ~MediaStreamRequestForUI() {} | 83 ~MediaStreamRequestForUI() {} |
| 83 | 84 |
| 84 bool IsRequestReadyForView() const { | 85 bool IsRequestReadyForView() const { |
| 85 if (wait_for_audio || wait_for_video) | 86 if (wait_for_audio || wait_for_video) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 131 |
| 131 MediaStreamUIController::~MediaStreamUIController() { | 132 MediaStreamUIController::~MediaStreamUIController() { |
| 132 DCHECK(requests_.empty()); | 133 DCHECK(requests_.empty()); |
| 133 } | 134 } |
| 134 | 135 |
| 135 void MediaStreamUIController::MakeUIRequest( | 136 void MediaStreamUIController::MakeUIRequest( |
| 136 const std::string& label, | 137 const std::string& label, |
| 137 int render_process_id, | 138 int render_process_id, |
| 138 int render_view_id, | 139 int render_view_id, |
| 139 const StreamOptions& request_options, | 140 const StreamOptions& request_options, |
| 140 const GURL& security_origin) { | 141 const GURL& security_origin, MediaStreamRequestType request_type) { |
| 141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 142 | 143 |
| 143 // Create a new request. | 144 // Create a new request. |
| 144 if (!requests_.insert( | 145 if (!requests_.insert( |
| 145 std::make_pair(label, new MediaStreamRequestForUI( | 146 std::make_pair(label, new MediaStreamRequestForUI( |
| 146 render_process_id, render_view_id, security_origin, | 147 render_process_id, render_view_id, security_origin, |
| 147 request_options))).second) { | 148 request_options, request_type))).second) { |
| 148 NOTREACHED(); | 149 NOTREACHED(); |
| 149 } | 150 } |
| 150 } | 151 } |
| 151 | 152 |
| 152 void MediaStreamUIController::CancelUIRequest(const std::string& label) { | 153 void MediaStreamUIController::CancelUIRequest(const std::string& label) { |
| 153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 154 UIRequests::iterator request_iter = requests_.find(label); | 155 UIRequests::iterator request_iter = requests_.find(label); |
| 155 if (request_iter != requests_.end()) { | 156 if (request_iter != requests_.end()) { |
| 156 // Proceed the next pending request for the same page. | 157 // Proceed the next pending request for the same page. |
| 157 scoped_ptr<MediaStreamRequestForUI> request(request_iter->second); | 158 scoped_ptr<MediaStreamRequestForUI> request(request_iter->second); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 } | 376 } |
| 376 } | 377 } |
| 377 | 378 |
| 378 BrowserThread::PostTask( | 379 BrowserThread::PostTask( |
| 379 BrowserThread::IO, FROM_HERE, | 380 BrowserThread::IO, FROM_HERE, |
| 380 base::Bind(&MediaStreamUIController::PostResponse, | 381 base::Bind(&MediaStreamUIController::PostResponse, |
| 381 weak_ptr_factory_.GetWeakPtr(), label, devices_to_use)); | 382 weak_ptr_factory_.GetWeakPtr(), label, devices_to_use)); |
| 382 } | 383 } |
| 383 | 384 |
| 384 } // namespace content | 385 } // namespace content |
| OLD | NEW |