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

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

Issue 8873032: Removing MessageLoop::QuitTask() from chrome/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert 3 more problematic files Created 9 years 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/threading/platform_thread.h" 8 #include "base/threading/platform_thread.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace { 11 namespace {
12 12
13 class TestCallback : public WorkerThreadTicker::Callback { 13 class TestCallback : public WorkerThreadTicker::Callback {
14 public: 14 public:
15 TestCallback() : counter_(0), message_loop_(MessageLoop::current()) { 15 TestCallback() : counter_(0), message_loop_(MessageLoop::current()) {
16 } 16 }
17 17
18 virtual void OnTick() { 18 virtual void OnTick() {
19 counter_++; 19 counter_++;
20 20
21 // Finish the test faster. 21 // Finish the test faster.
22 message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 22 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
23 } 23 }
24 24
25 int counter() const { return counter_; } 25 int counter() const { return counter_; }
26 26
27 private: 27 private:
28 int counter_; 28 int counter_;
29 MessageLoop* message_loop_; 29 MessageLoop* message_loop_;
30 }; 30 };
31 31
32 class LongCallback : public WorkerThreadTicker::Callback { 32 class LongCallback : public WorkerThreadTicker::Callback {
33 public: 33 public:
34 virtual void OnTick() { 34 virtual void OnTick() {
35 base::PlatformThread::Sleep(1500); 35 base::PlatformThread::Sleep(1500);
36 } 36 }
37 }; 37 };
38 38
39 void RunMessageLoopForAWhile() { 39 void RunMessageLoopForAWhile() {
40 MessageLoop::current()->PostDelayedTask(FROM_HERE, 40 MessageLoop::current()->PostDelayedTask(FROM_HERE,
41 new MessageLoop::QuitTask(), 500); 41 MessageLoop::QuitClosure(), 500);
42 MessageLoop::current()->Run(); 42 MessageLoop::current()->Run();
43 } 43 }
44 44
45 } // namespace 45 } // namespace
46 46
47 TEST(WorkerThreadTickerTest, Basic) { 47 TEST(WorkerThreadTickerTest, Basic) {
48 MessageLoop loop; 48 MessageLoop loop;
49 49
50 TestCallback callback; 50 TestCallback callback;
51 WorkerThreadTicker ticker(50); 51 WorkerThreadTicker ticker(50);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 TEST(WorkerThreadTickerTest, LongCallback) { 99 TEST(WorkerThreadTickerTest, LongCallback) {
100 MessageLoop loop; 100 MessageLoop loop;
101 101
102 LongCallback callback; 102 LongCallback callback;
103 WorkerThreadTicker ticker(50); 103 WorkerThreadTicker ticker(50);
104 ASSERT_TRUE(ticker.RegisterTickHandler(&callback)); 104 ASSERT_TRUE(ticker.RegisterTickHandler(&callback));
105 105
106 ASSERT_TRUE(ticker.Start()); 106 ASSERT_TRUE(ticker.Start());
107 RunMessageLoopForAWhile(); 107 RunMessageLoopForAWhile();
108 } 108 }
OLDNEW
« no previous file with comments | « chrome/common/service_process_util_unittest.cc ('k') | chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698