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

Side by Side Diff: content/child/webthread_impl.cc

Issue 404753002: Revert of Add WorkerThread based methods for start/stop of worker threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/child/webthread_impl.h ('k') | content/child/worker_task_runner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // An implementation of WebThread in terms of base::MessageLoop and 5 // An implementation of WebThread in terms of base::MessageLoop and
6 // base::Thread 6 // base::Thread
7 7
8 #include <math.h>
9
10 #include "content/child/webthread_impl.h" 8 #include "content/child/webthread_impl.h"
11 9
12 #include "base/bind.h" 10 #include "base/bind.h"
13 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
14 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
15 #include "base/pending_task.h" 13 #include "base/pending_task.h"
16 #include "base/threading/platform_thread.h" 14 #include "base/threading/platform_thread.h"
17 15
18 namespace content { 16 namespace content {
19 17
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 void WebThreadImpl::exitRunLoop() { 81 void WebThreadImpl::exitRunLoop() {
84 CHECK(isCurrentThread()); 82 CHECK(isCurrentThread());
85 CHECK(thread_->message_loop()->is_running()); 83 CHECK(thread_->message_loop()->is_running());
86 thread_->message_loop()->Quit(); 84 thread_->message_loop()->Quit();
87 } 85 }
88 86
89 bool WebThreadImpl::isCurrentThread() const { 87 bool WebThreadImpl::isCurrentThread() const {
90 return thread_->thread_id() == base::PlatformThread::CurrentId(); 88 return thread_->thread_id() == base::PlatformThread::CurrentId();
91 } 89 }
92 90
93 void WebThreadImpl::setSharedTimerFiredFunction(
94 SharedTimerFunction timerFunction) {
95 shared_timer_function_ = timerFunction;
96 }
97
98 void WebThreadImpl::setSharedTimerFireInterval(double interval_seconds) {
99 // See BlinkPlatformImpl::setSharedTimerFireInterval for explanation of
100 // why ceil is used in the interval calculation.
101 int64 interval = static_cast<int64>(
102 ceil(interval_seconds * base::Time::kMillisecondsPerSecond)
103 * base::Time::kMicrosecondsPerMillisecond);
104
105 if (interval < 0)
106 interval = 0;
107
108 shared_timer_.Stop();
109 shared_timer_.Start(FROM_HERE, base::TimeDelta::FromMicroseconds(interval),
110 this, &WebThreadImpl::OnTimeout);
111 }
112
113 void WebThreadImpl::stopSharedTimer() {
114 shared_timer_.Stop();
115 }
116
117 WebThreadImpl::~WebThreadImpl() { 91 WebThreadImpl::~WebThreadImpl() {
118 thread_->Stop(); 92 thread_->Stop();
119 } 93 }
120 94
121 WebThreadImplForMessageLoop::WebThreadImplForMessageLoop( 95 WebThreadImplForMessageLoop::WebThreadImplForMessageLoop(
122 base::MessageLoopProxy* message_loop) 96 base::MessageLoopProxy* message_loop)
123 : message_loop_(message_loop) {} 97 : message_loop_(message_loop) {}
124 98
125 void WebThreadImplForMessageLoop::postTask(Task* task) { 99 void WebThreadImplForMessageLoop::postTask(Task* task) {
126 message_loop_->PostTask( 100 message_loop_->PostTask(
(...skipping 21 matching lines...) Expand all
148 base::MessageLoop::current()->Quit(); 122 base::MessageLoop::current()->Quit();
149 } 123 }
150 124
151 bool WebThreadImplForMessageLoop::isCurrentThread() const { 125 bool WebThreadImplForMessageLoop::isCurrentThread() const {
152 return message_loop_->BelongsToCurrentThread(); 126 return message_loop_->BelongsToCurrentThread();
153 } 127 }
154 128
155 WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() {} 129 WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() {}
156 130
157 } // namespace content 131 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webthread_impl.h ('k') | content/child/worker_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698