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 "chrome/browser/metrics/thread_watcher.h" | 5 #include "chrome/browser/metrics/thread_watcher.h" |
6 | 6 |
7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
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 21 matching lines...) Expand all Loading... |
32 // | 32 // |
33 // We disable optimizations for this block of functions so the compiler doesn't | 33 // We disable optimizations for this block of functions so the compiler doesn't |
34 // merge them all together. | 34 // merge them all together. |
35 | 35 |
36 // TODO(eroman): What is the equivalent for other compilers? | 36 // TODO(eroman): What is the equivalent for other compilers? |
37 #if defined(COMPILER_MSVC) | 37 #if defined(COMPILER_MSVC) |
38 #pragma optimize("", off) | 38 #pragma optimize("", off) |
39 MSVC_PUSH_DISABLE_WARNING(4748) | 39 MSVC_PUSH_DISABLE_WARNING(4748) |
40 #endif | 40 #endif |
41 | 41 |
| 42 int* NullPointer() { |
| 43 return reinterpret_cast<int*>(NULL); |
| 44 } |
| 45 |
42 void ThreadUnresponsive_UI() { | 46 void ThreadUnresponsive_UI() { |
43 CHECK(false); | 47 *NullPointer() = __LINE__; |
44 } | 48 } |
45 | 49 |
46 void ThreadUnresponsive_DB() { | 50 void ThreadUnresponsive_DB() { |
47 CHECK(false); | 51 *NullPointer() = __LINE__; |
48 } | 52 } |
49 | 53 |
50 void ThreadUnresponsive_WEBKIT() { | 54 void ThreadUnresponsive_WEBKIT() { |
51 CHECK(false); | 55 *NullPointer() = __LINE__; |
52 } | 56 } |
53 | 57 |
54 void ThreadUnresponsive_FILE() { | 58 void ThreadUnresponsive_FILE() { |
55 CHECK(false); | 59 *NullPointer() = __LINE__; |
56 } | 60 } |
57 | 61 |
58 void ThreadUnresponsive_FILE_USER_BLOCKING() { | 62 void ThreadUnresponsive_FILE_USER_BLOCKING() { |
59 CHECK(false); | 63 *NullPointer() = __LINE__; |
60 } | 64 } |
61 | 65 |
62 void ThreadUnresponsive_PROCESS_LAUNCHER() { | 66 void ThreadUnresponsive_PROCESS_LAUNCHER() { |
63 CHECK(false); | 67 *NullPointer() = __LINE__; |
64 } | 68 } |
65 | 69 |
66 void ThreadUnresponsive_CACHE() { | 70 void ThreadUnresponsive_CACHE() { |
67 CHECK(false); | 71 *NullPointer() = __LINE__; |
68 } | 72 } |
69 | 73 |
70 void ThreadUnresponsive_IO() { | 74 void ThreadUnresponsive_IO() { |
71 CHECK(false); | 75 *NullPointer() = __LINE__; |
72 } | 76 } |
73 | 77 |
74 #if defined(COMPILER_MSVC) | 78 #if defined(COMPILER_MSVC) |
75 MSVC_POP_WARNING() | 79 MSVC_POP_WARNING() |
76 #pragma optimize("", on) | 80 #pragma optimize("", on) |
77 #endif | 81 #endif |
78 | 82 |
79 void CrashBecauseThreadWasUnresponsive(BrowserThread::ID thread_id) { | 83 void CrashBecauseThreadWasUnresponsive(BrowserThread::ID thread_id) { |
80 base::debug::Alias(&thread_id); | 84 base::debug::Alias(&thread_id); |
81 | 85 |
(...skipping 15 matching lines...) Expand all Loading... |
97 case BrowserThread::IO: | 101 case BrowserThread::IO: |
98 return ThreadUnresponsive_IO(); | 102 return ThreadUnresponsive_IO(); |
99 case BrowserThread::ID_COUNT: | 103 case BrowserThread::ID_COUNT: |
100 CHECK(false); // This shouldn't actually be reached! | 104 CHECK(false); // This shouldn't actually be reached! |
101 break; | 105 break; |
102 | 106 |
103 // Omission of the default hander is intentional -- that way the compiler | 107 // Omission of the default hander is intentional -- that way the compiler |
104 // should warn if our switch becomes outdated. | 108 // should warn if our switch becomes outdated. |
105 } | 109 } |
106 | 110 |
107 CHECK(false); // Shouldn't be reached. | 111 CHECK(false) << "Unknown thread was unresponsive."; // Shouldn't be reached. |
108 } | 112 } |
109 | 113 |
110 } // namespace | 114 } // namespace |
111 | 115 |
112 // ThreadWatcher methods and members. | 116 // ThreadWatcher methods and members. |
113 ThreadWatcher::ThreadWatcher(const WatchingParams& params) | 117 ThreadWatcher::ThreadWatcher(const WatchingParams& params) |
114 : thread_id_(params.thread_id), | 118 : thread_id_(params.thread_id), |
115 thread_name_(params.thread_name), | 119 thread_name_(params.thread_name), |
116 watched_loop_( | 120 watched_loop_( |
117 BrowserThread::GetMessageLoopProxyForThread(params.thread_id)), | 121 BrowserThread::GetMessageLoopProxyForThread(params.thread_id)), |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 | 924 |
921 #if defined(OS_WIN) | 925 #if defined(OS_WIN) |
922 // On Windows XP, give twice the time for shutdown. | 926 // On Windows XP, give twice the time for shutdown. |
923 if (base::win::GetVersion() <= base::win::VERSION_XP) | 927 if (base::win::GetVersion() <= base::win::VERSION_XP) |
924 actual_duration *= 2; | 928 actual_duration *= 2; |
925 #endif | 929 #endif |
926 | 930 |
927 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); | 931 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); |
928 shutdown_watchdog_->Arm(); | 932 shutdown_watchdog_->Arm(); |
929 } | 933 } |
OLD | NEW |