Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 if (!pump_factory_.is_null()) | 400 if (!pump_factory_.is_null()) |
| 401 pump_ = pump_factory_.Run(); | 401 pump_ = pump_factory_.Run(); |
| 402 else | 402 else |
| 403 pump_ = CreateMessagePumpForType(type_); | 403 pump_ = CreateMessagePumpForType(type_); |
| 404 | 404 |
| 405 DCHECK(!current()) << "should only have one message loop per thread"; | 405 DCHECK(!current()) << "should only have one message loop per thread"; |
| 406 lazy_tls_ptr.Pointer()->Set(this); | 406 lazy_tls_ptr.Pointer()->Set(this); |
| 407 | 407 |
| 408 incoming_task_queue_->StartScheduling(); | 408 incoming_task_queue_->StartScheduling(); |
| 409 unbound_task_runner_->BindToCurrentThread(); | 409 unbound_task_runner_->BindToCurrentThread(); |
| 410 SetTaskRunner(unbound_task_runner_.Pass()); | 410 unbound_task_runner_ = nullptr; |
|
danakj
2015/07/10 18:32:38
I'm feeling like this unbound_task_runner_ is prov
Sami
2015/07/13 10:43:31
Yes, it's not all that useful but I can't think of
danakj
2015/07/13 18:33:47
Ah, I see. LGTM then.
| |
| 411 SetThreadTaskRunnerHandle(); | |
| 411 } | 412 } |
| 412 | 413 |
| 413 void MessageLoop::SetTaskRunner( | 414 void MessageLoop::SetTaskRunner( |
| 414 scoped_refptr<SingleThreadTaskRunner> task_runner) { | 415 scoped_refptr<SingleThreadTaskRunner> task_runner) { |
| 415 DCHECK_EQ(this, current()); | 416 DCHECK_EQ(this, current()); |
| 416 DCHECK(task_runner->BelongsToCurrentThread()); | 417 DCHECK(task_runner->BelongsToCurrentThread()); |
| 417 DCHECK(!unbound_task_runner_); | 418 DCHECK(!unbound_task_runner_); |
| 418 task_runner_ = task_runner.Pass(); | 419 task_runner_ = task_runner.Pass(); |
| 420 SetThreadTaskRunnerHandle(); | |
| 421 } | |
| 422 | |
| 423 void MessageLoop::SetThreadTaskRunnerHandle() { | |
| 424 DCHECK_EQ(this, current()); | |
| 419 // Clear the previous thread task runner first because only one can exist at | 425 // Clear the previous thread task runner first because only one can exist at |
| 420 // a time. | 426 // a time. |
| 421 thread_task_runner_handle_.reset(); | 427 thread_task_runner_handle_.reset(); |
| 422 thread_task_runner_handle_.reset(new ThreadTaskRunnerHandle(task_runner_)); | 428 thread_task_runner_handle_.reset(new ThreadTaskRunnerHandle(task_runner_)); |
| 423 } | 429 } |
| 424 | 430 |
| 425 void MessageLoop::RunHandler() { | 431 void MessageLoop::RunHandler() { |
| 426 DCHECK_EQ(this, current()); | 432 DCHECK_EQ(this, current()); |
| 427 | 433 |
| 428 StartHistogrammer(); | 434 StartHistogrammer(); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 739 persistent, | 745 persistent, |
| 740 mode, | 746 mode, |
| 741 controller, | 747 controller, |
| 742 delegate); | 748 delegate); |
| 743 } | 749 } |
| 744 #endif | 750 #endif |
| 745 | 751 |
| 746 #endif // !defined(OS_NACL_SFI) | 752 #endif // !defined(OS_NACL_SFI) |
| 747 | 753 |
| 748 } // namespace base | 754 } // namespace base |
| OLD | NEW |