Skip to content

Commit

Permalink
Remove dependency from breakpad files on chrome switches.
Browse files Browse the repository at this point in the history
BUG=247431
R=mark@chromium.org

Review URL: https://codereview.chromium.org/19556005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212276 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jochen@chromium.org committed Jul 18, 2013
1 parent ed8f4eb commit 8ab19f6
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 41 deletions.
8 changes: 8 additions & 0 deletions base/base_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,12 @@ const char kWaitForDebugger[] = "wait-for-debugger";
// Sends a pretty-printed version of tracing info to the console.
const char kTraceToConsole[] = "trace-to-console";

#if defined(OS_POSIX)
// A flag, generated internally for renderer and other helper process command
// lines on Linux and Mac. It tells the helper process to enable crash dumping
// and reporting, because helpers cannot access the files needed to make this
// decision.
const char kEnableCrashReporter[] = "enable-crash-reporter";
#endif

} // namespace switches
6 changes: 6 additions & 0 deletions base/base_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#ifndef BASE_BASE_SWITCHES_H_
#define BASE_BASE_SWITCHES_H_

#include "build/build_config.h"

namespace switches {

extern const char kDebugOnStart[];
Expand All @@ -20,6 +22,10 @@ extern const char kVModule[];
extern const char kWaitForDebugger[];
extern const char kTraceToConsole[];

#if defined(OS_POSIX)
extern const char kEnableCrashReporter[];
#endif

} // namespace switches

#endif // BASE_BASE_SWITCHES_H_
3 changes: 2 additions & 1 deletion chrome/app/breakpad_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <algorithm>
#include <string>

#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/debug/crash_logging.h"
#include "base/files/file_path.h"
Expand All @@ -39,12 +40,12 @@
#include "chrome/app/breakpad_linux_impl.h"
#include "chrome/browser/crash_upload_list.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info_posix.h"
#include "chrome/common/crash_keys.h"
#include "chrome/common/env_vars.h"
#include "components/breakpad/breakpad_client.h"
#include "content/public/common/content_descriptors.h"
#include "content/public/common/content_switches.h"

#if defined(OS_ANDROID)
#include <android/log.h>
Expand Down
2 changes: 1 addition & 1 deletion chrome/app/breakpad_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
#include "base/threading/thread_restrictions.h"
#import "breakpad/src/client/mac/Framework/Breakpad.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/crash_keys.h"
#include "chrome/common/env_vars.h"
#include "chrome/installer/util/google_update_settings.h"
#include "content/public/common/content_switches.h"
#include "components/breakpad/breakpad_client.h"
#include "components/nacl/common/nacl_switches.h"
#include "native_client/src/trusted/service_runtime/osx/crash_filter.h"
Expand Down
40 changes: 9 additions & 31 deletions chrome/app/breakpad_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "base/command_line.h"
#include "base/debug/crash_logging.h"
#include "base/environment.h"
#include "base/file_version_info.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/strings/string_split.h"
Expand All @@ -33,13 +32,13 @@
#include "chrome/app/hard_error_handler_win.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_result_codes.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/crash_keys.h"
#include "chrome/common/env_vars.h"
#include "chrome/installer/util/google_chrome_sxs_distribution.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chrome/installer/util/install_util.h"
#include "components/breakpad/breakpad_client.h"
#include "content/public/common/content_switches.h"
#include "policy/policy_constants.h"
#include "sandbox/win/src/nt_internals.h"
#include "sandbox/win/src/sidestep/preamble_patcher.h"
Expand Down Expand Up @@ -362,41 +361,20 @@ std::wstring GetProfileType() {
google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& exe_path,
const std::wstring& type,
const std::wstring& channel) {
scoped_ptr<FileVersionInfo>
version_info(FileVersionInfo::CreateFileVersionInfo(
base::FilePath(exe_path)));

std::wstring version, product;
std::wstring special_build;
if (version_info.get()) {
// Get the information from the file.
version = version_info->product_version();
if (!version_info->is_official_build())
version.append(L"-devel");

const CommandLine& command = *CommandLine::ForCurrentProcess();
if (command.HasSwitch(switches::kChromeFrame)) {
product = L"ChromeFrame";
} else {
product = version_info->product_short_name();
}

special_build = version_info->special_build();
} else {
// No version info found. Make up the values.
product = L"Chrome";
version = L"0.0.0.0-devel";
}
base::string16 version, product;
base::string16 special_build;
breakpad::GetBreakpadClient()->GetProductNameAndVersion(
base::FilePath(exe_path), &product, &version, &special_build);

// We only expect this method to be called once per process.
DCHECK(!g_custom_entries);
g_custom_entries = new std::vector<google_breakpad::CustomInfoEntry>;

// Common g_custom_entries.
g_custom_entries->push_back(
google_breakpad::CustomInfoEntry(L"ver", version.c_str()));
google_breakpad::CustomInfoEntry(L"ver", UTF16ToWide(version).c_str()));
g_custom_entries->push_back(
google_breakpad::CustomInfoEntry(L"prod", product.c_str()));
google_breakpad::CustomInfoEntry(L"prod", UTF16ToWide(product).c_str()));
g_custom_entries->push_back(
google_breakpad::CustomInfoEntry(L"plat", L"Win32"));
g_custom_entries->push_back(
Expand All @@ -412,8 +390,8 @@ google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& exe_path,
google_breakpad::CustomInfoEntry(L"deferred-upload", L"true"));

