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

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

Issue 2557083002: Run ScopedTaskScheduler tasks synchronously. (Closed)
Patch Set: git cl try 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
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->BelongsToCurrentThread()); 360 DCHECK(!task_runner || task_runner->BelongsToCurrentThread());
361 DCHECK(!unbound_task_runner_); 361 DCHECK(!unbound_task_runner_);
362 task_runner_ = std::move(task_runner); 362 task_runner_ = std::move(task_runner);
363 SetThreadTaskRunnerHandle(); 363 SetThreadTaskRunnerHandle();
364 } 364 }
365 365
366 void MessageLoop::SetThreadTaskRunnerHandle() { 366 void MessageLoop::SetThreadTaskRunnerHandle() {
367 DCHECK_EQ(this, current()); 367 DCHECK_EQ(this, current());
368 // Clear the previous thread task runner first, because only one can exist at 368 // Clear the previous thread task runner first, because only one can exist at
369 // a time. 369 // a time.
370 thread_task_runner_handle_.reset(); 370 thread_task_runner_handle_.reset();
371 thread_task_runner_handle_.reset(new ThreadTaskRunnerHandle(task_runner_)); 371 if (task_runner_)
robliao 2016/12/09 01:32:54 Should we DCHECK here? Seems unexpected to silentl
fdoray 2016/12/09 16:26:41 It is intentional to have no ThreadTaskRunnerHandl
372 thread_task_runner_handle_.reset(new ThreadTaskRunnerHandle(task_runner_));
372 } 373 }
373 374
374 void MessageLoop::RunHandler() { 375 void MessageLoop::RunHandler() {
375 DCHECK_EQ(this, current()); 376 DCHECK_EQ(this, current());
376 DCHECK(run_loop_); 377 DCHECK(run_loop_);
377 CHECK(allow_nesting_ || run_loop_->run_depth_ == 1); 378 CHECK(allow_nesting_ || run_loop_->run_depth_ == 1);
378 pump_->Run(this); 379 pump_->Run(this);
379 } 380 }
380 381
381 bool MessageLoop::ProcessNextDelayedNonNestableTask() { 382 bool MessageLoop::ProcessNextDelayedNonNestableTask() {
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 persistent, 655 persistent,
655 mode, 656 mode,
656 controller, 657 controller,
657 delegate); 658 delegate);
658 } 659 }
659 #endif 660 #endif
660 661
661 #endif // !defined(OS_NACL_SFI) 662 #endif // !defined(OS_NACL_SFI)
662 663
663 } // namespace base 664 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698