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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 namespace { | 43 namespace { |
44 | 44 |
45 // A lazily created thread local storage for quick access to a thread's message | 45 // A lazily created thread local storage for quick access to a thread's message |
46 // loop, if one exists. This should be safe and free of static constructors. | 46 // loop, if one exists. This should be safe and free of static constructors. |
47 LazyInstance<base::ThreadLocalPointer<MessageLoop> >::Leaky lazy_tls_ptr = | 47 LazyInstance<base::ThreadLocalPointer<MessageLoop> >::Leaky lazy_tls_ptr = |
48 LAZY_INSTANCE_INITIALIZER; | 48 LAZY_INSTANCE_INITIALIZER; |
49 | 49 |
50 // Logical events for Histogram profiling. Run with -message-loop-histogrammer | 50 // Logical events for Histogram profiling. Run with -message-loop-histogrammer |
51 // to get an accounting of messages and actions taken on each thread. | 51 // to get an accounting of messages and actions taken on each thread. |
52 const int kTaskRunEvent = 0x1; | 52 const int kTaskRunEvent = 0x1; |
| 53 #if !defined(OS_NACL) |
53 const int kTimerEvent = 0x2; | 54 const int kTimerEvent = 0x2; |
54 | 55 |
55 // Provide range of message IDs for use in histogramming and debug display. | 56 // Provide range of message IDs for use in histogramming and debug display. |
56 const int kLeastNonZeroMessageId = 1; | 57 const int kLeastNonZeroMessageId = 1; |
57 const int kMaxMessageId = 1099; | 58 const int kMaxMessageId = 1099; |
58 const int kNumberOfDistinctMessagesDisplayed = 1100; | 59 const int kNumberOfDistinctMessagesDisplayed = 1100; |
59 | 60 |
60 // Provide a macro that takes an expression (such as a constant, or macro | 61 // Provide a macro that takes an expression (such as a constant, or macro |
61 // constant) and creates a pair to initalize an array of pairs. In this case, | 62 // constant) and creates a pair to initalize an array of pairs. In this case, |
62 // our pair consists of the expressions value, and the "stringized" version | 63 // our pair consists of the expressions value, and the "stringized" version |
(...skipping 13 matching lines...) Expand all Loading... |
76 const LinearHistogram::DescriptionPair event_descriptions_[] = { | 77 const LinearHistogram::DescriptionPair event_descriptions_[] = { |
77 // Provide some pretty print capability in our histogram for our internal | 78 // Provide some pretty print capability in our histogram for our internal |
78 // messages. | 79 // messages. |
79 | 80 |
80 // A few events we handle (kindred to messages), and used to profile actions. | 81 // A few events we handle (kindred to messages), and used to profile actions. |
81 VALUE_TO_NUMBER_AND_NAME(kTaskRunEvent) | 82 VALUE_TO_NUMBER_AND_NAME(kTaskRunEvent) |
82 VALUE_TO_NUMBER_AND_NAME(kTimerEvent) | 83 VALUE_TO_NUMBER_AND_NAME(kTimerEvent) |
83 | 84 |
84 {-1, NULL} // The list must be null terminated, per API to histogram. | 85 {-1, NULL} // The list must be null terminated, per API to histogram. |
85 }; | 86 }; |
| 87 #endif // !defined(OS_NACL) |
86 | 88 |
87 bool enable_histogrammer_ = false; | 89 bool enable_histogrammer_ = false; |
88 | 90 |
89 MessageLoop::MessagePumpFactory* message_pump_for_ui_factory_ = NULL; | 91 MessageLoop::MessagePumpFactory* message_pump_for_ui_factory_ = NULL; |
90 | 92 |
91 // Returns true if MessagePump::ScheduleWork() must be called one | 93 // Returns true if MessagePump::ScheduleWork() must be called one |
92 // time for every task that is added to the MessageLoop incoming queue. | 94 // time for every task that is added to the MessageLoop incoming queue. |
93 bool AlwaysNotifyPump(MessageLoop::Type type) { | 95 bool AlwaysNotifyPump(MessageLoop::Type type) { |
94 #if defined(OS_ANDROID) | 96 #if defined(OS_ANDROID) |
95 return type == MessageLoop::TYPE_UI || type == MessageLoop::TYPE_JAVA; | 97 return type == MessageLoop::TYPE_UI || type == MessageLoop::TYPE_JAVA; |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 fd, | 720 fd, |
719 persistent, | 721 persistent, |
720 mode, | 722 mode, |
721 controller, | 723 controller, |
722 delegate); | 724 delegate); |
723 } | 725 } |
724 | 726 |
725 #endif | 727 #endif |
726 | 728 |
727 } // namespace base | 729 } // namespace base |
OLD | NEW |