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

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: rebase Created 4 years, 4 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
« no previous file with comments | « base/sequenced_task_runner_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4b819c89056c8d89d6eaf3436b8744e1c4257667 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);
+
+ CertificateCallbackPtr transition(
+ 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(&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);
« no previous file with comments | « base/sequenced_task_runner_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698