Index: base/files/file_path_watcher_unittest.cc |
diff --git a/base/files/file_path_watcher_unittest.cc b/base/files/file_path_watcher_unittest.cc |
index 21e9dd137e2dc5cf080112595d74200c90d80002..0e1c467222c957807a63e2c47aa04455eb3b3b7c 100644 |
--- a/base/files/file_path_watcher_unittest.cc |
+++ b/base/files/file_path_watcher_unittest.cc |
@@ -20,15 +20,14 @@ |
#include "base/files/file_path.h" |
#include "base/files/file_util.h" |
#include "base/files/scoped_temp_dir.h" |
-#include "base/location.h" |
+#include "base/message_loop/message_loop.h" |
+#include "base/message_loop/message_loop_proxy.h" |
#include "base/run_loop.h" |
-#include "base/single_thread_task_runner.h" |
#include "base/stl_util.h" |
#include "base/strings/stringprintf.h" |
#include "base/synchronization/waitable_event.h" |
#include "base/test/test_file_util.h" |
#include "base/test/test_timeouts.h" |
-#include "base/thread_task_runner_handle.h" |
#include "base/threading/thread.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -47,13 +46,14 @@ |
class NotificationCollector |
: public base::RefCountedThreadSafe<NotificationCollector> { |
public: |
- NotificationCollector() : task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
+ NotificationCollector() |
+ : loop_(base::MessageLoopProxy::current()) {} |
// Called from the file thread by the delegates. |
void OnChange(TestDelegate* delegate) { |
- task_runner_->PostTask( |
- FROM_HERE, base::Bind(&NotificationCollector::RecordChange, this, |
- base::Unretained(delegate))); |
+ loop_->PostTask(FROM_HERE, |
+ base::Bind(&NotificationCollector::RecordChange, this, |
+ base::Unretained(delegate))); |
} |
void Register(TestDelegate* delegate) { |
@@ -74,13 +74,13 @@ |
void RecordChange(TestDelegate* delegate) { |
// Warning: |delegate| is Unretained. Do not dereference. |
- ASSERT_TRUE(task_runner_->BelongsToCurrentThread()); |
+ ASSERT_TRUE(loop_->BelongsToCurrentThread()); |
ASSERT_TRUE(delegates_.count(delegate)); |
signaled_.insert(delegate); |
// Check whether all delegates have been signaled. |
if (signaled_ == delegates_) |
- task_runner_->PostTask(FROM_HERE, MessageLoop::QuitWhenIdleClosure()); |
+ loop_->PostTask(FROM_HERE, MessageLoop::QuitWhenIdleClosure()); |
} |
// Set of registered delegates. |
@@ -90,7 +90,7 @@ |
std::set<TestDelegate*> signaled_; |
// The loop we should break after all delegates signaled. |
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
+ scoped_refptr<base::MessageLoopProxy> loop_; |
}; |
class TestDelegateBase : public SupportsWeakPtr<TestDelegateBase> { |
@@ -171,7 +171,7 @@ |
void TearDown() override { RunLoop().RunUntilIdle(); } |
void DeleteDelegateOnFileThread(TestDelegate* delegate) { |
- file_thread_.task_runner()->DeleteSoon(FROM_HERE, delegate); |
+ file_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, delegate); |
} |
FilePath test_file() { |
@@ -216,9 +216,10 @@ |
bool recursive_watch) { |
base::WaitableEvent completion(false, false); |
bool result; |
- file_thread_.task_runner()->PostTask( |
- FROM_HERE, base::Bind(SetupWatchCallback, target, watcher, delegate, |
- recursive_watch, &result, &completion)); |
+ file_thread_.message_loop_proxy()->PostTask( |
+ FROM_HERE, |
+ base::Bind(SetupWatchCallback, target, watcher, delegate, recursive_watch, |
+ &result, &completion)); |
completion.Wait(); |
return result; |
} |
@@ -288,8 +289,7 @@ |
void OnFileChanged(const FilePath&, bool) override { |
watcher_.reset(); |
- loop_->task_runner()->PostTask(FROM_HERE, |
- MessageLoop::QuitWhenIdleClosure()); |
+ loop_->PostTask(FROM_HERE, MessageLoop::QuitWhenIdleClosure()); |
} |
FilePathWatcher* watcher() const { return watcher_.get(); } |
@@ -324,7 +324,7 @@ |
FilePathWatcher* watcher = new FilePathWatcher; |
ASSERT_TRUE(SetupWatch(test_file(), watcher, delegate.get(), false)); |
ASSERT_TRUE(WriteFile(test_file(), "content")); |
- file_thread_.task_runner()->DeleteSoon(FROM_HERE, watcher); |
+ file_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, watcher); |
DeleteDelegateOnFileThread(delegate.release()); |
} |