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 15 matching lines...) Expand all Loading... | |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 // The following are unique function names for forcing the crash when a thread | 29 // The following are unique function names for forcing the crash when a thread |
30 // is unresponsive. This makes it possible to tell from the callstack alone what | 30 // is unresponsive. This makes it possible to tell from the callstack alone what |
31 // thread was unresponsive. | 31 // thread was unresponsive. |
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? |
eroman
2012/07/26 00:25:02
While you are here, can you remove this comment?
ramant (doing other things)
2012/07/26 00:28:41
Done.
| |
37 #if defined(COMPILER_MSVC) | 37 MSVC_DISABLE_OPTIMIZE() |
38 #pragma optimize("", off) | |
39 MSVC_PUSH_DISABLE_WARNING(4748) | 38 MSVC_PUSH_DISABLE_WARNING(4748) |
40 #endif | |
41 | 39 |
42 int* NullPointer() { | 40 int* NullPointer() { |
43 return reinterpret_cast<int*>(NULL); | 41 return reinterpret_cast<int*>(NULL); |
44 } | 42 } |
45 | 43 |
46 void ThreadUnresponsive_UI() { | 44 NOINLINE void ThreadUnresponsive_UI() { |
47 *NullPointer() = __LINE__; | 45 *NullPointer() = __LINE__; |
48 } | 46 } |
49 | 47 |
50 void ThreadUnresponsive_DB() { | 48 NOINLINE void ThreadUnresponsive_DB() { |
51 *NullPointer() = __LINE__; | 49 *NullPointer() = __LINE__; |
52 } | 50 } |
53 | 51 |
54 void ThreadUnresponsive_WEBKIT() { | 52 NOINLINE void ThreadUnresponsive_WEBKIT() { |
55 *NullPointer() = __LINE__; | 53 *NullPointer() = __LINE__; |
56 } | 54 } |
57 | 55 |
58 void ThreadUnresponsive_FILE() { | 56 NOINLINE void ThreadUnresponsive_FILE() { |
59 *NullPointer() = __LINE__; | 57 *NullPointer() = __LINE__; |
60 } | 58 } |
61 | 59 |
62 void ThreadUnresponsive_FILE_USER_BLOCKING() { | 60 NOINLINE void ThreadUnresponsive_FILE_USER_BLOCKING() { |
63 *NullPointer() = __LINE__; | 61 *NullPointer() = __LINE__; |
64 } | 62 } |
65 | 63 |
66 void ThreadUnresponsive_PROCESS_LAUNCHER() { | 64 NOINLINE void ThreadUnresponsive_PROCESS_LAUNCHER() { |
67 *NullPointer() = __LINE__; | 65 *NullPointer() = __LINE__; |
68 } | 66 } |
69 | 67 |
70 void ThreadUnresponsive_CACHE() { | 68 NOINLINE void ThreadUnresponsive_CACHE() { |
71 *NullPointer() = __LINE__; | 69 *NullPointer() = __LINE__; |
72 } | 70 } |
73 | 71 |
74 void ThreadUnresponsive_IO() { | 72 NOINLINE void ThreadUnresponsive_IO() { |
75 *NullPointer() = __LINE__; | 73 *NullPointer() = __LINE__; |
76 } | 74 } |
77 | 75 |
78 #if defined(COMPILER_MSVC) | |
79 MSVC_POP_WARNING() | 76 MSVC_POP_WARNING() |
80 #pragma optimize("", on) | 77 MSVC_ENABLE_OPTIMIZE(); |
81 #endif | |
82 | 78 |
83 void CrashBecauseThreadWasUnresponsive(BrowserThread::ID thread_id) { | 79 void CrashBecauseThreadWasUnresponsive(BrowserThread::ID thread_id) { |
84 base::debug::Alias(&thread_id); | 80 base::debug::Alias(&thread_id); |
85 | 81 |
86 switch (thread_id) { | 82 switch (thread_id) { |
87 case BrowserThread::UI: | 83 case BrowserThread::UI: |
88 return ThreadUnresponsive_UI(); | 84 return ThreadUnresponsive_UI(); |
89 case BrowserThread::DB: | 85 case BrowserThread::DB: |
90 return ThreadUnresponsive_DB(); | 86 return ThreadUnresponsive_DB(); |
91 case BrowserThread::WEBKIT_DEPRECATED: | 87 case BrowserThread::WEBKIT_DEPRECATED: |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
924 | 920 |
925 #if defined(OS_WIN) | 921 #if defined(OS_WIN) |
926 // On Windows XP, give twice the time for shutdown. | 922 // On Windows XP, give twice the time for shutdown. |
927 if (base::win::GetVersion() <= base::win::VERSION_XP) | 923 if (base::win::GetVersion() <= base::win::VERSION_XP) |
928 actual_duration *= 2; | 924 actual_duration *= 2; |
929 #endif | 925 #endif |
930 | 926 |
931 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); | 927 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); |
932 shutdown_watchdog_->Arm(); | 928 shutdown_watchdog_->Arm(); |
933 } | 929 } |
OLD | NEW |