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

Side by Side Diff: base/message_loop_unittest.cc

Issue 4081003: Added task to Observer methods (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made default birthplace a local static Created 10 years, 1 month 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') | base/tracked.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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/eintr_wrapper.h" 7 #include "base/eintr_wrapper.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/platform_thread.h" 10 #include "base/platform_thread.h"
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 1481
1482 class DummyTaskObserver : public MessageLoop::TaskObserver { 1482 class DummyTaskObserver : public MessageLoop::TaskObserver {
1483 public: 1483 public:
1484 explicit DummyTaskObserver(int num_tasks) 1484 explicit DummyTaskObserver(int num_tasks)
1485 : num_tasks_started_(0), 1485 : num_tasks_started_(0),
1486 num_tasks_processed_(0), 1486 num_tasks_processed_(0),
1487 num_tasks_(num_tasks) {} 1487 num_tasks_(num_tasks) {}
1488 1488
1489 virtual ~DummyTaskObserver() {} 1489 virtual ~DummyTaskObserver() {}
1490 1490
1491 virtual void WillProcessTask(base::TimeTicks /* birth_time */) { 1491 virtual void WillProcessTask(const Task* task) {
1492 num_tasks_started_++; 1492 num_tasks_started_++;
1493 EXPECT_NE(NULL, task);
1493 EXPECT_LE(num_tasks_started_, num_tasks_); 1494 EXPECT_LE(num_tasks_started_, num_tasks_);
1494 EXPECT_EQ(num_tasks_started_, num_tasks_processed_ + 1); 1495 EXPECT_EQ(num_tasks_started_, num_tasks_processed_ + 1);
1495 } 1496 }
1496 1497
1497 virtual void DidProcessTask() { 1498 virtual void DidProcessTask(const Task* task) {
1498 num_tasks_processed_++; 1499 num_tasks_processed_++;
1500 EXPECT_NE(NULL, task);
1499 EXPECT_LE(num_tasks_started_, num_tasks_); 1501 EXPECT_LE(num_tasks_started_, num_tasks_);
1500 EXPECT_EQ(num_tasks_started_, num_tasks_processed_); 1502 EXPECT_EQ(num_tasks_started_, num_tasks_processed_);
1501 } 1503 }
1502 1504
1503 int num_tasks_started() const { return num_tasks_started_; } 1505 int num_tasks_started() const { return num_tasks_started_; }
1504 int num_tasks_processed() const { return num_tasks_processed_; } 1506 int num_tasks_processed() const { return num_tasks_processed_; }
1505 1507
1506 private: 1508 private:
1507 int num_tasks_started_; 1509 int num_tasks_started_;
1508 int num_tasks_processed_; 1510 int num_tasks_processed_;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 } 1640 }
1639 if (HANDLE_EINTR(close(pipefds[0])) < 0) 1641 if (HANDLE_EINTR(close(pipefds[0])) < 0)
1640 PLOG(ERROR) << "close"; 1642 PLOG(ERROR) << "close";
1641 if (HANDLE_EINTR(close(pipefds[1])) < 0) 1643 if (HANDLE_EINTR(close(pipefds[1])) < 0)
1642 PLOG(ERROR) << "close"; 1644 PLOG(ERROR) << "close";
1643 } 1645 }
1644 1646
1645 } // namespace 1647 } // namespace
1646 1648
1647 #endif // defined(OS_POSIX) 1649 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « base/message_loop.cc ('k') | base/tracked.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698