Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROMECAST_CRASH_MINIDUMP_WRITER_H_ | |
| 6 #define CHROMECAST_CRASH_MINIDUMP_WRITER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "chromecast/crash/dump_info.h" | |
| 12 #include "chromecast/crash/minidump_manager.h" | |
| 13 | |
| 14 namespace chromecast { | |
| 15 | |
| 16 class MinidumpGenerator; | |
| 17 | |
| 18 // Class for writing a minidump. | |
| 19 class MinidumpWriter : public MinidumpManager { | |
| 20 public: | |
| 21 // Constructs a minidump writer. | |
| 22 MinidumpWriter(MinidumpGenerator* minidump_generator, | |
| 23 const std::string& minidump_path, | |
| 24 const MinidumpParams& params); | |
| 25 | |
| 26 ~MinidumpWriter() override {} | |
| 27 | |
| 28 // Fork and run dumpstate, saving results to minidump_name + ".txt.gz". | |
| 29 static int DumpState(const std::string& minidump_name); | |
| 30 | |
| 31 protected: | |
| 32 // MinidumpManager implementation: | |
| 33 int DoWork() override; | |
| 34 | |
| 35 private: | |
| 36 friend class MinidumpWriterTest; | |
|
gunsch
2015/06/09 18:46:19
nit: prefer using public *ForTest methods (enforce
slan
2015/06/10 01:49:13
Done.
| |
| 37 | |
| 38 // Returns true if we can write another dump, false otherwise. This | |
| 39 // function checks for two limits: current number of dumps in *dump_path*, | |
| 40 // and recent number of dumps written in *dump_interval*. The respective | |
| 41 // maximums are defined by *max_dumps* and *max_recent_dumps*. *fd* is the | |
| 42 // file descriptor of the lockfile. | |
| 43 bool CanWriteDump(); | |
| 44 | |
| 45 // Append another entry to the lockfile describing the latest dump written. | |
| 46 // Returns 0 on success, -1 on failure. | |
| 47 int LogLockFile(const std::string& logfile); | |
| 48 | |
| 49 // These are data passed in from the constructor, to be used inside DoWork(). | |
| 50 MinidumpGenerator* minidump_generator_; | |
| 51 const std::string& minidump_path_; | |
| 52 const MinidumpParams params_; | |
| 53 | |
| 54 int max_dumps_; | |
| 55 int dump_interval_; | |
| 56 int max_recent_dumps_; | |
| 57 int max_total_size_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(MinidumpWriter); | |
| 60 }; | |
| 61 | |
| 62 } // namespace chromecast | |
| 63 | |
| 64 #endif // CHROMECAST_CRASH_MINIDUMP_WRITER_H_ | |
| OLD | NEW |