| Index: chromecast/crash/linux/minidump_manager.h
|
| diff --git a/chromecast/crash/linux/minidump_manager.h b/chromecast/crash/linux/minidump_manager.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8b92672e22de4195c2198196c588c01052ec7dac
|
| --- /dev/null
|
| +++ b/chromecast/crash/linux/minidump_manager.h
|
| @@ -0,0 +1,67 @@
|
| +// 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_MANAGER_H_
|
| +#define CHROMECAST_CRASH_LINUX_MINIDUMP_MANAGER_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/macros.h"
|
| +
|
| +namespace chromecast {
|
| +
|
| +// Abstract class for minidump handling. Ensures synchronized access to
|
| +// minidumps using a file lock.
|
| +class MinidumpManager {
|
| + public:
|
| + virtual ~MinidumpManager();
|
| +
|
| + // Acquires file lock, calls doWork(), then releases file lock.
|
| + // Returns the status of doWork(), or -1 if the lock could not be acquired.
|
| + int DoWorkLocked();
|
| +
|
| + // Returns whether this object's file locking method is nonblocking or not.
|
| + bool nonblocking() { return nonblocking_; }
|
| +
|
| + // Sets the file locking mechansim to be nonblocking or not.
|
| + void SetNonblocking(bool nonblocking) { nonblocking_ = nonblocking; }
|
| +
|
| + protected:
|
| + MinidumpManager();
|
| +
|
| + // Overriden by child classes doing a specific operation to minidumps
|
| + virtual int DoWork() = 0;
|
| +
|
| + // Get the number of un-uploaded dumps in the dump_path directory.
|
| + // If delete_all_dumps is true, also delete all these files, this is used to
|
| + // clean lingering dump files.
|
| + int GetNumDumps(bool delete_all_dumps);
|
| +
|
| + // If true, the flock on the lockfile will be nonblocking
|
| + bool nonblocking_;
|
| +
|
| + // cached string storing the dump path directory retrieved from system
|
| + // properties, or empty string if property does not exist
|
| + std::string dump_path_;
|
| +
|
| + // cached string storing the lockfile path
|
| + std::string lockfile_path_;
|
| +
|
| + private:
|
| + // Acquire the lock file. Blocks if another process holds it, or if called
|
| + // a second time by the same process. Returns the fd of the lockfile if
|
| + // successful, or -1 if failed.
|
| + int AcquireLockFile();
|
| + // Release the lock file with the associated *fd*.
|
| + void ReleaseLockFile();
|
| +
|
| + // the lockfile fd, or -1 if not open
|
| + int lockfile_fd_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MinidumpManager);
|
| +};
|
| +
|
| +} // namespace chromecast
|
| +
|
| +#endif // CHROMECAST_CRASH_LINUX_MINIDUMP_MANAGER_H_
|
|
|