| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "base/message_loop.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 7 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
| 9 #include <gdk/gdkx.h> | 9 #include <gdk/gdkx.h> |
| 10 #endif | 10 #endif |
| 11 | 11 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 115 |
| 116 MessageLoop::DestructionObserver::~DestructionObserver() { | 116 MessageLoop::DestructionObserver::~DestructionObserver() { |
| 117 } | 117 } |
| 118 | 118 |
| 119 //------------------------------------------------------------------------------ | 119 //------------------------------------------------------------------------------ |
| 120 | 120 |
| 121 MessageLoop::MessageLoop(Type type) | 121 MessageLoop::MessageLoop(Type type) |
| 122 : type_(type), | 122 : type_(type), |
| 123 nestable_tasks_allowed_(true), | 123 nestable_tasks_allowed_(true), |
| 124 exception_restoration_(false), | 124 exception_restoration_(false), |
| 125 message_histogram_(NULL), |
| 125 state_(NULL), | 126 state_(NULL), |
| 126 #ifdef OS_WIN | 127 #ifdef OS_WIN |
| 127 os_modal_loop_(false), | 128 os_modal_loop_(false), |
| 128 #endif // OS_WIN | 129 #endif // OS_WIN |
| 129 next_sequence_num_(0) { | 130 next_sequence_num_(0) { |
| 130 DCHECK(!current()) << "should only have one message loop per thread"; | 131 DCHECK(!current()) << "should only have one message loop per thread"; |
| 131 lazy_tls_ptr.Pointer()->Set(this); | 132 lazy_tls_ptr.Pointer()->Set(this); |
| 132 | 133 |
| 133 // TODO(rvargas): Get rid of the OS guards. | 134 // TODO(rvargas): Get rid of the OS guards. |
| 134 #if defined(OS_WIN) | 135 #if defined(OS_WIN) |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 // ScheduleWork outside of incoming_queue_lock_. | 525 // ScheduleWork outside of incoming_queue_lock_. |
| 525 | 526 |
| 526 pump->ScheduleWork(); | 527 pump->ScheduleWork(); |
| 527 } | 528 } |
| 528 | 529 |
| 529 //------------------------------------------------------------------------------ | 530 //------------------------------------------------------------------------------ |
| 530 // Method and data for histogramming events and actions taken by each instance | 531 // Method and data for histogramming events and actions taken by each instance |
| 531 // on each thread. | 532 // on each thread. |
| 532 | 533 |
| 533 void MessageLoop::StartHistogrammer() { | 534 void MessageLoop::StartHistogrammer() { |
| 534 if (enable_histogrammer_ && !message_histogram_.get() | 535 if (enable_histogrammer_ && !message_histogram_ |
| 535 && base::StatisticsRecorder::IsActive()) { | 536 && base::StatisticsRecorder::IsActive()) { |
| 536 DCHECK(!thread_name_.empty()); | 537 DCHECK(!thread_name_.empty()); |
| 537 message_histogram_ = base::LinearHistogram::FactoryGet( | 538 message_histogram_ = base::LinearHistogram::FactoryGet( |
| 538 "MsgLoop:" + thread_name_, | 539 "MsgLoop:" + thread_name_, |
| 539 kLeastNonZeroMessageId, kMaxMessageId, | 540 kLeastNonZeroMessageId, kMaxMessageId, |
| 540 kNumberOfDistinctMessagesDisplayed, | 541 kNumberOfDistinctMessagesDisplayed, |
| 541 message_histogram_->kHexRangePrintingFlag); | 542 message_histogram_->kHexRangePrintingFlag); |
| 542 message_histogram_->SetRangeDescriptions(event_descriptions_); | 543 message_histogram_->SetRangeDescriptions(event_descriptions_); |
| 543 } | 544 } |
| 544 } | 545 } |
| 545 | 546 |
| 546 void MessageLoop::HistogramEvent(int event) { | 547 void MessageLoop::HistogramEvent(int event) { |
| 547 if (message_histogram_.get()) | 548 if (message_histogram_) |
| 548 message_histogram_->Add(event); | 549 message_histogram_->Add(event); |
| 549 } | 550 } |
| 550 | 551 |
| 551 bool MessageLoop::DoWork() { | 552 bool MessageLoop::DoWork() { |
| 552 if (!nestable_tasks_allowed_) { | 553 if (!nestable_tasks_allowed_) { |
| 553 // Task can't be executed right now. | 554 // Task can't be executed right now. |
| 554 return false; | 555 return false; |
| 555 } | 556 } |
| 556 | 557 |
| 557 for (;;) { | 558 for (;;) { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 Watcher *delegate) { | 717 Watcher *delegate) { |
| 717 return pump_libevent()->WatchFileDescriptor( | 718 return pump_libevent()->WatchFileDescriptor( |
| 718 fd, | 719 fd, |
| 719 persistent, | 720 persistent, |
| 720 static_cast<base::MessagePumpLibevent::Mode>(mode), | 721 static_cast<base::MessagePumpLibevent::Mode>(mode), |
| 721 controller, | 722 controller, |
| 722 delegate); | 723 delegate); |
| 723 } | 724 } |
| 724 | 725 |
| 725 #endif | 726 #endif |
| OLD | NEW |