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

Side by Side Diff: base/files/important_file_writer_unittest.cc

Issue 2791243002: Rewrite base::Bind into base::BindOnce on trivial cases in base (Closed)
Patch Set: rebase Created 3 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
« no previous file with comments | « base/files/file_util_proxy.cc ('k') | base/memory/weak_ptr_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 "base/files/important_file_writer.h" 5 #include "base/files/important_file_writer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 file_writer_thread.Start(); 194 file_writer_thread.Start();
195 ImportantFileWriter writer(file_, file_writer_thread.task_runner()); 195 ImportantFileWriter writer(file_, file_writer_thread.task_runner());
196 EXPECT_EQ(NOT_CALLED, write_callback_observer_.GetAndResetObservationState()); 196 EXPECT_EQ(NOT_CALLED, write_callback_observer_.GetAndResetObservationState());
197 197
198 // Block execution on |file_writer_thread| to verify that callbacks are 198 // Block execution on |file_writer_thread| to verify that callbacks are
199 // executed on it. 199 // executed on it.
200 base::WaitableEvent wait_helper( 200 base::WaitableEvent wait_helper(
201 base::WaitableEvent::ResetPolicy::MANUAL, 201 base::WaitableEvent::ResetPolicy::MANUAL,
202 base::WaitableEvent::InitialState::NOT_SIGNALED); 202 base::WaitableEvent::InitialState::NOT_SIGNALED);
203 file_writer_thread.task_runner()->PostTask( 203 file_writer_thread.task_runner()->PostTask(
204 FROM_HERE, 204 FROM_HERE, base::BindOnce(&base::WaitableEvent::Wait,
205 base::Bind(&base::WaitableEvent::Wait, base::Unretained(&wait_helper))); 205 base::Unretained(&wait_helper)));
206 206
207 write_callback_observer_.ObserveNextWriteCallbacks(&writer); 207 write_callback_observer_.ObserveNextWriteCallbacks(&writer);
208 writer.WriteNow(MakeUnique<std::string>("foo")); 208 writer.WriteNow(MakeUnique<std::string>("foo"));
209 RunLoop().RunUntilIdle(); 209 RunLoop().RunUntilIdle();
210 210
211 // Expect the callback to not have been executed before the 211 // Expect the callback to not have been executed before the
212 // |file_writer_thread| is unblocked. 212 // |file_writer_thread| is unblocked.
213 EXPECT_EQ(NOT_CALLED, write_callback_observer_.GetAndResetObservationState()); 213 EXPECT_EQ(NOT_CALLED, write_callback_observer_.GetAndResetObservationState());
214 214
215 wait_helper.Signal(); 215 wait_helper.Signal();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 writer.ScheduleWrite(&baz); 264 writer.ScheduleWrite(&baz);
265 ThreadTaskRunnerHandle::Get()->PostDelayedTask( 265 ThreadTaskRunnerHandle::Get()->PostDelayedTask(
266 FROM_HERE, MessageLoop::QuitWhenIdleClosure(), 266 FROM_HERE, MessageLoop::QuitWhenIdleClosure(),
267 TimeDelta::FromMilliseconds(100)); 267 TimeDelta::FromMilliseconds(100));
268 RunLoop().Run(); 268 RunLoop().Run();
269 ASSERT_TRUE(PathExists(writer.path())); 269 ASSERT_TRUE(PathExists(writer.path()));
270 EXPECT_EQ("baz", GetFileContent(writer.path())); 270 EXPECT_EQ("baz", GetFileContent(writer.path()));
271 } 271 }
272 272
273 } // namespace base 273 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_util_proxy.cc ('k') | base/memory/weak_ptr_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698