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/chrome_browser_main_linux.h" | 5 #include "chrome/browser/chrome_browser_main_linux.h" |
6 | 6 |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/metrics/metrics_service.h" | 8 #include "chrome/browser/metrics/metrics_service.h" |
9 | 9 |
10 #if !defined(OS_CHROMEOS) | 10 #if !defined(OS_CHROMEOS) |
11 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" | 11 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #endif | 13 #endif |
14 | 14 |
15 #if defined(USE_LINUX_BREAKPAD) | |
16 #include <stdlib.h> | 15 #include <stdlib.h> |
Lei Zhang
2013/07/15 20:55:35
Can you integrate lines 15-23 with lines 7-8?
jam
2013/07/15 21:15:28
Done.
| |
17 | 16 |
18 #include "base/command_line.h" | 17 #include "base/command_line.h" |
19 #include "base/linux_util.h" | 18 #include "base/linux_util.h" |
20 #include "base/prefs/pref_service.h" | 19 #include "base/prefs/pref_service.h" |
21 #include "chrome/app/breakpad_linux.h" | 20 #include "chrome/app/breakpad_linux.h" |
22 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/common/env_vars.h" | 22 #include "chrome/common/env_vars.h" |
24 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
25 | 24 |
26 #if defined(OS_CHROMEOS) | 25 #if defined(OS_CHROMEOS) |
27 #include "chrome/browser/chromeos/settings/cros_settings.h" | 26 #include "chrome/browser/chromeos/settings/cros_settings.h" |
28 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 27 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
29 #include "chrome/common/chrome_version_info.h" | 28 #include "chrome/common/chrome_version_info.h" |
30 #include "chromeos/chromeos_switches.h" | 29 #include "chromeos/chromeos_switches.h" |
31 #endif | 30 #endif |
32 | 31 |
33 #endif // defined(USE_LINUX_BREAKPAD) | |
34 | |
35 namespace { | 32 namespace { |
36 | 33 |
37 #if defined(USE_LINUX_BREAKPAD) | |
38 #if !defined(OS_CHROMEOS) | 34 #if !defined(OS_CHROMEOS) |
39 void GetLinuxDistroCallback() { | 35 void GetLinuxDistroCallback() { |
40 base::GetLinuxDistro(); // Initialize base::linux_distro if needed. | 36 base::GetLinuxDistro(); // Initialize base::linux_distro if needed. |
41 } | 37 } |
42 #endif | 38 #endif |
43 | 39 |
44 bool IsCrashReportingEnabled(const PrefService* local_state) { | 40 bool IsCrashReportingEnabled(const PrefService* local_state) { |
45 // Check whether we should initialize the crash reporter. It may be disabled | 41 // Check whether we should initialize the crash reporter. It may be disabled |
46 // through configuration policy or user preference. It must be disabled for | 42 // through configuration policy or user preference. It must be disabled for |
47 // Guest mode on Chrome OS in Stable channel. | 43 // Guest mode on Chrome OS in Stable channel. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 // instead. | 91 // instead. |
96 if (is_chrome_build && !breakpad_enabled) | 92 if (is_chrome_build && !breakpad_enabled) |
97 breakpad_enabled = getenv(env_vars::kHeadless) != NULL; | 93 breakpad_enabled = getenv(env_vars::kHeadless) != NULL; |
98 if (!breakpad_enabled) | 94 if (!breakpad_enabled) |
99 breakpad_enabled = CommandLine::ForCurrentProcess()->HasSwitch( | 95 breakpad_enabled = CommandLine::ForCurrentProcess()->HasSwitch( |
100 switches::kEnableCrashReporterForTesting); | 96 switches::kEnableCrashReporterForTesting); |
101 } | 97 } |
102 | 98 |
103 return breakpad_enabled; | 99 return breakpad_enabled; |
104 } | 100 } |
105 #endif // defined(USE_LINUX_BREAKPAD) | |
106 | 101 |
107 } // namespace | 102 } // namespace |
108 | 103 |
109 ChromeBrowserMainPartsLinux::ChromeBrowserMainPartsLinux( | 104 ChromeBrowserMainPartsLinux::ChromeBrowserMainPartsLinux( |
110 const content::MainFunctionParams& parameters) | 105 const content::MainFunctionParams& parameters) |
111 : ChromeBrowserMainPartsPosix(parameters) { | 106 : ChromeBrowserMainPartsPosix(parameters) { |
112 } | 107 } |
113 | 108 |
114 ChromeBrowserMainPartsLinux::~ChromeBrowserMainPartsLinux() { | 109 ChromeBrowserMainPartsLinux::~ChromeBrowserMainPartsLinux() { |
115 } | 110 } |
116 | 111 |
117 void ChromeBrowserMainPartsLinux::PreProfileInit() { | 112 void ChromeBrowserMainPartsLinux::PreProfileInit() { |
118 #if defined(USE_LINUX_BREAKPAD) | |
119 #if !defined(OS_CHROMEOS) | 113 #if !defined(OS_CHROMEOS) |
120 // Needs to be called after we have chrome::DIR_USER_DATA and | 114 // Needs to be called after we have chrome::DIR_USER_DATA and |
121 // g_browser_process. This happens in PreCreateThreads. | 115 // g_browser_process. This happens in PreCreateThreads. |
122 content::BrowserThread::PostTask(content::BrowserThread::FILE, | 116 content::BrowserThread::PostTask(content::BrowserThread::FILE, |
123 FROM_HERE, | 117 FROM_HERE, |
124 base::Bind(&GetLinuxDistroCallback)); | 118 base::Bind(&GetLinuxDistroCallback)); |
125 #endif | 119 #endif |
126 | 120 |
127 if (IsCrashReportingEnabled(local_state())) | 121 if (IsCrashReportingEnabled(local_state())) |
128 InitCrashReporter(); | 122 InitCrashReporter(); |
129 #endif | |
130 | 123 |
131 #if !defined(OS_CHROMEOS) | 124 #if !defined(OS_CHROMEOS) |
132 const base::FilePath kDefaultMtabPath("/etc/mtab"); | 125 const base::FilePath kDefaultMtabPath("/etc/mtab"); |
133 storage_monitor_.reset(new chrome::StorageMonitorLinux(kDefaultMtabPath)); | 126 storage_monitor_.reset(new chrome::StorageMonitorLinux(kDefaultMtabPath)); |
134 #endif | 127 #endif |
135 | 128 |
136 ChromeBrowserMainPartsPosix::PreProfileInit(); | 129 ChromeBrowserMainPartsPosix::PreProfileInit(); |
137 } | 130 } |
138 | 131 |
139 void ChromeBrowserMainPartsLinux::PostProfileInit() { | 132 void ChromeBrowserMainPartsLinux::PostProfileInit() { |
140 ChromeBrowserMainPartsPosix::PostProfileInit(); | 133 ChromeBrowserMainPartsPosix::PostProfileInit(); |
141 | 134 |
142 #if defined(USE_LINUX_BREAKPAD) | |
143 g_browser_process->metrics_service()->RecordBreakpadRegistration( | 135 g_browser_process->metrics_service()->RecordBreakpadRegistration( |
144 IsCrashReporterEnabled()); | 136 IsCrashReporterEnabled()); |
145 #else | |
146 g_browser_process->metrics_service()->RecordBreakpadRegistration(false); | |
147 #endif | |
148 } | 137 } |
149 | 138 |
150 void ChromeBrowserMainPartsLinux::PostMainMessageLoopRun() { | 139 void ChromeBrowserMainPartsLinux::PostMainMessageLoopRun() { |
151 ChromeBrowserMainPartsPosix::PostMainMessageLoopRun(); | 140 ChromeBrowserMainPartsPosix::PostMainMessageLoopRun(); |
152 | 141 |
153 #if !defined(OS_CHROMEOS) | 142 #if !defined(OS_CHROMEOS) |
154 // Delete it now. Otherwise the FILE thread would be gone when we try to | 143 // Delete it now. Otherwise the FILE thread would be gone when we try to |
155 // release it in the dtor and Valgrind would report a leak on almost every | 144 // release it in the dtor and Valgrind would report a leak on almost every |
156 // single browser_test. | 145 // single browser_test. |
157 storage_monitor_.reset(); | 146 storage_monitor_.reset(); |
158 #endif | 147 #endif |
159 } | 148 } |
OLD | NEW |