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

Side by Side Diff: base/message_loop/message_loop.cc

Issue 2557083002: Run ScopedTaskScheduler tasks synchronously. (Closed)
Patch Set: rebase Created 4 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
« no previous file with comments | « base/message_loop/message_loop.h ('k') | base/task_scheduler/task_scheduler.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 std::string MessageLoop::GetThreadName() const { 350 std::string MessageLoop::GetThreadName() const {
351 DCHECK_NE(kInvalidThreadId, thread_id_) 351 DCHECK_NE(kInvalidThreadId, thread_id_)
352 << "GetThreadName() must only be called after BindToCurrentThread()'s " 352 << "GetThreadName() must only be called after BindToCurrentThread()'s "
353 << "side-effects have been synchronized with this thread."; 353 << "side-effects have been synchronized with this thread.";
354 return ThreadIdNameManager::GetInstance()->GetName(thread_id_); 354 return ThreadIdNameManager::GetInstance()->GetName(thread_id_);
355 } 355 }
356 356
357 void MessageLoop::SetTaskRunner( 357 void MessageLoop::SetTaskRunner(
358 scoped_refptr<SingleThreadTaskRunner> task_runner) { 358 scoped_refptr<SingleThreadTaskRunner> task_runner) {
359 DCHECK_EQ(this, current()); 359 DCHECK_EQ(this, current());
360 DCHECK(task_runner);
360 DCHECK(task_runner->BelongsToCurrentThread()); 361 DCHECK(task_runner->BelongsToCurrentThread());
361 DCHECK(!unbound_task_runner_); 362 DCHECK(!unbound_task_runner_);
362 task_runner_ = std::move(task_runner); 363 task_runner_ = std::move(task_runner);
363 SetThreadTaskRunnerHandle(); 364 SetThreadTaskRunnerHandle();
364 } 365 }
365 366
367 void MessageLoop::ClearTaskRunnerForTesting() {
368 DCHECK_EQ(this, current());
369 DCHECK(!unbound_task_runner_);
370 task_runner_ = nullptr;
371 thread_task_runner_handle_.reset();
372 }
373
366 void MessageLoop::SetThreadTaskRunnerHandle() { 374 void MessageLoop::SetThreadTaskRunnerHandle() {
367 DCHECK_EQ(this, current()); 375 DCHECK_EQ(this, current());
368 // Clear the previous thread task runner first, because only one can exist at 376 // Clear the previous thread task runner first, because only one can exist at
369 // a time. 377 // a time.
370 thread_task_runner_handle_.reset(); 378 thread_task_runner_handle_.reset();
371 thread_task_runner_handle_.reset(new ThreadTaskRunnerHandle(task_runner_)); 379 thread_task_runner_handle_.reset(new ThreadTaskRunnerHandle(task_runner_));
372 } 380 }
373 381
374 void MessageLoop::RunHandler() { 382 void MessageLoop::RunHandler() {
375 DCHECK_EQ(this, current()); 383 DCHECK_EQ(this, current());
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 persistent, 662 persistent,
655 mode, 663 mode,
656 controller, 664 controller,
657 delegate); 665 delegate);
658 } 666 }
659 #endif 667 #endif
660 668
661 #endif // !defined(OS_NACL_SFI) 669 #endif // !defined(OS_NACL_SFI)
662 670
663 } // namespace base 671 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_loop.h ('k') | base/task_scheduler/task_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698