Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Side by Side Diff: components/crash/app/breakpad_linux.cc

Issue 762723003: Prefix CommandLine usage with base namespace (Part 8: components) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // For linux_syscall_support.h. This makes it safe to call embedded system 5 // For linux_syscall_support.h. This makes it safe to call embedded system
6 // calls when in seccomp mode. 6 // calls when in seccomp mode.
7 7
8 #include "components/crash/app/breakpad_linux.h" 8 #include "components/crash/app/breakpad_linux.h"
9 9
10 #include <fcntl.h> 10 #include <fcntl.h>
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 198 }
199 #endif 199 #endif
200 200
201 size_t LengthWithoutTrailingSpaces(const char* str, size_t len) { 201 size_t LengthWithoutTrailingSpaces(const char* str, size_t len) {
202 while (len > 0 && str[len - 1] == ' ') { 202 while (len > 0 && str[len - 1] == ' ') {
203 len--; 203 len--;
204 } 204 }
205 return len; 205 return len;
206 } 206 }
207 207
208 void SetClientIdFromCommandLine(const CommandLine& command_line) { 208 void SetClientIdFromCommandLine(const base::CommandLine& command_line) {
209 // Get the guid from the command line switch. 209 // Get the guid from the command line switch.
210 std::string switch_value = 210 std::string switch_value =
211 command_line.GetSwitchValueASCII(switches::kEnableCrashReporter); 211 command_line.GetSwitchValueASCII(switches::kEnableCrashReporter);
212 GetCrashReporterClient()->SetCrashReporterClientIdFromGUID(switch_value); 212 GetCrashReporterClient()->SetCrashReporterClientIdFromGUID(switch_value);
213 } 213 }
214 214
215 // MIME substrings. 215 // MIME substrings.
216 #if defined(OS_CHROMEOS) 216 #if defined(OS_CHROMEOS)
217 const char g_sep[] = ":"; 217 const char g_sep[] = ":";
218 #endif 218 #endif
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 info.crash_keys = g_crash_keys; 762 info.crash_keys = g_crash_keys;
763 HandleCrashDump(info); 763 HandleCrashDump(info);
764 return FinalizeCrashDoneAndroid(false /* is_browser_process */); 764 return FinalizeCrashDoneAndroid(false /* is_browser_process */);
765 } 765 }
766 766
767 void EnableNonBrowserCrashDumping(const std::string& process_type, 767 void EnableNonBrowserCrashDumping(const std::string& process_type,
768 int minidump_fd) { 768 int minidump_fd) {
769 // This will guarantee that the BuildInfo has been initialized and subsequent 769 // This will guarantee that the BuildInfo has been initialized and subsequent
770 // calls will not require memory allocation. 770 // calls will not require memory allocation.
771 base::android::BuildInfo::GetInstance(); 771 base::android::BuildInfo::GetInstance();
772 SetClientIdFromCommandLine(*CommandLine::ForCurrentProcess()); 772 SetClientIdFromCommandLine(*base::CommandLine::ForCurrentProcess());
773 773
774 // On Android, the current sandboxing uses process isolation, in which the 774 // On Android, the current sandboxing uses process isolation, in which the
775 // child process runs with a different UID. That breaks the normal crash 775 // child process runs with a different UID. That breaks the normal crash
776 // reporting where the browser process generates the minidump by inspecting 776 // reporting where the browser process generates the minidump by inspecting
777 // the child process. This is because the browser process now does not have 777 // the child process. This is because the browser process now does not have
778 // the permission to access the states of the child process (as it has a 778 // the permission to access the states of the child process (as it has a
779 // different UID). 779 // different UID).
780 // TODO(jcivelli): http://b/issue?id=6776356 we should use a watchdog 780 // TODO(jcivelli): http://b/issue?id=6776356 we should use a watchdog
781 // process forked from the renderer process that generates the minidump. 781 // process forked from the renderer process that generates the minidump.
782 if (minidump_fd == -1) { 782 if (minidump_fd == -1) {
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 // This will guarantee that the BuildInfo has been initialized and subsequent 1628 // This will guarantee that the BuildInfo has been initialized and subsequent
1629 // calls will not require memory allocation. 1629 // calls will not require memory allocation.
1630 base::android::BuildInfo::GetInstance(); 1630 base::android::BuildInfo::GetInstance();
1631 1631
1632 // Handler registration is LIFO. Install the microdump handler first, such 1632 // Handler registration is LIFO. Install the microdump handler first, such
1633 // that if conventional minidump crash reporting is enabled below, it takes 1633 // that if conventional minidump crash reporting is enabled below, it takes
1634 // precedence (i.e. its handler is run first) over the microdump handler. 1634 // precedence (i.e. its handler is run first) over the microdump handler.
1635 InitMicrodumpCrashHandlerIfNecessary(process_type); 1635 InitMicrodumpCrashHandlerIfNecessary(process_type);
1636 #endif 1636 #endif
1637 // Determine the process type and take appropriate action. 1637 // Determine the process type and take appropriate action.
1638 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 1638 const base::CommandLine& parsed_command_line =
1639 *base::CommandLine::ForCurrentProcess();
1639 if (parsed_command_line.HasSwitch(switches::kDisableBreakpad)) 1640 if (parsed_command_line.HasSwitch(switches::kDisableBreakpad))
1640 return; 1641 return;
1641 1642
1642 if (process_type.empty()) { 1643 if (process_type.empty()) {
1643 bool enable_breakpad = GetCrashReporterClient()->GetCollectStatsConsent() || 1644 bool enable_breakpad = GetCrashReporterClient()->GetCollectStatsConsent() ||
1644 GetCrashReporterClient()->IsRunningUnattended(); 1645 GetCrashReporterClient()->IsRunningUnattended();
1645 enable_breakpad &= 1646 enable_breakpad &=
1646 !parsed_command_line.HasSwitch(switches::kDisableBreakpad); 1647 !parsed_command_line.HasSwitch(switches::kDisableBreakpad);
1647 if (!enable_breakpad) { 1648 if (!enable_breakpad) {
1648 enable_breakpad = parsed_command_line.HasSwitch( 1649 enable_breakpad = parsed_command_line.HasSwitch(
(...skipping 24 matching lines...) Expand all
1673 EnableNonBrowserCrashDumping(); 1674 EnableNonBrowserCrashDumping();
1674 VLOG(1) << "Non Browser crash dumping enabled for: " << process_type; 1675 VLOG(1) << "Non Browser crash dumping enabled for: " << process_type;
1675 #endif // #if defined(OS_ANDROID) 1676 #endif // #if defined(OS_ANDROID)
1676 } 1677 }
1677 1678
1678 PostEnableBreakpadInitialization(); 1679 PostEnableBreakpadInitialization();
1679 } 1680 }
1680 1681
1681 #if defined(OS_ANDROID) 1682 #if defined(OS_ANDROID)
1682 void InitNonBrowserCrashReporterForAndroid(const std::string& process_type) { 1683 void InitNonBrowserCrashReporterForAndroid(const std::string& process_type) {
1683 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 1684 const base::CommandLine* command_line =
1685 base::CommandLine::ForCurrentProcess();
1684 1686
1685 // Handler registration is LIFO. Install the microdump handler first, such 1687 // Handler registration is LIFO. Install the microdump handler first, such
1686 // that if conventional minidump crash reporting is enabled below, it takes 1688 // that if conventional minidump crash reporting is enabled below, it takes
1687 // precedence (i.e. its handler is run first) over the microdump handler. 1689 // precedence (i.e. its handler is run first) over the microdump handler.
1688 InitMicrodumpCrashHandlerIfNecessary(process_type); 1690 InitMicrodumpCrashHandlerIfNecessary(process_type);
1689 1691
1690 if (command_line->HasSwitch(switches::kEnableCrashReporter)) { 1692 if (command_line->HasSwitch(switches::kEnableCrashReporter)) {
1691 // On Android we need to provide a FD to the file where the minidump is 1693 // On Android we need to provide a FD to the file where the minidump is
1692 // generated as the renderer and browser run with different UIDs 1694 // generated as the renderer and browser run with different UIDs
1693 // (preventing the browser from inspecting the renderer process). 1695 // (preventing the browser from inspecting the renderer process).
1694 int minidump_fd = base::GlobalDescriptors::GetInstance()->MaybeGet( 1696 int minidump_fd = base::GlobalDescriptors::GetInstance()->MaybeGet(
1695 GetCrashReporterClient()->GetAndroidMinidumpDescriptor()); 1697 GetCrashReporterClient()->GetAndroidMinidumpDescriptor());
1696 if (minidump_fd < 0) { 1698 if (minidump_fd < 0) {
1697 NOTREACHED() << "Could not find minidump FD, crash reporting disabled."; 1699 NOTREACHED() << "Could not find minidump FD, crash reporting disabled.";
1698 } else { 1700 } else {
1699 InitCrashKeys(); 1701 InitCrashKeys();
1700 EnableNonBrowserCrashDumping(process_type, minidump_fd); 1702 EnableNonBrowserCrashDumping(process_type, minidump_fd);
1701 } 1703 }
1702 } 1704 }
1703 } 1705 }
1704 #endif // OS_ANDROID 1706 #endif // OS_ANDROID
1705 1707
1706 bool IsCrashReporterEnabled() { 1708 bool IsCrashReporterEnabled() {
1707 return g_is_crash_reporter_enabled; 1709 return g_is_crash_reporter_enabled;
1708 } 1710 }
1709 1711
1710 } // namespace breakpad 1712 } // namespace breakpad
OLDNEW
« no previous file with comments | « components/cloud_devices/common/cloud_devices_urls.cc ('k') | components/crash/app/breakpad_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698