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

Side by Side Diff: chromecast/crash/android/cast_crash_reporter_client_android.cc

Issue 1176003005: Chromecast: Android crash startup can't read path from /data/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months 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 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(bool privileged)
20 : privileged_(privileged) {
lcwu1 2015/06/12 01:42:01 I feel like it is not very clear what 'privileged_
20 } 21 }
21 22
22 CastCrashReporterClientAndroid::~CastCrashReporterClientAndroid() { 23 CastCrashReporterClientAndroid::~CastCrashReporterClientAndroid() {
23 } 24 }
24 25
25 void CastCrashReporterClientAndroid::GetProductNameAndVersion( 26 void CastCrashReporterClientAndroid::GetProductNameAndVersion(
26 const char** product_name, 27 const char** product_name,
27 const char** version) { 28 const char** version) {
28 *product_name = "media_shell"; 29 *product_name = "media_shell";
29 *version = PRODUCT_VERSION 30 *version = PRODUCT_VERSION
30 #if CAST_IS_DEBUG_BUILD() 31 #if CAST_IS_DEBUG_BUILD()
31 ".debug" 32 ".debug"
32 #endif 33 #endif
33 "." CAST_BUILD_REVISION; 34 "." CAST_BUILD_REVISION;
34 } 35 }
35 36
36 base::FilePath CastCrashReporterClientAndroid::GetReporterLogFilename() { 37 base::FilePath CastCrashReporterClientAndroid::GetReporterLogFilename() {
37 return base::FilePath(FILE_PATH_LITERAL("uploads.log")); 38 return base::FilePath(FILE_PATH_LITERAL("uploads.log"));
38 } 39 }
39 40
40 bool CastCrashReporterClientAndroid::GetCrashDumpLocation( 41 bool CastCrashReporterClientAndroid::GetCrashDumpLocation(
41 base::FilePath* crash_dir) { 42 base::FilePath* crash_dir) {
42 base::FilePath crash_dir_local; 43 base::FilePath crash_dir_local;
43 if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &crash_dir_local)) { 44 if (!PathService::Get(base::DIR_ANDROID_APP_DATA, &crash_dir_local)) {
44 return false; 45 return false;
45 } 46 }
46 crash_dir_local = crash_dir_local.Append("crashes"); 47 crash_dir_local = crash_dir_local.Append("crashes");
47 48
48 if (!base::DirectoryExists(crash_dir_local)) { 49 // Only try to create the directory in a privileged process. For other
49 if (!base::CreateDirectory(crash_dir_local)) { 50 // processes, assume the directory exists.
halliwell 2015/06/10 21:23:16 Do we need to make that assumption? Wouldn't it b
gunsch 2015/06/10 21:30:16 Renderer process is not allowed to check if file e
gunsch 2015/06/12 20:07:52 I was hoping to abstract over the "process type" c
50 return false; 51 if (privileged_) {
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698