Description[Thread-safe] Apply base::Passed to WebThread::Task
WebThread::Task can contain RefPtr to a thread-unsafe-reference-counted object
(e.g. WorkerThreadTask can contain RefPtr to WebKit's StringImpl).
This caused a race condition:
[A] When WebThread::Task::run is executed, more RefPtr's to the refcounted
object can be created and the reference counter of the object can be
modified via these RefPtr's (as intended) on the thread where the task
is executed.
[B] However, base::Closure still retains the ownership of WebThread::Task
even after WebThread::Task::run is called.
When base::Closure is deleted, WebThread::Task is deleted and the
reference counter of the object is decreased by one, possibly from a
different thread from [A], which is a race condition.
This CL removes the ownership of WebThread::Task from base::Closure after
WebThread::Task::run is executed by using scoped_ptr and base::Passed.
This removes the reference counter modification of [B] and hence removes the
race condition.
BUG=390851
Committed: https://crrev.com/8446b33c7ea20bd1596f876ab225034b7c5d1162
Cr-Commit-Position: refs/heads/master@{#309396}
Patch Set 1 #
Total comments: 8
Patch Set 2 : #
Total comments: 6
Patch Set 3 : #Messages
Total messages: 13 (3 generated)
|