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

Unified Diff: content/child/webthread_impl.cc

Issue 393283003: Add WorkerThread based methods for start/stop of worker threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add shared timer to WebThread. 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 side-by-side diff with in-line comments
Download patch
Index: content/child/webthread_impl.cc
diff --git a/content/child/webthread_impl.cc b/content/child/webthread_impl.cc
index d53d06e061036ba3a2c8fb99c5bcee800471eb24..8ea673789206a61ec0070568bab6060fc3c6d405 100644
--- a/content/child/webthread_impl.cc
+++ b/content/child/webthread_impl.cc
@@ -88,6 +88,30 @@ bool WebThreadImpl::isCurrentThread() const {
return thread_->thread_id() == base::PlatformThread::CurrentId();
}
+void WebThreadImpl::setSharedTimerFiredFunction(
+ SharedTimerFunction timerFunction) {
+ shared_timer_function_ = timerFunction;
+}
+
+void WebThreadImpl::setSharedTimerFireInterval(double interval_seconds) {
+ // See BlinkPlatformImpl::setSharedTimerFireInterval for explanation of
+ // why ceil is used in the interval calculation.
+ int64 interval = static_cast<int64>(
+ ceil(interval_seconds * base::Time::kMillisecondsPerSecond)
+ * base::Time::kMicrosecondsPerMillisecond);
+
+ if (interval < 0)
+ interval = 0;
+
+ shared_timer_.Stop();
+ shared_timer_.Start(FROM_HERE, base::TimeDelta::FromMicroseconds(interval),
+ this, &WebThreadImpl::OnTimeout);
+}
+
+void WebThreadImpl::stopSharedTimer() {
+ shared_timer_.Stop();
+}
+
WebThreadImpl::~WebThreadImpl() {
thread_->Stop();
}

Powered by Google App Engine
This is Rietveld 408576698