Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3166)

Unified Diff: chromecast/crash/minidump_manager.h

Issue 1154383006: Adding crash utilities to chromecast/crash. (Closed) Base URL: https://eureka-internal.googlesource.com/chromium/src@master
Patch Set: Corrected version hack in breakpad_util. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromecast/crash/minidump_manager.h
diff --git a/chromecast/crash/minidump_manager.h b/chromecast/crash/minidump_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..c008ded37f93d542e4faae42092600572c9a2a47
--- /dev/null
+++ b/chromecast/crash/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_MINIDUMP_MANAGER_H_
+#define CHROMECAST_CRASH_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_MINIDUMP_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698