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

Side by Side Diff: content/renderer/media/rtc_peer_connection_handler.cc

Issue 1023443007: Make sure Blink WebRTCSessionDescriptionRequest and WebRTCVoidRequest are deleted on the correct th… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/media/rtc_peer_connection_handler.h" 5 #include "content/renderer/media/rtc_peer_connection_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 void OnSuccess(webrtc::SessionDescriptionInterface* desc) override { 256 void OnSuccess(webrtc::SessionDescriptionInterface* desc) override {
257 if (!main_thread_->BelongsToCurrentThread()) { 257 if (!main_thread_->BelongsToCurrentThread()) {
258 main_thread_->PostTask(FROM_HERE, 258 main_thread_->PostTask(FROM_HERE,
259 base::Bind(&CreateSessionDescriptionRequest::OnSuccess, this, desc)); 259 base::Bind(&CreateSessionDescriptionRequest::OnSuccess, this, desc));
260 return; 260 return;
261 } 261 }
262 262
263 tracker_.TrackOnSuccess(desc); 263 tracker_.TrackOnSuccess(desc);
264 webkit_request_.requestSucceeded(CreateWebKitSessionDescription(desc)); 264 webkit_request_.requestSucceeded(CreateWebKitSessionDescription(desc));
265 webkit_request_.reset();
265 delete desc; 266 delete desc;
266 } 267 }
267 void OnFailure(const std::string& error) override { 268 void OnFailure(const std::string& error) override {
268 if (!main_thread_->BelongsToCurrentThread()) { 269 if (!main_thread_->BelongsToCurrentThread()) {
269 main_thread_->PostTask(FROM_HERE, 270 main_thread_->PostTask(FROM_HERE,
270 base::Bind(&CreateSessionDescriptionRequest::OnFailure, this, error)); 271 base::Bind(&CreateSessionDescriptionRequest::OnFailure, this, error));
271 return; 272 return;
272 } 273 }
273 274
274 tracker_.TrackOnFailure(error); 275 tracker_.TrackOnFailure(error);
275 webkit_request_.requestFailed(base::UTF8ToUTF16(error)); 276 webkit_request_.requestFailed(base::UTF8ToUTF16(error));
277 webkit_request_.reset();
276 } 278 }
277 279
278 protected: 280 protected:
279 ~CreateSessionDescriptionRequest() override {} 281 ~CreateSessionDescriptionRequest() override {
282 DCHECK(webkit_request_.isNull());
283 }
280 284
281 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_; 285 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_;
282 blink::WebRTCSessionDescriptionRequest webkit_request_; 286 blink::WebRTCSessionDescriptionRequest webkit_request_;
283 SessionDescriptionRequestTracker tracker_; 287 SessionDescriptionRequestTracker tracker_;
284 }; 288 };
285 289
286 // Class mapping responses from calls to libjingle 290 // Class mapping responses from calls to libjingle
287 // SetLocalDescription/SetRemoteDescription and a blink::WebRTCVoidRequest. 291 // SetLocalDescription/SetRemoteDescription and a blink::WebRTCVoidRequest.
288 class SetSessionDescriptionRequest 292 class SetSessionDescriptionRequest
289 : public webrtc::SetSessionDescriptionObserver { 293 : public webrtc::SetSessionDescriptionObserver {
(...skipping 10 matching lines...) Expand all
300 } 304 }
301 305
302 void OnSuccess() override { 306 void OnSuccess() override {
303 if (!main_thread_->BelongsToCurrentThread()) { 307 if (!main_thread_->BelongsToCurrentThread()) {
304 main_thread_->PostTask(FROM_HERE, 308 main_thread_->PostTask(FROM_HERE,
305 base::Bind(&SetSessionDescriptionRequest::OnSuccess, this)); 309 base::Bind(&SetSessionDescriptionRequest::OnSuccess, this));
306 return; 310 return;
307 } 311 }
308 tracker_.TrackOnSuccess(NULL); 312 tracker_.TrackOnSuccess(NULL);
309 webkit_request_.requestSucceeded(); 313 webkit_request_.requestSucceeded();
314 webkit_request_.reset();
310 } 315 }
311 void OnFailure(const std::string& error) override { 316 void OnFailure(const std::string& error) override {
312 if (!main_thread_->BelongsToCurrentThread()) { 317 if (!main_thread_->BelongsToCurrentThread()) {
313 main_thread_->PostTask(FROM_HERE, 318 main_thread_->PostTask(FROM_HERE,
314 base::Bind(&SetSessionDescriptionRequest::OnFailure, this, error)); 319 base::Bind(&SetSessionDescriptionRequest::OnFailure, this, error));
315 return; 320 return;
316 } 321 }
317 tracker_.TrackOnFailure(error); 322 tracker_.TrackOnFailure(error);
318 webkit_request_.requestFailed(base::UTF8ToUTF16(error)); 323 webkit_request_.requestFailed(base::UTF8ToUTF16(error));
324 webkit_request_.reset();
319 } 325 }
320 326
321 protected: 327 protected:
322 ~SetSessionDescriptionRequest() override {} 328 ~SetSessionDescriptionRequest() override {
329 DCHECK(webkit_request_.isNull());
330 }
323 331
324 private: 332 private:
325 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_; 333 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_;
326 blink::WebRTCVoidRequest webkit_request_; 334 blink::WebRTCVoidRequest webkit_request_;
327 SessionDescriptionRequestTracker tracker_; 335 SessionDescriptionRequestTracker tracker_;
328 }; 336 };
329 337
330 // Class mapping responses from calls to libjingle 338 // Class mapping responses from calls to libjingle
331 // GetStats into a blink::WebRTCStatsCallback. 339 // GetStats into a blink::WebRTCStatsCallback.
332 class StatsResponse : public webrtc::StatsObserver { 340 class StatsResponse : public webrtc::StatsObserver {
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 base::WaitableEvent event(false, false); 1476 base::WaitableEvent event(false, false);
1469 thread->PostTask(FROM_HERE, 1477 thread->PostTask(FROM_HERE,
1470 base::Bind(&RunSynchronousClosure, closure, 1478 base::Bind(&RunSynchronousClosure, closure,
1471 base::Unretained(trace_event_name), 1479 base::Unretained(trace_event_name),
1472 base::Unretained(&event))); 1480 base::Unretained(&event)));
1473 event.Wait(); 1481 event.Wait();
1474 } 1482 }
1475 } 1483 }
1476 1484
1477 } // namespace content 1485 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698