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

Side by Side Diff: base/message_loop_unittest.cc

Issue 10004001: Add virtual and OVERRIDE to base/ implementation files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win Fix -> Missing header Created 8 years, 8 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_proxy_unittest.cc ('k') | base/message_pump_libevent_unittest.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/eintr_wrapper.h" 10 #include "base/eintr_wrapper.h"
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 } 1539 }
1540 1540
1541 #endif // defined(OS_WIN) 1541 #endif // defined(OS_WIN)
1542 1542
1543 #if defined(OS_POSIX) && !defined(OS_NACL) 1543 #if defined(OS_POSIX) && !defined(OS_NACL)
1544 1544
1545 namespace { 1545 namespace {
1546 1546
1547 class QuitDelegate : public MessageLoopForIO::Watcher { 1547 class QuitDelegate : public MessageLoopForIO::Watcher {
1548 public: 1548 public:
1549 virtual void OnFileCanWriteWithoutBlocking(int fd) { 1549 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE {
1550 MessageLoop::current()->Quit(); 1550 MessageLoop::current()->Quit();
1551 } 1551 }
1552 virtual void OnFileCanReadWithoutBlocking(int fd) { 1552 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE {
1553 MessageLoop::current()->Quit(); 1553 MessageLoop::current()->Quit();
1554 } 1554 }
1555 }; 1555 };
1556 1556
1557 TEST(MessageLoopTest, FileDescriptorWatcherOutlivesMessageLoop) { 1557 TEST(MessageLoopTest, FileDescriptorWatcherOutlivesMessageLoop) {
1558 // Simulate a MessageLoop that dies before an FileDescriptorWatcher. 1558 // Simulate a MessageLoop that dies before an FileDescriptorWatcher.
1559 // This could happen when people use the Singleton pattern or atexit. 1559 // This could happen when people use the Singleton pattern or atexit.
1560 1560
1561 // Create a file descriptor. Doesn't need to be readable or writable, 1561 // Create a file descriptor. Doesn't need to be readable or writable,
1562 // as we don't need to actually get any notifications. 1562 // as we don't need to actually get any notifications.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 bool* destruction_observer_called_; 1637 bool* destruction_observer_called_;
1638 }; 1638 };
1639 1639
1640 class MLDestructionObserver : public MessageLoop::DestructionObserver { 1640 class MLDestructionObserver : public MessageLoop::DestructionObserver {
1641 public: 1641 public:
1642 MLDestructionObserver(bool* task_destroyed, bool* destruction_observer_called) 1642 MLDestructionObserver(bool* task_destroyed, bool* destruction_observer_called)
1643 : task_destroyed_(task_destroyed), 1643 : task_destroyed_(task_destroyed),
1644 destruction_observer_called_(destruction_observer_called), 1644 destruction_observer_called_(destruction_observer_called),
1645 task_destroyed_before_message_loop_(false) { 1645 task_destroyed_before_message_loop_(false) {
1646 } 1646 }
1647 virtual void WillDestroyCurrentMessageLoop() { 1647 virtual void WillDestroyCurrentMessageLoop() OVERRIDE {
1648 task_destroyed_before_message_loop_ = *task_destroyed_; 1648 task_destroyed_before_message_loop_ = *task_destroyed_;
1649 *destruction_observer_called_ = true; 1649 *destruction_observer_called_ = true;
1650 } 1650 }
1651 bool task_destroyed_before_message_loop() const { 1651 bool task_destroyed_before_message_loop() const {
1652 return task_destroyed_before_message_loop_; 1652 return task_destroyed_before_message_loop_;
1653 } 1653 }
1654 private: 1654 private:
1655 bool* task_destroyed_; 1655 bool* task_destroyed_;
1656 bool* destruction_observer_called_; 1656 bool* destruction_observer_called_;
1657 bool task_destroyed_before_message_loop_; 1657 bool task_destroyed_before_message_loop_;
(...skipping 17 matching lines...) Expand all
1675 base::Bind(&DestructionObserverProbe::Run, 1675 base::Bind(&DestructionObserverProbe::Run,
1676 new DestructionObserverProbe(&task_destroyed, 1676 new DestructionObserverProbe(&task_destroyed,
1677 &destruction_observer_called)), 1677 &destruction_observer_called)),
1678 kDelay); 1678 kDelay);
1679 delete loop; 1679 delete loop;
1680 EXPECT_TRUE(observer.task_destroyed_before_message_loop()); 1680 EXPECT_TRUE(observer.task_destroyed_before_message_loop());
1681 // The task should have been destroyed when we deleted the loop. 1681 // The task should have been destroyed when we deleted the loop.
1682 EXPECT_TRUE(task_destroyed); 1682 EXPECT_TRUE(task_destroyed);
1683 EXPECT_TRUE(destruction_observer_called); 1683 EXPECT_TRUE(destruction_observer_called);
1684 } 1684 }
OLDNEW
« no previous file with comments | « base/message_loop_proxy_unittest.cc ('k') | base/message_pump_libevent_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698