Commit 0774fed9 authored by Thomas Guilbert's avatar Thomas Guilbert Committed by Chromium LUCI CQ

Prevent log creation in detached context

This CL fixes a race condition in which a MediaLog could be created in
a context that is already destroyed. See the attached bug for more
details.

Bug: 1154468
Change-Id: I26ae0c621d9a4557d224ca77f696ad3ce53b41c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2580478Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Thomas Guilbert <tguilbert@chromium.org>
Auto-Submit: Thomas Guilbert <tguilbert@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835842}
parent 87d86528
...@@ -17,9 +17,18 @@ CodecLogger::CodecLogger( ...@@ -17,9 +17,18 @@ CodecLogger::CodecLogger(
ExecutionContext* context, ExecutionContext* context,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) { scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
DCHECK(context); DCHECK(context);
parent_media_log_ = Platform::Current()->GetMediaLog(
MediaInspectorContextImpl::From(*context), task_runner);
// Owners of |this| should be ExecutionLifeCycleObservers, and should call
// Neuter() if |context| is destroyed. The MediaInspectorContextImpl must
// outlive |parent_media_log_|. If |context| is already destroyed, owners
// might never call Neuter(), and MediaInspectorContextImpl* could be garbage
// collected before |parent_media_log_| is destroyed.
if (!context->IsContextDestroyed()) {
parent_media_log_ = Platform::Current()->GetMediaLog(
MediaInspectorContextImpl::From(*context), task_runner);
}
// NullMediaLog silently and safely does nothing.
if (!parent_media_log_) if (!parent_media_log_)
parent_media_log_ = std::make_unique<media::NullMediaLog>(); parent_media_log_ = std::make_unique<media::NullMediaLog>();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment