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

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

Issue 399653003: Prepare chromium for WorkerThread migration to WebThread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix check in PostTask 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
8 #include "content/child/webthread_impl.h" 10 #include "content/child/webthread_impl.h"
9 11
10 #include "base/bind.h" 12 #include "base/bind.h"
11 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
12 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
13 #include "base/pending_task.h" 15 #include "base/pending_task.h"
14 #include "base/threading/platform_thread.h" 16 #include "base/threading/platform_thread.h"
15 17
16 namespace content { 18 namespace content {
17 19
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 void WebThreadImpl::exitRunLoop() { 83 void WebThreadImpl::exitRunLoop() {
82 CHECK(isCurrentThread()); 84 CHECK(isCurrentThread());
83 CHECK(thread_->message_loop()->is_running()); 85 CHECK(thread_->message_loop()->is_running());
84 thread_->message_loop()->Quit(); 86 thread_->message_loop()->Quit();
85 } 87 }
86 88
87 bool WebThreadImpl::isCurrentThread() const { 89 bool WebThreadImpl::isCurrentThread() const {
88 return thread_->thread_id() == base::PlatformThread::CurrentId(); 90 return thread_->thread_id() == base::PlatformThread::CurrentId();
89 } 91 }
90 92
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
91 WebThreadImpl::~WebThreadImpl() { 117 WebThreadImpl::~WebThreadImpl() {
92 thread_->Stop(); 118 thread_->Stop();
93 } 119 }
94 120
95 WebThreadImplForMessageLoop::WebThreadImplForMessageLoop( 121 WebThreadImplForMessageLoop::WebThreadImplForMessageLoop(
96 base::MessageLoopProxy* message_loop) 122 base::MessageLoopProxy* message_loop)
97 : message_loop_(message_loop) {} 123 : message_loop_(message_loop) {}
98 124
99 void WebThreadImplForMessageLoop::postTask(Task* task) { 125 void WebThreadImplForMessageLoop::postTask(Task* task) {
100 message_loop_->PostTask( 126 message_loop_->PostTask(
(...skipping 21 matching lines...) Expand all
122 base::MessageLoop::current()->Quit(); 148 base::MessageLoop::current()->Quit();
123 } 149 }
124 150
125 bool WebThreadImplForMessageLoop::isCurrentThread() const { 151 bool WebThreadImplForMessageLoop::isCurrentThread() const {
126 return message_loop_->BelongsToCurrentThread(); 152 return message_loop_->BelongsToCurrentThread();
127 } 153 }
128 154
129 WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() {} 155 WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() {}
130 156
131 } // namespace content 157 } // 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