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

Side by Side Diff: base/message_loop_unittest.cc

Issue 12161002: MessageLoop's RUN method will pass a const ref to PendingTask when (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 | « base/message_loop.cc ('k') | chrome/browser/google_apis/test_util.cc » ('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 (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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/pending_task.h"
13 #include "base/posix/eintr_wrapper.h" 14 #include "base/posix/eintr_wrapper.h"
14 #include "base/run_loop.h" 15 #include "base/run_loop.h"
15 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
16 #include "base/threading/platform_thread.h" 17 #include "base/threading/platform_thread.h"
17 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 #if defined(OS_WIN) 21 #if defined(OS_WIN)
21 #include "base/message_pump_win.h" 22 #include "base/message_pump_win.h"
22 #include "base/win/scoped_handle.h" 23 #include "base/win/scoped_handle.h"
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 1794
1794 class DummyTaskObserver : public MessageLoop::TaskObserver { 1795 class DummyTaskObserver : public MessageLoop::TaskObserver {
1795 public: 1796 public:
1796 explicit DummyTaskObserver(int num_tasks) 1797 explicit DummyTaskObserver(int num_tasks)
1797 : num_tasks_started_(0), 1798 : num_tasks_started_(0),
1798 num_tasks_processed_(0), 1799 num_tasks_processed_(0),
1799 num_tasks_(num_tasks) {} 1800 num_tasks_(num_tasks) {}
1800 1801
1801 virtual ~DummyTaskObserver() {} 1802 virtual ~DummyTaskObserver() {}
1802 1803
1803 virtual void WillProcessTask(TimeTicks time_posted) OVERRIDE { 1804 virtual void WillProcessTask(const base::PendingTask& pending_task) OVERRIDE {
1804 num_tasks_started_++; 1805 num_tasks_started_++;
1805 EXPECT_TRUE(time_posted != TimeTicks()); 1806 EXPECT_TRUE(pending_task.time_posted != TimeTicks());
1806 EXPECT_LE(num_tasks_started_, num_tasks_); 1807 EXPECT_LE(num_tasks_started_, num_tasks_);
1807 EXPECT_EQ(num_tasks_started_, num_tasks_processed_ + 1); 1808 EXPECT_EQ(num_tasks_started_, num_tasks_processed_ + 1);
1808 } 1809 }
1809 1810
1810 virtual void DidProcessTask(TimeTicks time_posted) OVERRIDE { 1811 virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE {
1811 num_tasks_processed_++; 1812 num_tasks_processed_++;
1812 EXPECT_TRUE(time_posted != TimeTicks()); 1813 EXPECT_TRUE(pending_task.time_posted != TimeTicks());
1813 EXPECT_LE(num_tasks_started_, num_tasks_); 1814 EXPECT_LE(num_tasks_started_, num_tasks_);
1814 EXPECT_EQ(num_tasks_started_, num_tasks_processed_); 1815 EXPECT_EQ(num_tasks_started_, num_tasks_processed_);
1815 } 1816 }
1816 1817
1817 int num_tasks_started() const { return num_tasks_started_; } 1818 int num_tasks_started() const { return num_tasks_started_; }
1818 int num_tasks_processed() const { return num_tasks_processed_; } 1819 int num_tasks_processed() const { return num_tasks_processed_; }
1819 1820
1820 private: 1821 private:
1821 int num_tasks_started_; 1822 int num_tasks_started_;
1822 int num_tasks_processed_; 1823 int num_tasks_processed_;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 // exist in other MessagePumps. 2075 // exist in other MessagePumps.
2075 2076
2076 // On Linux, the pipe buffer size is 64KiB by default. The bug caused one 2077 // On Linux, the pipe buffer size is 64KiB by default. The bug caused one
2077 // byte accumulated in the pipe per two posts, so we should repeat 128K 2078 // byte accumulated in the pipe per two posts, so we should repeat 128K
2078 // times to reproduce the bug. 2079 // times to reproduce the bug.
2079 const int kNumTimes = 1 << 17; 2080 const int kNumTimes = 1 << 17;
2080 RunTest_RecursivePosts(MessageLoop::TYPE_DEFAULT, kNumTimes); 2081 RunTest_RecursivePosts(MessageLoop::TYPE_DEFAULT, kNumTimes);
2081 RunTest_RecursivePosts(MessageLoop::TYPE_UI, kNumTimes); 2082 RunTest_RecursivePosts(MessageLoop::TYPE_UI, kNumTimes);
2082 RunTest_RecursivePosts(MessageLoop::TYPE_IO, kNumTimes); 2083 RunTest_RecursivePosts(MessageLoop::TYPE_IO, kNumTimes);
2083 } 2084 }
OLDNEW
« no previous file with comments | « base/message_loop.cc ('k') | chrome/browser/google_apis/test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698