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

Side by Side Diff: base/threading/thread_unittest.cc

Issue 614103004: replace 'virtual ... OVERRIDE' with '... override' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: process base/ Created 6 years, 2 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 "base/threading/thread.h" 5 #include "base/threading/thread.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 17 matching lines...) Expand all
28 public: 28 public:
29 SleepInsideInitThread() : Thread("none") { 29 SleepInsideInitThread() : Thread("none") {
30 init_called_ = false; 30 init_called_ = false;
31 ANNOTATE_BENIGN_RACE( 31 ANNOTATE_BENIGN_RACE(
32 this, "Benign test-only data race on vptr - http://crbug.com/98219"); 32 this, "Benign test-only data race on vptr - http://crbug.com/98219");
33 } 33 }
34 virtual ~SleepInsideInitThread() { 34 virtual ~SleepInsideInitThread() {
35 Stop(); 35 Stop();
36 } 36 }
37 37
38 virtual void Init() OVERRIDE { 38 void Init() override {
39 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(500)); 39 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(500));
40 init_called_ = true; 40 init_called_ = true;
41 } 41 }
42 bool InitCalled() { return init_called_; } 42 bool InitCalled() { return init_called_; }
43 private: 43 private:
44 bool init_called_; 44 bool init_called_;
45 }; 45 };
46 46
47 enum ThreadEvent { 47 enum ThreadEvent {
48 // Thread::Init() was called. 48 // Thread::Init() was called.
(...skipping 18 matching lines...) Expand all
67 // lifetime of this thread. 67 // lifetime of this thread.
68 explicit CaptureToEventList(EventList* event_list) 68 explicit CaptureToEventList(EventList* event_list)
69 : Thread("none"), 69 : Thread("none"),
70 event_list_(event_list) { 70 event_list_(event_list) {
71 } 71 }
72 72
73 virtual ~CaptureToEventList() { 73 virtual ~CaptureToEventList() {
74 Stop(); 74 Stop();
75 } 75 }
76 76
77 virtual void Init() OVERRIDE { 77 void Init() override { event_list_->push_back(THREAD_EVENT_INIT); }
78 event_list_->push_back(THREAD_EVENT_INIT);
79 }
80 78
81 virtual void CleanUp() OVERRIDE { 79 void CleanUp() override { event_list_->push_back(THREAD_EVENT_CLEANUP); }
82 event_list_->push_back(THREAD_EVENT_CLEANUP);
83 }
84 80
85 private: 81 private:
86 EventList* event_list_; 82 EventList* event_list_;
87 }; 83 };
88 84
89 // Observer that writes a value into |event_list| when a message loop has been 85 // Observer that writes a value into |event_list| when a message loop has been
90 // destroyed. 86 // destroyed.
91 class CapturingDestructionObserver 87 class CapturingDestructionObserver
92 : public base::MessageLoop::DestructionObserver { 88 : public base::MessageLoop::DestructionObserver {
93 public: 89 public:
94 // |event_list| must remain valid throughout the observer's lifetime. 90 // |event_list| must remain valid throughout the observer's lifetime.
95 explicit CapturingDestructionObserver(EventList* event_list) 91 explicit CapturingDestructionObserver(EventList* event_list)
96 : event_list_(event_list) { 92 : event_list_(event_list) {
97 } 93 }
98 94
99 // DestructionObserver implementation: 95 // DestructionObserver implementation:
100 virtual void WillDestroyCurrentMessageLoop() OVERRIDE { 96 void WillDestroyCurrentMessageLoop() override {
101 event_list_->push_back(THREAD_EVENT_MESSAGE_LOOP_DESTROYED); 97 event_list_->push_back(THREAD_EVENT_MESSAGE_LOOP_DESTROYED);
102 event_list_ = NULL; 98 event_list_ = NULL;
103 } 99 }
104 100
105 private: 101 private:
106 EventList* event_list_; 102 EventList* event_list_;
107 }; 103 };
108 104
109 // Task that adds a destruction observer to the current message loop. 105 // Task that adds a destruction observer to the current message loop.
110 void RegisterDestructionObserver( 106 void RegisterDestructionObserver(
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 226
231 // Upon leaving this scope, the thread is deleted. 227 // Upon leaving this scope, the thread is deleted.
232 } 228 }
233 229
234 // Check the order of events during shutdown. 230 // Check the order of events during shutdown.
235 ASSERT_EQ(static_cast<size_t>(THREAD_NUM_EVENTS), captured_events.size()); 231 ASSERT_EQ(static_cast<size_t>(THREAD_NUM_EVENTS), captured_events.size());
236 EXPECT_EQ(THREAD_EVENT_INIT, captured_events[0]); 232 EXPECT_EQ(THREAD_EVENT_INIT, captured_events[0]);
237 EXPECT_EQ(THREAD_EVENT_CLEANUP, captured_events[1]); 233 EXPECT_EQ(THREAD_EVENT_CLEANUP, captured_events[1]);
238 EXPECT_EQ(THREAD_EVENT_MESSAGE_LOOP_DESTROYED, captured_events[2]); 234 EXPECT_EQ(THREAD_EVENT_MESSAGE_LOOP_DESTROYED, captured_events[2]);
239 } 235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698