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

Unified Diff: content/renderer/media/rtc_certificate_generator.cc

Issue 2164503002: Do not delete blink::WebRTCCertificateCallback on non-main thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/rtc_certificate_generator.cc
diff --git a/content/renderer/media/rtc_certificate_generator.cc b/content/renderer/media/rtc_certificate_generator.cc
index aa3f8d72c93fae0a19ea5bf5aa505de41c65b530..2365f625479d0621a75a9816d04052eef80b6516 100644
--- a/content/renderer/media/rtc_certificate_generator.cc
+++ b/content/renderer/media/rtc_certificate_generator.cc
@@ -43,6 +43,10 @@ rtc::KeyParams WebRTCKeyParamsToKeyParams(
// request alive independently of the |RTCCertificateGenerator| that spawned it.
class RTCCertificateGeneratorRequest
: public base::RefCountedThreadSafe<RTCCertificateGeneratorRequest> {
+ private:
+ using CertificateCallbackPtr = std::unique_ptr<
+ blink::WebRTCCertificateCallback,
+ base::OnTaskRunnerDeleter>;
public:
RTCCertificateGeneratorRequest(
const scoped_refptr<base::SingleThreadTaskRunner>& main_thread,
@@ -59,12 +63,16 @@ class RTCCertificateGeneratorRequest
std::unique_ptr<blink::WebRTCCertificateCallback> observer) {
DCHECK(main_thread_->BelongsToCurrentThread());
DCHECK(observer);
+
+ auto transition = base::WrapUnique(
dcheng 2016/07/22 06:12:04 Since this is typedefed, maybe we can just write C
tzik 2016/07/22 07:27:21 Done.
+ observer.release(),
+ base::OnTaskRunnerDeleter(base::ThreadTaskRunnerHandle::Get()));
worker_thread_->PostTask(FROM_HERE, base::Bind(
&RTCCertificateGeneratorRequest::GenerateCertificateOnWorkerThread,
this,
key_params,
expires_ms,
- base::Passed(std::move(observer))));
+ base::Passed(std::move(transition))));
}
private:
@@ -74,7 +82,7 @@ class RTCCertificateGeneratorRequest
void GenerateCertificateOnWorkerThread(
const blink::WebRTCKeyParams key_params,
const rtc::Optional<uint64_t> expires_ms,
- std::unique_ptr<blink::WebRTCCertificateCallback> observer) {
+ CertificateCallbackPtr observer) {
DCHECK(worker_thread_->BelongsToCurrentThread());
rtc::scoped_refptr<rtc::RTCCertificate> certificate =
@@ -89,7 +97,7 @@ class RTCCertificateGeneratorRequest
}
void DoCallbackOnMainThread(
- std::unique_ptr<blink::WebRTCCertificateCallback> observer,
+ CertificateCallbackPtr observer,
std::unique_ptr<blink::WebRTCCertificate> certificate) {
DCHECK(main_thread_->BelongsToCurrentThread());
DCHECK(observer);
« base/sequenced_task_runner_unittest.cc ('K') | « base/sequenced_task_runner_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698