| Index: chromecast/crash/linux/minidump_writer.h
|
| diff --git a/chromecast/crash/linux/minidump_writer.h b/chromecast/crash/linux/minidump_writer.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..df854daddab937f085437de522dbe938f9b12eed
|
| --- /dev/null
|
| +++ b/chromecast/crash/linux/minidump_writer.h
|
| @@ -0,0 +1,70 @@
|
| +// 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_LINUX_MINIDUMP_WRITER_H_
|
| +#define CHROMECAST_CRASH_LINUX_MINIDUMP_WRITER_H_
|
| +
|
| +#include <stdint.h>
|
| +
|
| +#include "base/macros.h"
|
| +#include "chromecast/crash/linux/dump_info.h"
|
| +#include "chromecast/crash/linux/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);
|
| +
|
| + void SetMaxDumpsForTest(int max_dumps) { max_dumps_ = max_dumps; }
|
| + void SetMaxRecentDumpsForTest(int max_recent_dumps) {
|
| + max_recent_dumps_ = max_recent_dumps;
|
| + }
|
| + bool CanWriteDumpForTest() { return CanWriteDump(); };
|
| +
|
| + protected:
|
| + // MinidumpManager implementation:
|
| + int DoWork() override;
|
| +
|
| + private:
|
| + // Returns true if we can write another dump, false otherwise. This
|
| + // function parses the file at |lockfile_path_|, which contains records of
|
| + // each minidump in |minidump_path_|. We can write another dump if the number
|
| + // of minidumps is strictly less than |max_dumps_| and the number of minidumps
|
| + // which occurred within the last |dump_interval_| is strictly less than
|
| + // |max_recent_dumps_|. This method is expensive, and should be called
|
| + // sparingly.
|
| + bool CanWriteDump() const;
|
| +
|
| + // 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_LINUX_MINIDUMP_WRITER_H_
|
|
|