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

Unified Diff: components/scheduler/child/webthread_base.cc

Issue 1309423004: Introduce WebTaskRunner Patch 4/5 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Try and fix compile Created 5 years, 3 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 | « components/scheduler/child/webthread_base.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/scheduler/child/webthread_base.cc
diff --git a/components/scheduler/child/webthread_base.cc b/components/scheduler/child/webthread_base.cc
index a48849d35403514f548641cfb2ab805ace71f2bd..71c2b3189c53726ccfa5d12bd0437d3da001438a 100644
--- a/components/scheduler/child/webthread_base.cc
+++ b/components/scheduler/child/webthread_base.cc
@@ -72,35 +72,6 @@ void WebThreadBase::RemoveTaskObserverInternal(
base::MessageLoop::current()->RemoveTaskObserver(observer);
}
-// RunWebThreadTask takes the ownership of |task| from base::Closure and
-// deletes it on the first invocation of the closure for thread-safety.
-// base::Closure made from RunWebThreadTask is copyable but Closure::Run
-// should be called at most only once.
-// This is because WebThread::Task can contain RefPtr to a
-// thread-unsafe-reference-counted object (e.g. WorkerThreadTask can contain
-// RefPtr to WebKit's StringImpl), and if we don't delete |task| here,
-// it causes a race condition as follows:
-// [A] In task->run(), 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 RunWebThreadTask 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.
-// Taking the ownership of |task| here by using scoped_ptr and base::Passed
-// removes the reference counter modification of [B] and the race condition.
-// When the closure never runs at all, the corresponding WebThread::Task is
-// destructed when base::Closure is deleted (like [B]). In this case, there
-// are no reference counter modification like [A] (because task->run() is not
-// executed), so there are no race conditions.
-// See https://crbug.com/390851 for more details.
-//
-// static
-void WebThreadBase::RunWebThreadTask(scoped_ptr<blink::WebThread::Task> task) {
- task->run();
-}
-
// static
void WebThreadBase::RunWebThreadIdleTask(
scoped_ptr<blink::WebThread::IdleTask> idle_task,
@@ -108,22 +79,6 @@ void WebThreadBase::RunWebThreadIdleTask(
idle_task->run((deadline - base::TimeTicks()).InSecondsF());
}
-void WebThreadBase::postTask(const blink::WebTraceLocation& location,
- Task* task) {
- postDelayedTask(location, task, 0);
-}
-
-void WebThreadBase::postDelayedTask(const blink::WebTraceLocation& web_location,
- Task* task,
- long long delay_ms) {
- tracked_objects::Location location(web_location.functionName(),
- web_location.fileName(), -1, nullptr);
- TaskRunner()->PostDelayedTask(
- location,
- base::Bind(RunWebThreadTask, base::Passed(make_scoped_ptr(task))),
- base::TimeDelta::FromMilliseconds(delay_ms));
-}
-
void WebThreadBase::postIdleTask(const blink::WebTraceLocation& web_location,
IdleTask* idle_task) {
tracked_objects::Location location(web_location.functionName(),
« no previous file with comments | « components/scheduler/child/webthread_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698