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

Unified Diff: content/child/webmessageportchannel_impl.cc

Issue 2224393002: Fix a data race in WebMessagePortChannelImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webmessageportchannel_impl.cc
diff --git a/content/child/webmessageportchannel_impl.cc b/content/child/webmessageportchannel_impl.cc
index b2ef7e411b2a674aa64fdaf6a16f2e5e94cab345..2b4d265a895c981473ee0968e714490b6d43f3e1 100644
--- a/content/child/webmessageportchannel_impl.cc
+++ b/content/child/webmessageportchannel_impl.cc
@@ -168,9 +168,13 @@ void WebMessagePortChannelImpl::postMessage(
WebMessagePortChannelArray* channels_ptr) {
std::unique_ptr<WebMessagePortChannelArray> channels(channels_ptr);
if (!main_thread_task_runner_->BelongsToCurrentThread()) {
+ // Note: we must construct the base::string16 here and pass that. Otherwise,
+ // the WebString will be passed, leading to references to the StringImpl
+ // from two threads, which is a data race.
main_thread_task_runner_->PostTask(
FROM_HERE, base::Bind(&WebMessagePortChannelImpl::SendPostMessage, this,
- message, base::Passed(std::move(channels))));
+ base::Passed(base::string16(message)),
+ base::Passed(std::move(channels))));
} else {
SendPostMessage(message, std::move(channels));
}
« 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