if (!special_build.empty())
g_custom_entries->push_back(
google_breakpad::CustomInfoEntry(L"special", special_build.c_str()));
g_custom_entries->push_back(google_breakpad::CustomInfoEntry(
L"special", UTF16ToWide(special_build).c_str()));

g_num_of_extensions_offset = g_custom_entries->size();
g_custom_entries->push_back(
Expand Down
41 changes: 41 additions & 0 deletions chrome/app/chrome_breakpad_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@

#include "chrome/app/chrome_breakpad_client.h"

#include "base/command_line.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"

#if defined(OS_WIN)
#include "base/file_version_info.h"
#endif

#if defined(OS_POSIX)
#include "chrome/common/dump_without_crashing.h"
Expand All @@ -34,6 +42,39 @@ bool ChromeBreakpadClient::GetAlternativeCrashDumpLocation(

return false;
}

void ChromeBreakpadClient::GetProductNameAndVersion(
const base::FilePath& exe_path,
base::string16* product_name,
base::string16* version,
base::string16* special_build) {
DCHECK(product_name);
DCHECK(version);
DCHECK(special_build);

scoped_ptr<FileVersionInfo> version_info(
FileVersionInfo::CreateFileVersionInfo(exe_path));

if (version_info.get()) {
// Get the information from the file.
*version = version_info->product_version();
if (!version_info->is_official_build())
version->append(base::ASCIIToUTF16("-devel"));

const CommandLine& command = *CommandLine::ForCurrentProcess();
if (command.HasSwitch(switches::kChromeFrame)) {
*product_name = base::ASCIIToUTF16("ChromeFrame");
} else {
*product_name = version_info->product_short_name();
}

*special_build = version_info->special_build();
} else {
// No version info found. Make up the values.
*product_name = base::ASCIIToUTF16("Chrome");
*version = base::ASCIIToUTF16("0.0.0.0-devel");
}
}
#endif

bool ChromeBreakpadClient::GetCrashDumpLocation(base::FilePath* crash_dir) {
Expand Down
4 changes: 4 additions & 0 deletions chrome/app/chrome_breakpad_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class ChromeBreakpadClient : public breakpad::BreakpadClient {
#if defined(OS_WIN)
virtual bool GetAlternativeCrashDumpLocation(base::FilePath* crash_dir)
OVERRIDE;
virtual void GetProductNameAndVersion(const base::FilePath& exe_path,
base::string16* product_name,
base::string16* version,
base::string16* special_build) OVERRIDE;
#endif

virtual bool GetCrashDumpLocation(base::FilePath* crash_dir) OVERRIDE;
Expand Down
6 changes: 0 additions & 6 deletions chrome/common/chrome_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1458,12 +1458,6 @@ const char kOpenAsh[] = "open-ash";
#endif

#if defined(OS_POSIX)
// A flag, generated internally by Chrome for renderer and other helper process
// command lines on Linux and Mac. It tells the helper process to enable crash
// dumping and reporting, because helpers cannot access the profile or other
// files needed to make this decision.
const char kEnableCrashReporter[] = "enable-crash-reporter";

// Used for turning on Breakpad crash reporting in a debug environment where
// crash reporting is typically compiled but disabled.
const char kEnableCrashReporterForTesting[] =
Expand Down
1 change: 0 additions & 1 deletion chrome/common/chrome_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ extern const char kOpenAsh[];
#endif

#if defined(OS_POSIX)
extern const char kEnableCrashReporter[];
extern const char kEnableCrashReporterForTesting[];
#if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
extern const char kPasswordStore[];
Expand Down
6 changes: 6 additions & 0 deletions components/breakpad/breakpad_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ bool BreakpadClient::GetAlternativeCrashDumpLocation(
base::FilePath* crash_dir) {
return false;
}

void BreakpadClient::GetProductNameAndVersion(const base::FilePath& exe_path,
base::string16* product_name,
base::string16* version,
base::string16* special_build) {
}
#endif

bool BreakpadClient::GetCrashDumpLocation(base::FilePath* crash_dir) {
Expand Down
10 changes: 9 additions & 1 deletion components/breakpad/breakpad_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#ifndef COMPONENTS_BREAKPAD_BREAKPAD_CLIENT_H_
#define COMPONENTS_BREAKPAD_BREAKPAD_CLIENT_H_

#include "base/basictypes.h"
#include "base/strings/string16.h"
#include "build/build_config.h"

namespace base {
class FilePath;
Expand All @@ -32,6 +33,13 @@ class BreakpadClient {
// Returns true if an alternative location to store the minidump files was
// specified. Returns true if |crash_dir| was set.
virtual bool GetAlternativeCrashDumpLocation(base::FilePath* crash_dir);

// Returns a textual description of the product type and version to include
// in the crash report.
virtual void GetProductNameAndVersion(const base::FilePath& exe_path,
base::string16* product_name,
base::string16* version,
base::string16* special_build);
#endif

// The location where minidump files should be written. Returns true if
Expand Down

0 comments on commit 8ab19f6

Please sign in to comment.