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

Unified Diff: content/child/webthread_impl.cc

Issue 416453002: Move the shared timer to be dynamically allocated. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/webthread_impl.h ('k') | no next file » | 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 ede0f8ffc6aeb7834c32bf4276baef7f336c0f60..9375c28a4d855b2ebacaee7b6d50babd93fdf7e8 100644
--- a/content/child/webthread_impl.cc
+++ b/content/child/webthread_impl.cc
@@ -93,9 +93,15 @@ bool WebThreadImpl::isCurrentThread() const {
void WebThreadImpl::setSharedTimerFiredFunction(
SharedTimerFunction timerFunction) {
shared_timer_function_ = timerFunction;
+ if (shared_timer_function_ != NULL)
+ shared_timer_.reset(new base::OneShotTimer<WebThreadImpl>());
+ else
+ shared_timer_.reset(NULL);
}
void WebThreadImpl::setSharedTimerFireInterval(double interval_seconds) {
+ DCHECK(shared_timer_function_);
+
// See BlinkPlatformImpl::setSharedTimerFireInterval for explanation of
// why ceil is used in the interval calculation.
int64 interval = static_cast<int64>(
@@ -105,13 +111,14 @@ void WebThreadImpl::setSharedTimerFireInterval(double interval_seconds) {
if (interval < 0)
interval = 0;
- shared_timer_.Stop();
- shared_timer_.Start(FROM_HERE, base::TimeDelta::FromMicroseconds(interval),
+ shared_timer_->Stop();
+ shared_timer_->Start(FROM_HERE, base::TimeDelta::FromMicroseconds(interval),
this, &WebThreadImpl::OnTimeout);
}
void WebThreadImpl::stopSharedTimer() {
- shared_timer_.Stop();
+ DCHECK(shared_timer_function_);
+ shared_timer_->Stop();
}
WebThreadImpl::~WebThreadImpl() {
« no previous file with comments | « content/child/webthread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698