OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromecast/crash/android/cast_crash_reporter_client_android.h" | 5 #include "chromecast/crash/android/cast_crash_reporter_client_android.h" |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "chromecast/android/chromecast_config_android.h" | 11 #include "chromecast/android/chromecast_config_android.h" |
12 #include "chromecast/base/version.h" | 12 #include "chromecast/base/version.h" |
13 #include "chromecast/common/global_descriptors.h" | 13 #include "chromecast/common/global_descriptors.h" |
14 #include "chromecast/crash/cast_crash_keys.h" | 14 #include "chromecast/crash/cast_crash_keys.h" |
15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
16 | 16 |
17 namespace chromecast { | 17 namespace chromecast { |
18 | 18 |
19 CastCrashReporterClientAndroid::CastCrashReporterClientAndroid() { | 19 CastCrashReporterClientAndroid::CastCrashReporterClientAndroid( |
| 20 const std::string& process_type) |
| 21 : process_type_(process_type) { |
20 } | 22 } |
21 | 23 |
22 CastCrashReporterClientAndroid::~CastCrashReporterClientAndroid() { | 24 CastCrashReporterClientAndroid::~CastCrashReporterClientAndroid() { |
23 } | 25 } |
24 | 26 |
25 void CastCrashReporterClientAndroid::GetProductNameAndVersion( | 27 void CastCrashReporterClientAndroid::GetProductNameAndVersion( |
26 const char** product_name, | 28 const char** product_name, |
27 const char** version) { | 29 const char** version) { |
28 *product_name = "media_shell"; | 30 *product_name = "media_shell"; |
29 *version = PRODUCT_VERSION | 31 *version = PRODUCT_VERSION |
30 #if CAST_IS_DEBUG_BUILD() | 32 #if CAST_IS_DEBUG_BUILD() |
31 ".debug" | 33 ".debug" |
32 #endif | 34 #endif |
33 "." CAST_BUILD_REVISION; | 35 "." CAST_BUILD_REVISION; |
34 } | 36 } |
35 | 37 |
36 base::FilePath CastCrashReporterClientAndroid::GetReporterLogFilename() { | 38 base::FilePath CastCrashReporterClientAndroid::GetReporterLogFilename() { |
37 return base::FilePath(FILE_PATH_LITERAL("uploads.log")); | 39 return base::FilePath(FILE_PATH_LITERAL("uploads.log")); |
38 } | 40 } |
39 | 41 |
40 bool CastCrashReporterClientAndroid::GetCrashDumpLocation( | 42 bool CastCrashReporterClientAndroid::GetCrashDumpLocation( |
41 base::FilePath* crash_dir) { | 43 base::FilePath* crash_dir) { |
42 base::FilePath crash_dir_local; | 44 base::FilePath crash_dir_local; |
43 if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &crash_dir_local)) { | 45 if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &crash_dir_local)) { |
44 return false; | 46 return false; |
45 } | 47 } |
46 crash_dir_local = crash_dir_local.Append("crashes"); | 48 crash_dir_local = crash_dir_local.Append("crashes"); |
47 | 49 |
48 if (!base::DirectoryExists(crash_dir_local)) { | 50 // Only try to create the directory in the browser process (empty value). |
49 if (!base::CreateDirectory(crash_dir_local)) { | 51 if (process_type_.empty()) { |
50 return false; | 52 if (!base::DirectoryExists(crash_dir_local)) { |
| 53 if (!base::CreateDirectory(crash_dir_local)) { |
| 54 return false; |
| 55 } |
51 } | 56 } |
52 } | 57 } |
53 | 58 |
54 // Provide value to crash_dir once directory is known to be a valid path. | 59 // Provide value to crash_dir once directory is known to be a valid path. |
55 *crash_dir = crash_dir_local; | 60 *crash_dir = crash_dir_local; |
56 return true; | 61 return true; |
57 } | 62 } |
58 | 63 |
59 size_t CastCrashReporterClientAndroid::RegisterCrashKeys() { | 64 size_t CastCrashReporterClientAndroid::RegisterCrashKeys() { |
60 return crash_keys::RegisterCastCrashKeys(); | 65 return crash_keys::RegisterCastCrashKeys(); |
61 } | 66 } |
62 | 67 |
63 bool CastCrashReporterClientAndroid::GetCollectStatsConsent() { | 68 bool CastCrashReporterClientAndroid::GetCollectStatsConsent() { |
64 return android::ChromecastConfigAndroid::GetInstance()->CanSendUsageStats(); | 69 return android::ChromecastConfigAndroid::GetInstance()->CanSendUsageStats(); |
65 } | 70 } |
66 | 71 |
67 int CastCrashReporterClientAndroid::GetAndroidMinidumpDescriptor() { | 72 int CastCrashReporterClientAndroid::GetAndroidMinidumpDescriptor() { |
68 return kAndroidMinidumpDescriptor; | 73 return kAndroidMinidumpDescriptor; |
69 } | 74 } |
70 | 75 |
71 bool CastCrashReporterClientAndroid::EnableBreakpadForProcess( | 76 bool CastCrashReporterClientAndroid::EnableBreakpadForProcess( |
72 const std::string& process_type) { | 77 const std::string& process_type) { |
73 return process_type == switches::kRendererProcess || | 78 return process_type == switches::kRendererProcess || |
74 process_type == switches::kGpuProcess; | 79 process_type == switches::kGpuProcess; |
75 } | 80 } |
76 | 81 |
77 } // namespace chromecast | 82 } // namespace chromecast |
OLD | NEW |