diff options
4 files changed, 28 insertions, 16 deletions
diff --git a/chromecast/crash/android/cast_crash_reporter_client_android.cc b/chromecast/crash/android/cast_crash_reporter_client_android.cc index d914767..6e690dd 100644 --- a/chromecast/crash/android/cast_crash_reporter_client_android.cc +++ b/chromecast/crash/android/cast_crash_reporter_client_android.cc @@ -16,7 +16,9 @@ namespace chromecast { -CastCrashReporterClientAndroid::CastCrashReporterClientAndroid() { +CastCrashReporterClientAndroid::CastCrashReporterClientAndroid( + const std::string& process_type) + : process_type_(process_type) { } CastCrashReporterClientAndroid::~CastCrashReporterClientAndroid() { @@ -45,9 +47,12 @@ bool CastCrashReporterClientAndroid::GetCrashDumpLocation( } crash_dir_local = crash_dir_local.Append("crashes"); - if (!base::DirectoryExists(crash_dir_local)) { - if (!base::CreateDirectory(crash_dir_local)) { - return false; + // Only try to create the directory in the browser process (empty value). + if (process_type_.empty()) { + if (!base::DirectoryExists(crash_dir_local)) { + if (!base::CreateDirectory(crash_dir_local)) { + return false; + } } } diff --git a/chromecast/crash/android/cast_crash_reporter_client_android.h b/chromecast/crash/android/cast_crash_reporter_client_android.h index e98eef7..3f296ab 100644 --- a/chromecast/crash/android/cast_crash_reporter_client_android.h +++ b/chromecast/crash/android/cast_crash_reporter_client_android.h @@ -13,7 +13,7 @@ namespace chromecast { class CastCrashReporterClientAndroid : public crash_reporter::CrashReporterClient { public: - CastCrashReporterClientAndroid(); + explicit CastCrashReporterClientAndroid(const std::string& process_type); ~CastCrashReporterClientAndroid() override; // crash_reporter::CrashReporterClient implementation: @@ -28,6 +28,8 @@ class CastCrashReporterClientAndroid size_t RegisterCrashKeys() override; private: + std::string process_type_; + DISALLOW_COPY_AND_ASSIGN(CastCrashReporterClientAndroid); }; diff --git a/chromecast/crash/android/crash_handler.cc b/chromecast/crash/android/crash_handler.cc index 8bd580b..4324b71 100644 --- a/chromecast/crash/android/crash_handler.cc +++ b/chromecast/crash/android/crash_handler.cc @@ -57,8 +57,8 @@ namespace chromecast { void CrashHandler::Initialize(const std::string& process_type, const base::FilePath& log_file_path) { DCHECK(!g_crash_handler); - g_crash_handler = new CrashHandler(log_file_path); - g_crash_handler->Initialize(process_type); + g_crash_handler = new CrashHandler(process_type, log_file_path); + g_crash_handler->Initialize(); } // static @@ -73,9 +73,11 @@ bool CrashHandler::RegisterCastCrashJni(JNIEnv* env) { return RegisterNativesImpl(env); } -CrashHandler::CrashHandler(const base::FilePath& log_file_path) +CrashHandler::CrashHandler(const std::string& process_type, + const base::FilePath& log_file_path) : log_file_path_(log_file_path), - crash_reporter_client_(new CastCrashReporterClientAndroid) { + process_type_(process_type), + crash_reporter_client_(new CastCrashReporterClientAndroid(process_type)) { if (!crash_reporter_client_->GetCrashDumpLocation(&crash_dump_path_)) { LOG(ERROR) << "Could not get crash dump location"; } @@ -87,8 +89,8 @@ CrashHandler::~CrashHandler() { g_crash_handler = NULL; } -void CrashHandler::Initialize(const std::string& process_type) { - if (process_type.empty()) { +void CrashHandler::Initialize() { + if (process_type_.empty()) { InitializeUploader(); // ExceptionHandlers are called on crash in reverse order of @@ -100,13 +102,13 @@ void CrashHandler::Initialize(const std::string& process_type) { crash_uploader_.reset(new google_breakpad::ExceptionHandler( dummy, &HandleCrash, NULL, NULL, true, -1)); - breakpad::InitCrashReporter(process_type); + breakpad::InitCrashReporter(process_type_); return; } - if (process_type != switches::kZygoteProcess) { - breakpad::InitNonBrowserCrashReporterForAndroid(process_type); + if (process_type_ != switches::kZygoteProcess) { + breakpad::InitNonBrowserCrashReporterForAndroid(process_type_); } } diff --git a/chromecast/crash/android/crash_handler.h b/chromecast/crash/android/crash_handler.h index 853e7f5..f78bcd0 100644 --- a/chromecast/crash/android/crash_handler.h +++ b/chromecast/crash/android/crash_handler.h @@ -39,10 +39,11 @@ class CrashHandler { void UploadCrashDumps(); private: - CrashHandler(const base::FilePath& log_file_path); + CrashHandler(const std::string& process_type, + const base::FilePath& log_file_path); ~CrashHandler(); - void Initialize(const std::string& process_type); + void Initialize(); // Starts a thread to periodically check for uploads void InitializeUploader(); @@ -53,6 +54,8 @@ class CrashHandler { // Location to which crash dumps should be written. base::FilePath crash_dump_path_; + std::string process_type_; + scoped_ptr<CastCrashReporterClientAndroid> crash_reporter_client_; scoped_ptr<google_breakpad::ExceptionHandler> crash_uploader_; |