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

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 math.h to make gn build happy. 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
« no previous file with comments | « content/child/webthread_impl.h ('k') | content/child/worker_task_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webthread_impl.cc
diff --git a/content/child/webthread_impl.cc b/content/child/webthread_impl.cc
index d53d06e061036ba3a2c8fb99c5bcee800471eb24..ede0f8ffc6aeb7834c32bf4276baef7f336c0f60 100644
--- a/content/child/webthread_impl.cc
+++ b/content/child/webthread_impl.cc
@@ -5,6 +5,8 @@
// An implementation of WebThread in terms of base::MessageLoop and
// base::Thread
+#include <math.h>
+
#include "content/child/webthread_impl.h"
#include "base/bind.h"
@@ -88,6 +90,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();
}
« 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