summaryrefslogtreecommitdiffstats
path: root/chrome/chrome_watcher
diff options
context:
space:
mode:
authorchrisha <chrisha@chromium.org>2015-12-10 15:38:21 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-10 23:39:24 +0000
commit6c1ee213efd0a1cb2268bf8b922cf78bb2fe93e0 (patch)
tree2c8ed8a0a414ae2db763e10600130897cc441e8d /chrome/chrome_watcher
parentd4246652b1da9f5a880632cc5b070d4d247ad0b7 (diff)
downloadchromium_src-6c1ee213efd0a1cb2268bf8b922cf78bb2fe93e0.zip
chromium_src-6c1ee213efd0a1cb2268bf8b922cf78bb2fe93e0.tar.gz
chromium_src-6c1ee213efd0a1cb2268bf8b922cf78bb2fe93e0.tar.bz2
[Kasko] Add ability to explicitly set Kasko configuration for testing.
This allows Kasko defaults to be over-ridden via environment variables, enabling easier integration testing. BUG=564329 Review URL: https://codereview.chromium.org/1512323002 Cr-Commit-Position: refs/heads/master@{#364523}
Diffstat (limited to 'chrome/chrome_watcher')
-rw-r--r--chrome/chrome_watcher/chrome_watcher_main.cc46
1 files changed, 43 insertions, 3 deletions
diff --git a/chrome/chrome_watcher/chrome_watcher_main.cc b/chrome/chrome_watcher/chrome_watcher_main.cc
index db578d6..01e916b 100644
--- a/chrome/chrome_watcher/chrome_watcher_main.cc
+++ b/chrome/chrome_watcher/chrome_watcher_main.cc
@@ -10,6 +10,7 @@
#include "base/bind_helpers.h"
#include "base/callback_helpers.h"
#include "base/command_line.h"
+#include "base/environment.h"
#include "base/file_version_info.h"
#include "base/files/file_path.h"
#include "base/logging_win.h"
@@ -194,6 +195,40 @@ void OnWindowEvent(
}
#ifdef KASKO
+// Helper function for determining the crash server to use. Defaults to the
+// standard crash server, but can be overridden via an environment variable.
+// Enables easy integration testing.
+void GetKaskoCrashServerUrl(base::string16* crash_server) {
+ const char kKaskoCrashServerUrl[] = "KASKO_CRASH_SERVER_URL";
+ static const wchar_t kDefaultKaskoCrashServerUrl[] =
+ L"https://clients2.google.com/cr/report";
+
+ auto env = base::Environment::Create();
+ std::string env_var;
+ if (env->GetVar(kKaskoCrashServerUrl, &env_var)) {
+ base::UTF8ToWide(env_var.c_str(), env_var.size(), crash_server);
+ } else {
+ *crash_server = kDefaultKaskoCrashServerUrl;
+ }
+}
+
+// Helper function for determining the crash reports directory to use. Defaults
+// to the browser data directory, but can be overridden via an environment
+// variable. Enables easy integration testing.
+void GetKaskoCrashReportsBaseDir(const base::char16* browser_data_directory,
+ base::FilePath* base_dir) {
+ const char kKaskoCrashReportBaseDir[] = "KASKO_CRASH_REPORTS_BASE_DIR";
+ auto env = base::Environment::Create();
+ std::string env_var;
+ if (env->GetVar(kKaskoCrashReportBaseDir, &env_var)) {
+ base::string16 wide_env_var;
+ base::UTF8ToWide(env_var.c_str(), env_var.size(), &wide_env_var);
+ *base_dir = base::FilePath(wide_env_var);
+ } else {
+ *base_dir = base::FilePath(browser_data_directory);
+ }
+}
+
void DumpHungBrowserProcess(DWORD main_thread_id,
const base::string16& channel,
const base::Process& process) {
@@ -337,14 +372,19 @@ extern "C" int WatcherMain(const base::char16* registry_path,
base::Callback<void(const base::Process&)> on_hung_callback;
#ifdef KASKO
+ base::string16 crash_server;
+ GetKaskoCrashServerUrl(&crash_server);
+
+ base::FilePath crash_reports_base_dir;
+ GetKaskoCrashReportsBaseDir(browser_data_directory, &crash_reports_base_dir);
bool launched_kasko = kasko::api::InitializeReporter(
GetKaskoEndpoint(process.Pid()).c_str(),
- L"https://clients2.google.com/cr/report",
- base::FilePath(browser_data_directory)
+ crash_server.c_str(),
+ crash_reports_base_dir
.Append(L"Crash Reports")
.value()
.c_str(),
- base::FilePath(browser_data_directory)
+ crash_reports_base_dir
.Append(kPermanentlyFailedReportsSubdir)
.value()
.c_str(),