OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_LINUX_MINIDUMP_WRITER_H_ | 5 #ifndef CHROMECAST_CRASH_LINUX_MINIDUMP_WRITER_H_ |
6 #define CHROMECAST_CRASH_LINUX_MINIDUMP_WRITER_H_ | 6 #define CHROMECAST_CRASH_LINUX_MINIDUMP_WRITER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // |dump_state_cb_| is used inside DoWork(). | 39 // |dump_state_cb_| is used inside DoWork(). |
40 MinidumpWriter(MinidumpGenerator* minidump_generator, | 40 MinidumpWriter(MinidumpGenerator* minidump_generator, |
41 const std::string& minidump_filename, | 41 const std::string& minidump_filename, |
42 const MinidumpParams& params); | 42 const MinidumpParams& params); |
43 | 43 |
44 ~MinidumpWriter() override; | 44 ~MinidumpWriter() override; |
45 | 45 |
46 // Acquires exclusive access to the minidumps directory and generates a | 46 // Acquires exclusive access to the minidumps directory and generates a |
47 // minidump and a log to be uploaded later. Returns 0 if successful, -1 | 47 // minidump and a log to be uploaded later. Returns 0 if successful, -1 |
48 // otherwise. | 48 // otherwise. |
49 int Write() { return AcquireLockAndDoWork(); } | 49 int Write() { return AcquireLockAndDoWork() ? 0 : -1; } |
50 | 50 |
51 protected: | 51 protected: |
52 // MinidumpManager implementation: | 52 // MinidumpManager implementation: |
53 int DoWork() override; | 53 bool DoWork() override; |
54 | 54 |
55 private: | 55 private: |
56 MinidumpGenerator* const minidump_generator_; | 56 MinidumpGenerator* const minidump_generator_; |
57 base::FilePath minidump_path_; | 57 base::FilePath minidump_path_; |
58 const MinidumpParams params_; | 58 const MinidumpParams params_; |
59 | 59 |
60 // This callback is Run() to dump a log to |minidump_path_|.txt.gz, taking | 60 // This callback is Run() to dump a log to |minidump_path_|.txt.gz, taking |
61 // |minidump_path_| as a parameter. It returns 0 on success, and a negative | 61 // |minidump_path_| as a parameter. It returns 0 on success, and a negative |
62 // integer otherwise. If a callback is not passed in the constructor, the | 62 // integer otherwise. If a callback is not passed in the constructor, the |
63 // default implemementaion is used. | 63 // default implemementaion is used. |
64 DumpStateCallback dump_state_cb_; | 64 DumpStateCallback dump_state_cb_; |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(MinidumpWriter); | 66 DISALLOW_COPY_AND_ASSIGN(MinidumpWriter); |
67 }; | 67 }; |
68 | 68 |
69 } // namespace chromecast | 69 } // namespace chromecast |
70 | 70 |
71 #endif // CHROMECAST_CRASH_LINUX_MINIDUMP_WRITER_H_ | 71 #endif // CHROMECAST_CRASH_LINUX_MINIDUMP_WRITER_H_ |
OLD | NEW |