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

Side by Side Diff: mojo/public/cpp/bindings/tests/bind_task_runner_unittest.cc

Issue 2637843002: Migrate base::TaskRunner from Closure to OnceClosure (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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <utility> 5 #include <utility>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 14 matching lines...) Expand all
25 25
26 class TestTaskRunner : public base::SingleThreadTaskRunner { 26 class TestTaskRunner : public base::SingleThreadTaskRunner {
27 public: 27 public:
28 TestTaskRunner() 28 TestTaskRunner()
29 : thread_id_(base::PlatformThread::CurrentRef()), 29 : thread_id_(base::PlatformThread::CurrentRef()),
30 quit_called_(false), 30 quit_called_(false),
31 task_ready_(base::WaitableEvent::ResetPolicy::AUTOMATIC, 31 task_ready_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
32 base::WaitableEvent::InitialState::NOT_SIGNALED) {} 32 base::WaitableEvent::InitialState::NOT_SIGNALED) {}
33 33
34 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 34 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
35 base::Closure task, 35 base::OnceClosure task,
36 base::TimeDelta delay) override { 36 base::TimeDelta delay) override {
37 NOTREACHED(); 37 NOTREACHED();
38 return false; 38 return false;
39 } 39 }
40 40
41 bool PostDelayedTask(const tracked_objects::Location& from_here, 41 bool PostDelayedTask(const tracked_objects::Location& from_here,
42 base::Closure task, 42 base::OnceClosure task,
43 base::TimeDelta delay) override { 43 base::TimeDelta delay) override {
44 { 44 {
45 base::AutoLock locker(lock_); 45 base::AutoLock locker(lock_);
46 tasks_.push(std::move(task)); 46 tasks_.push(std::move(task));
47 } 47 }
48 task_ready_.Signal(); 48 task_ready_.Signal();
49 return true; 49 return true;
50 } 50 }
51 bool RunsTasksOnCurrentThread() const override { 51 bool RunsTasksOnCurrentThread() const override {
52 return base::PlatformThread::CurrentRef() == thread_id_; 52 return base::PlatformThread::CurrentRef() == thread_id_;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 private: 106 private:
107 ~TestTaskRunner() override {} 107 ~TestTaskRunner() override {}
108 108
109 const base::PlatformThreadRef thread_id_; 109 const base::PlatformThreadRef thread_id_;
110 bool quit_called_; 110 bool quit_called_;
111 base::WaitableEvent task_ready_; 111 base::WaitableEvent task_ready_;
112 112
113 // Protect |tasks_|. 113 // Protect |tasks_|.
114 base::Lock lock_; 114 base::Lock lock_;
115 std::queue<base::Closure> tasks_; 115 std::queue<base::OnceClosure> tasks_;
116 116
117 DISALLOW_COPY_AND_ASSIGN(TestTaskRunner); 117 DISALLOW_COPY_AND_ASSIGN(TestTaskRunner);
118 }; 118 };
119 119
120 template <typename BindingType, typename RequestType> 120 template <typename BindingType, typename RequestType>
121 class IntegerSenderImpl : public IntegerSender { 121 class IntegerSenderImpl : public IntegerSender {
122 public: 122 public:
123 IntegerSenderImpl(RequestType request, 123 IntegerSenderImpl(RequestType request,
124 scoped_refptr<base::SingleThreadTaskRunner> runner) 124 scoped_refptr<base::SingleThreadTaskRunner> runner)
125 : binding_(this, std::move(request), std::move(runner)) {} 125 : binding_(this, std::move(request), std::move(runner)) {}
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 EXPECT_TRUE(sender_impl_error); 386 EXPECT_TRUE(sender_impl_error);
387 connection_ptr_task_runner_->Run(); 387 connection_ptr_task_runner_->Run();
388 EXPECT_TRUE(connection_ptr_error); 388 EXPECT_TRUE(connection_ptr_error);
389 sender_ptr_task_runner_->Run(); 389 sender_ptr_task_runner_->Run();
390 EXPECT_TRUE(sender_ptr_error); 390 EXPECT_TRUE(sender_ptr_error);
391 } 391 }
392 392
393 } // namespace 393 } // namespace
394 } // namespace test 394 } // namespace test
395 } // namespace mojo 395 } // namespace mojo
OLDNEW
« no previous file with comments | « media/cast/test/skewed_single_thread_task_runner.cc ('k') | net/quic/chromium/test_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698