Chromium Code Reviews| Index: chromecast/crash/minidump_writer.h |
| diff --git a/chromecast/crash/minidump_writer.h b/chromecast/crash/minidump_writer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7e39e458d4f9945164b2195a709edb48f2778ec2 |
| --- /dev/null |
| +++ b/chromecast/crash/minidump_writer.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROMECAST_CRASH_MINIDUMP_WRITER_H_ |
| +#define CHROMECAST_CRASH_MINIDUMP_WRITER_H_ |
| + |
| +#include <stdint.h> |
| + |
| +#include "base/macros.h" |
| +#include "chromecast/crash/dump_info.h" |
| +#include "chromecast/crash/minidump_manager.h" |
| + |
| +namespace chromecast { |
| + |
| +class MinidumpGenerator; |
| + |
| +// Class for writing a minidump. |
| +class MinidumpWriter : public MinidumpManager { |
| + public: |
| + // Constructs a minidump writer. |
| + MinidumpWriter(MinidumpGenerator* minidump_generator, |
| + const std::string& minidump_path, |
| + const MinidumpParams& params); |
| + |
| + ~MinidumpWriter() override {} |
| + |
| + // Fork and run dumpstate, saving results to minidump_name + ".txt.gz". |
| + static int DumpState(const std::string& minidump_name); |
| + |
| + protected: |
| + // MinidumpManager implementation: |
| + int DoWork() override; |
| + |
| + private: |
| + 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.
|
| + |
| + // Returns true if we can write another dump, false otherwise. This |
| + // function checks for two limits: current number of dumps in *dump_path*, |
| + // and recent number of dumps written in *dump_interval*. The respective |
| + // maximums are defined by *max_dumps* and *max_recent_dumps*. *fd* is the |
| + // file descriptor of the lockfile. |
| + bool CanWriteDump(); |
| + |
| + // Append another entry to the lockfile describing the latest dump written. |
| + // Returns 0 on success, -1 on failure. |
| + int LogLockFile(const std::string& logfile); |
| + |
| + // These are data passed in from the constructor, to be used inside DoWork(). |
| + MinidumpGenerator* minidump_generator_; |
| + const std::string& minidump_path_; |
| + const MinidumpParams params_; |
| + |
| + int max_dumps_; |
| + int dump_interval_; |
| + int max_recent_dumps_; |
| + int max_total_size_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MinidumpWriter); |
| +}; |
| + |
| +} // namespace chromecast |
| + |
| +#endif // CHROMECAST_CRASH_MINIDUMP_WRITER_H_ |