OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 // ScheduleWork outside of incoming_queue_lock_. | 613 // ScheduleWork outside of incoming_queue_lock_. |
614 | 614 |
615 pump->ScheduleWork(); | 615 pump->ScheduleWork(); |
616 } | 616 } |
617 | 617 |
618 //------------------------------------------------------------------------------ | 618 //------------------------------------------------------------------------------ |
619 // Method and data for histogramming events and actions taken by each instance | 619 // Method and data for histogramming events and actions taken by each instance |
620 // on each thread. | 620 // on each thread. |
621 | 621 |
622 void MessageLoop::StartHistogrammer() { | 622 void MessageLoop::StartHistogrammer() { |
| 623 #if !defined(OS_NACL) // NaCl build has no metrics code. |
623 if (enable_histogrammer_ && !message_histogram_ | 624 if (enable_histogrammer_ && !message_histogram_ |
624 && base::StatisticsRecorder::IsActive()) { | 625 && base::StatisticsRecorder::IsActive()) { |
625 DCHECK(!thread_name_.empty()); | 626 DCHECK(!thread_name_.empty()); |
626 message_histogram_ = base::LinearHistogram::FactoryGet( | 627 message_histogram_ = base::LinearHistogram::FactoryGet( |
627 "MsgLoop:" + thread_name_, | 628 "MsgLoop:" + thread_name_, |
628 kLeastNonZeroMessageId, kMaxMessageId, | 629 kLeastNonZeroMessageId, kMaxMessageId, |
629 kNumberOfDistinctMessagesDisplayed, | 630 kNumberOfDistinctMessagesDisplayed, |
630 message_histogram_->kHexRangePrintingFlag); | 631 message_histogram_->kHexRangePrintingFlag); |
631 message_histogram_->SetRangeDescriptions(event_descriptions_); | 632 message_histogram_->SetRangeDescriptions(event_descriptions_); |
632 } | 633 } |
| 634 #endif |
633 } | 635 } |
634 | 636 |
635 void MessageLoop::HistogramEvent(int event) { | 637 void MessageLoop::HistogramEvent(int event) { |
| 638 #if !defined(OS_NACL) |
636 if (message_histogram_) | 639 if (message_histogram_) |
637 message_histogram_->Add(event); | 640 message_histogram_->Add(event); |
| 641 #endif |
638 } | 642 } |
639 | 643 |
640 bool MessageLoop::DoWork() { | 644 bool MessageLoop::DoWork() { |
641 if (!nestable_tasks_allowed_) { | 645 if (!nestable_tasks_allowed_) { |
642 // Task can't be executed right now. | 646 // Task can't be executed right now. |
643 return false; | 647 return false; |
644 } | 648 } |
645 | 649 |
646 for (;;) { | 650 for (;;) { |
647 ReloadWorkQueue(); | 651 ReloadWorkQueue(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 Watcher *delegate) { | 785 Watcher *delegate) { |
782 return pump_libevent()->WatchFileDescriptor( | 786 return pump_libevent()->WatchFileDescriptor( |
783 fd, | 787 fd, |
784 persistent, | 788 persistent, |
785 static_cast<base::MessagePumpLibevent::Mode>(mode), | 789 static_cast<base::MessagePumpLibevent::Mode>(mode), |
786 controller, | 790 controller, |
787 delegate); | 791 delegate); |
788 } | 792 } |
789 | 793 |
790 #endif | 794 #endif |
OLD | NEW |