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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 os_modal_loop_(false), | 391 os_modal_loop_(false), |
392 #endif // OS_WIN | 392 #endif // OS_WIN |
393 pump_factory_(pump_factory), | 393 pump_factory_(pump_factory), |
394 message_histogram_(NULL), | 394 message_histogram_(NULL), |
395 run_loop_(NULL), | 395 run_loop_(NULL), |
396 incoming_task_queue_(new internal::IncomingTaskQueue(this)), | 396 incoming_task_queue_(new internal::IncomingTaskQueue(this)), |
397 unbound_task_runner_( | 397 unbound_task_runner_( |
398 new internal::MessageLoopTaskRunner(incoming_task_queue_)), | 398 new internal::MessageLoopTaskRunner(incoming_task_queue_)), |
399 task_runner_(unbound_task_runner_) { | 399 task_runner_(unbound_task_runner_) { |
400 // If type is TYPE_CUSTOM non-null pump_factory must be given. | 400 // If type is TYPE_CUSTOM non-null pump_factory must be given. |
401 DCHECK_EQ(type_ == TYPE_CUSTOM, !pump_factory_.is_null()); | 401 DCHECK(type_ != TYPE_CUSTOM || !pump_factory_.is_null()); |
402 } | 402 } |
403 | 403 |
404 void MessageLoop::BindToCurrentThread() { | 404 void MessageLoop::BindToCurrentThread() { |
405 DCHECK(!pump_); | 405 DCHECK(!pump_); |
406 if (!pump_factory_.is_null()) | 406 if (!pump_factory_.is_null()) |
407 pump_ = pump_factory_.Run(); | 407 pump_ = pump_factory_.Run(); |
408 else | 408 else |
409 pump_ = CreateMessagePumpForType(type_); | 409 pump_ = CreateMessagePumpForType(type_); |
410 | 410 |
411 DCHECK(!current()) << "should only have one message loop per thread"; | 411 DCHECK(!current()) << "should only have one message loop per thread"; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 const tracked_objects::Location& from_here, | 677 const tracked_objects::Location& from_here, |
678 void(*releaser)(const void*), | 678 void(*releaser)(const void*), |
679 const void* object) { | 679 const void* object) { |
680 PostNonNestableTask(from_here, Bind(releaser, object)); | 680 PostNonNestableTask(from_here, Bind(releaser, object)); |
681 } | 681 } |
682 | 682 |
683 #if !defined(OS_NACL) | 683 #if !defined(OS_NACL) |
684 //------------------------------------------------------------------------------ | 684 //------------------------------------------------------------------------------ |
685 // MessageLoopForUI | 685 // MessageLoopForUI |
686 | 686 |
| 687 MessageLoopForUI::MessageLoopForUI(scoped_ptr<MessagePump> pump) |
| 688 : MessageLoop(TYPE_UI, Bind(&ReturnPump, Passed(&pump))) { |
| 689 } |
| 690 |
687 #if defined(OS_ANDROID) | 691 #if defined(OS_ANDROID) |
688 void MessageLoopForUI::Start() { | 692 void MessageLoopForUI::Start() { |
689 // No Histogram support for UI message loop as it is managed by Java side | 693 // No Histogram support for UI message loop as it is managed by Java side |
690 static_cast<MessagePumpForUI*>(pump_.get())->Start(this); | 694 static_cast<MessagePumpForUI*>(pump_.get())->Start(this); |
691 } | 695 } |
692 #endif | 696 #endif |
693 | 697 |
694 #if defined(OS_IOS) | 698 #if defined(OS_IOS) |
695 void MessageLoopForUI::Attach() { | 699 void MessageLoopForUI::Attach() { |
696 static_cast<MessagePumpUIApplication*>(pump_.get())->Attach(this); | 700 static_cast<MessagePumpUIApplication*>(pump_.get())->Attach(this); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 persistent, | 756 persistent, |
753 mode, | 757 mode, |
754 controller, | 758 controller, |
755 delegate); | 759 delegate); |
756 } | 760 } |
757 #endif | 761 #endif |
758 | 762 |
759 #endif // !defined(OS_NACL_SFI) | 763 #endif // !defined(OS_NACL_SFI) |
760 | 764 |
761 } // namespace base | 765 } // namespace base |
OLD | NEW |