Commit ef82c674 authored by Takashi Toyoshima's avatar Takashi Toyoshima Committed by Commit Bot

Blink Loader: make FetchContext::NullInstance thread-safe

Accessing FetchContext passed to ResourceLoadScheduler causes
indeterminate crashes. This implies that there might be a race to
access NullInstance because dedicated FetchContext instance
should be passed in usual production code path, and NullInstance
use is only the exception. XHR will touch this regardless of
threads, and can cause a race condition among the first and the
second access over multiple-threading.

This patch creates new FetchContext instance always instead of
sharing one instance among all threads. If this affects performance
we would consider to make it thread-local.

Bug: 803849
Change-Id: I8bcdab577aceccaaea15288c6e3ae4c83f218213
Reviewed-on: https://chromium-review.googlesource.com/880421
Commit-Queue: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532396}
parent 13c588bc
...@@ -36,8 +36,7 @@ ...@@ -36,8 +36,7 @@
namespace blink { namespace blink {
FetchContext& FetchContext::NullInstance() { FetchContext& FetchContext::NullInstance() {
DEFINE_STATIC_LOCAL(FetchContext, instance, (new FetchContext)); return *(new FetchContext);
return instance;
} }
FetchContext::FetchContext() : platform_probe_sink_(new PlatformProbeSink) { FetchContext::FetchContext() : platform_probe_sink_(new PlatformProbeSink) {
......
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