OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_android.h" | 5 #include "chrome/browser/metrics/thread_watcher_android.h" |
6 | 6 |
7 #include "base/android/application_status_listener.h" | 7 #include "base/android/application_status_listener.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "chrome/browser/metrics/thread_watcher.h" | 10 #include "chrome/browser/metrics/thread_watcher.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 } else if (application_state == | 32 } else if (application_state == |
33 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES && | 33 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES && |
34 g_application_has_stopped) { | 34 g_application_has_stopped) { |
35 g_application_has_stopped = false; | 35 g_application_has_stopped = false; |
36 ThreadWatcherList::StartWatchingAll(*CommandLine::ForCurrentProcess()); | 36 ThreadWatcherList::StartWatchingAll(*CommandLine::ForCurrentProcess()); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 struct LeakyApplicationStatusListenerTraits { | 40 struct LeakyApplicationStatusListenerTraits { |
41 static const bool kRegisterOnExit = false; | 41 static const bool kRegisterOnExit = false; |
| 42 #ifndef NDEBUG |
42 static const bool kAllowedToAccessOnNonjoinableThread = true; | 43 static const bool kAllowedToAccessOnNonjoinableThread = true; |
| 44 #endif |
43 | 45 |
44 static base::android::ApplicationStatusListener* New(void* instance) { | 46 static base::android::ApplicationStatusListener* New(void* instance) { |
45 ANNOTATE_SCOPED_MEMORY_LEAK; | 47 ANNOTATE_SCOPED_MEMORY_LEAK; |
46 return new (instance) base::android::ApplicationStatusListener( | 48 return new (instance) base::android::ApplicationStatusListener( |
47 base::Bind(&OnApplicationStateChange)); | 49 base::Bind(&OnApplicationStateChange)); |
48 } | 50 } |
49 | 51 |
50 static void Delete(base::android::ApplicationStatusListener* instance) { | 52 static void Delete(base::android::ApplicationStatusListener* instance) { |
51 } | 53 } |
52 }; | 54 }; |
53 | 55 |
54 base::LazyInstance<base::android::ApplicationStatusListener, | 56 base::LazyInstance<base::android::ApplicationStatusListener, |
55 LeakyApplicationStatusListenerTraits> | 57 LeakyApplicationStatusListenerTraits> |
56 g_application_status_listener = LAZY_INSTANCE_INITIALIZER; | 58 g_application_status_listener = LAZY_INSTANCE_INITIALIZER; |
57 | 59 |
58 } // namespace | 60 } // namespace |
59 | 61 |
60 void ThreadWatcherAndroid::RegisterApplicationStatusListener() { | 62 void ThreadWatcherAndroid::RegisterApplicationStatusListener() { |
61 // Leaky. | 63 // Leaky. |
62 g_application_status_listener.Get(); | 64 g_application_status_listener.Get(); |
63 } | 65 } |
OLD | NEW |