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 #ifndef CHROMECAST_CRASH_ANDROID_CRASH_HANDLER_H_ | 5 #ifndef CHROMECAST_CRASH_ANDROID_CRASH_HANDLER_H_ |
6 #define CHROMECAST_CRASH_ANDROID_CRASH_HANDLER_H_ | 6 #define CHROMECAST_CRASH_ANDROID_CRASH_HANDLER_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 | 14 |
15 namespace google_breakpad { | |
16 class ExceptionHandler; | |
17 } | |
18 | |
19 namespace chromecast { | 15 namespace chromecast { |
20 class CastCrashReporterClientAndroid; | 16 class CastCrashReporterClientAndroid; |
21 | 17 |
22 class CrashHandler { | 18 class CrashHandler { |
23 public: | 19 public: |
24 // Initializes the crash handler for attempting to upload crash dumps with | 20 // Initializes the crash handler for attempting to upload crash dumps with |
25 // the current process's log file. | 21 // the current process's log file. |
26 // Must not be called more than once. | 22 // Must not be called more than once. |
27 static void Initialize(const std::string& process_type, | 23 static void Initialize(const std::string& process_type, |
28 const base::FilePath& log_file_path); | 24 const base::FilePath& log_file_path); |
29 | 25 |
30 // Returns the directory location for crash dumps. | 26 // Returns the directory location for crash dumps. |
31 static bool GetCrashDumpLocation(base::FilePath* crash_dir); | 27 static bool GetCrashDumpLocation(base::FilePath* crash_dir); |
32 | 28 |
33 // Registers JNI methods for this module. | 29 // Registers JNI methods for this module. |
34 static bool RegisterCastCrashJni(JNIEnv* env); | 30 static bool RegisterCastCrashJni(JNIEnv* env); |
35 | 31 |
36 // Returns whether or not the user has allowed for uploading crash dumps. | |
37 bool CanUploadCrashDump(); | |
38 | |
39 void UploadCrashDumps(); | |
40 | |
41 private: | 32 private: |
42 CrashHandler(const std::string& process_type, | 33 CrashHandler(const std::string& process_type, |
43 const base::FilePath& log_file_path); | 34 const base::FilePath& log_file_path); |
44 ~CrashHandler(); | 35 ~CrashHandler(); |
45 | 36 |
46 void Initialize(); | 37 void Initialize(); |
47 | 38 |
48 // Starts a thread to periodically check for uploads | 39 // Starts a thread to periodically check for uploads |
49 void InitializeUploader(); | 40 void InitializeUploader(); |
50 | 41 |
51 // Path to the current process's log file. | 42 // Path to the current process's log file. |
52 base::FilePath log_file_path_; | 43 base::FilePath log_file_path_; |
53 | 44 |
54 // Location to which crash dumps should be written. | 45 // Location to which crash dumps should be written. |
55 base::FilePath crash_dump_path_; | 46 base::FilePath crash_dump_path_; |
56 | 47 |
57 std::string process_type_; | 48 std::string process_type_; |
58 | 49 |
59 scoped_ptr<CastCrashReporterClientAndroid> crash_reporter_client_; | 50 scoped_ptr<CastCrashReporterClientAndroid> crash_reporter_client_; |
60 scoped_ptr<google_breakpad::ExceptionHandler> crash_uploader_; | |
61 | 51 |
62 DISALLOW_COPY_AND_ASSIGN(CrashHandler); | 52 DISALLOW_COPY_AND_ASSIGN(CrashHandler); |
63 }; | 53 }; |
64 | 54 |
65 } // namespace chromecast | 55 } // namespace chromecast |
66 | 56 |
67 #endif // CHROMECAST_CRASH_ANDROID_CRASH_HANDLER_H_ | 57 #endif // CHROMECAST_CRASH_ANDROID_CRASH_HANDLER_H_ |
OLD | NEW |