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

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

Issue 11446042: Make sure that all OpenDevice requests are scrutinized against the audio and video policies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved RequestType according to Shijing's proposal. Created 8 years 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) 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
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 DCHECK(requester_); 129 DCHECK(requester_);
129 } 130 }
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, int render_process_id, int render_view_id, 137 const std::string& label, int render_process_id, int render_view_id,
137 const StreamOptions& request_options, 138 const StreamOptions& request_options,
138 const GURL& security_origin) { 139 const GURL& security_origin, MediaStreamRequestType request_type) {
139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
140 141
141 // Create a new request. 142 // Create a new request.
142 if (!requests_.insert( 143 if (!requests_.insert(
143 std::make_pair(label, new MediaStreamRequestForUI( 144 std::make_pair(label, new MediaStreamRequestForUI(
144 render_process_id, render_view_id, security_origin, 145 render_process_id, render_view_id, security_origin,
145 request_options))).second) { 146 request_options, request_type))).second) {
146 NOTREACHED(); 147 NOTREACHED();
147 } 148 }
148 } 149 }
149 150
150 void MediaStreamUIController::CancelUIRequest(const std::string& label) { 151 void MediaStreamUIController::CancelUIRequest(const std::string& label) {
151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
152 UIRequests::iterator request_iter = requests_.find(label); 153 UIRequests::iterator request_iter = requests_.find(label);
153 if (request_iter != requests_.end()) { 154 if (request_iter != requests_.end()) {
154 // Proceed the next pending request for the same page. 155 // Proceed the next pending request for the same page.
155 scoped_ptr<MediaStreamRequestForUI> request(request_iter->second); 156 scoped_ptr<MediaStreamRequestForUI> request(request_iter->second);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 372 }
372 } 373 }
373 374
374 BrowserThread::PostTask( 375 BrowserThread::PostTask(
375 BrowserThread::IO, FROM_HERE, 376 BrowserThread::IO, FROM_HERE,
376 base::Bind(&MediaStreamUIController::PostResponse, 377 base::Bind(&MediaStreamUIController::PostResponse,
377 weak_ptr_factory_.GetWeakPtr(), label, devices_to_use)); 378 weak_ptr_factory_.GetWeakPtr(), label, devices_to_use));
378 } 379 }
379 380
380 } // namespace content 381 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698