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

Side by Side Diff: chrome/common/worker_thread_ticker.cc

Issue 1167163002: chrome: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added some missing message_loop.h includes. Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/common/worker_thread_ticker.h" 5 #include "chrome/common/worker_thread_ticker.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/location.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 13 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
14 15
15 WorkerThreadTicker::WorkerThreadTicker(int tick_interval) 16 WorkerThreadTicker::WorkerThreadTicker(int tick_interval)
16 : timer_thread_("worker_thread_ticker"), 17 : timer_thread_("worker_thread_ticker"),
17 is_running_(false), 18 is_running_(false),
18 tick_interval_(base::TimeDelta::FromMilliseconds(tick_interval)) { 19 tick_interval_(base::TimeDelta::FromMilliseconds(tick_interval)) {
19 } 20 }
20 21
21 WorkerThreadTicker::~WorkerThreadTicker() { 22 WorkerThreadTicker::~WorkerThreadTicker() {
22 Stop(); 23 Stop();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // call Stop at the same time 70 // call Stop at the same time
70 base::AutoLock lock(lock_); 71 base::AutoLock lock(lock_);
71 if (!IsRunning()) 72 if (!IsRunning())
72 return false; 73 return false;
73 is_running_ = false; 74 is_running_ = false;
74 timer_thread_.Stop(); 75 timer_thread_.Stop();
75 return true; 76 return true;
76 } 77 }
77 78
78 void WorkerThreadTicker::ScheduleTimerTask() { 79 void WorkerThreadTicker::ScheduleTimerTask() {
79 timer_thread_.message_loop()->PostDelayedTask( 80 timer_thread_.task_runner()->PostDelayedTask(
80 FROM_HERE, 81 FROM_HERE,
81 base::Bind(&WorkerThreadTicker::TimerTask, base::Unretained(this)), 82 base::Bind(&WorkerThreadTicker::TimerTask, base::Unretained(this)),
82 tick_interval_); 83 tick_interval_);
83 } 84 }
84 85
85 void WorkerThreadTicker::TimerTask() { 86 void WorkerThreadTicker::TimerTask() {
86 // When the ticker is running, the handler list CANNOT be modified. 87 // When the ticker is running, the handler list CANNOT be modified.
87 // So we can do the enumeration safely without a lock 88 // So we can do the enumeration safely without a lock
88 const TickHandlerListType& handlers = tick_handler_list_; 89 const TickHandlerListType& handlers = tick_handler_list_;
89 for (TickHandlerListType::const_iterator i = handlers.begin(); 90 for (TickHandlerListType::const_iterator i = handlers.begin();
90 i != handlers.end(); ++i) { 91 i != handlers.end(); ++i) {
91 (*i)->OnTick(); 92 (*i)->OnTick();
92 } 93 }
93 94
94 ScheduleTimerTask(); 95 ScheduleTimerTask();
95 } 96 }
96 97
OLDNEW
« no previous file with comments | « chrome/common/service_process_util_win.cc ('k') | chrome/common/worker_thread_ticker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698