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

Side by Side Diff: net/dns/watching_file_reader_unittest.cc

Issue 8735014: base::Bind fixes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « net/dns/serial_worker_unittest.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/dns/watching_file_reader.h" 5 #include "net/dns/watching_file_reader.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/synchronization/lock.h" 8 #include "base/synchronization/lock.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 BreakNow("OnWatch"); 98 BreakNow("OnWatch");
99 return !fail_on_watch_; 99 return !fail_on_watch_;
100 } 100 }
101 101
102 void OnWork() { 102 void OnWork() {
103 EXPECT_TRUE(message_loop_ == MessageLoop::current()); 103 EXPECT_TRUE(message_loop_ == MessageLoop::current());
104 BreakNow("OnWork"); 104 BreakNow("OnWork");
105 } 105 }
106 106
107 protected: 107 protected:
108 friend class BreakTask; 108 void BreakCallback(std::string breakpoint) {
109 class BreakTask : public Task { 109 breakpoint_ = breakpoint;
110 public: 110 MessageLoop::current()->QuitNow();
111 BreakTask(WatchingFileReaderTest* test, std::string breakpoint) 111 }
112 : test_(test), breakpoint_(breakpoint) {}
113 virtual ~BreakTask() {}
114 virtual void Run() OVERRIDE {
115 test_->breakpoint_ = breakpoint_;
116 MessageLoop::current()->QuitNow();
117 }
118 private:
119 WatchingFileReaderTest* test_;
120 std::string breakpoint_;
121 };
122 112
123 void BreakNow(std::string b) { 113 void BreakNow(std::string b) {
124 message_loop_->PostTask(FROM_HERE, new BreakTask(this, b)); 114 message_loop_->PostTask(FROM_HERE,
115 new base::Bind(&WatchingFileReaderTest::BreakCallback, this, b));
mmenke 2011/11/30 02:29:05 I'm no expert on the new callback system, but it d
groby-ooo-7-16 2011/11/30 03:03:42 You are absolutely correct, thank you for catching
125 } 116 }
126 117
127 void RunUntilBreak(std::string b) { 118 void RunUntilBreak(std::string b) {
128 message_loop_->Run(); 119 message_loop_->Run();
129 ASSERT_EQ(breakpoint_, b); 120 ASSERT_EQ(breakpoint_, b);
130 } 121 }
131 122
132 WatchingFileReaderTest() 123 WatchingFileReaderTest()
133 : watcher_shim_(NULL), 124 : watcher_shim_(NULL),
134 fail_on_watch_(false), 125 fail_on_watch_(false),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 watcher_shim_->PathChanged(); 157 watcher_shim_->PathChanged();
167 RunUntilBreak("OnWork"); 158 RunUntilBreak("OnWork");
168 159
169 message_loop_->AssertIdle(); 160 message_loop_->AssertIdle();
170 } 161 }
171 162
172 } // namespace 163 } // namespace
173 164
174 } // namespace net 165 } // namespace net
175 166
OLDNEW
« no previous file with comments | « net/dns/serial_worker_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698