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

Unified Diff: client/settings.h

Issue 1392953002: Don’t log an error when creating a new crash report database (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | client/settings.cc » ('j') | client/settings.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/settings.h
diff --git a/client/settings.h b/client/settings.h
index 61e18c4339e69628ffb76363eb2205dceb783c0e..819574897506f94c8387dda86514190be9645e3a 100644
--- a/client/settings.h
+++ b/client/settings.h
@@ -23,7 +23,7 @@
#include "base/files/file_path.h"
#include "base/scoped_generic.h"
#include "util/file/file_io.h"
-#include "util/misc/initialization_state_dcheck.h"
+#include "util/misc/initialization_state.h"
#include "util/misc/uuid.h"
namespace crashpad {
@@ -108,8 +108,7 @@ class Settings {
// This must be constructed with MakeScopedLockedFileHandle(). It both unlocks
// and closes the file on destruction.
using ScopedLockedFileHandle =
- base::ScopedGeneric<FileHandle,
- internal::ScopedLockedFileHandleTraits>;
+ base::ScopedGeneric<FileHandle, internal::ScopedLockedFileHandleTraits>;
static ScopedLockedFileHandle MakeScopedLockedFileHandle(FileHandle file,
FileLocking locking);
@@ -118,8 +117,15 @@ class Settings {
ScopedLockedFileHandle OpenForReading();
// Opens the settings file for reading and writing. On error, logs a message
- // and returns the invalid handle.
- ScopedLockedFileHandle OpenForReadingAndWriting();
+ // and returns the invalid handle. |mode| determines how the file will be
+ // opened. |mode| must not be FileWriteMode::kTruncateOrCreate.
+ //
+ // If |log_open_error| is false, nothing will be logged for an error
+ // encountered when attempting to open the file, but this method will still
+ // return false. This is intended to be used to suppress error messages when
+ // attempting to create a new settings file when multiple attempts are made.
+ ScopedLockedFileHandle OpenForReadingAndWriting(FileWriteMode mode,
+ bool log_open_error);
// Opens the settings file and reads the data. If that fails, an error will
// be logged and the settings will be recovered and re-initialized. If that
@@ -133,7 +139,12 @@ class Settings {
// Reads the settings from |handle|. Logs an error and returns false on
// failure. This does not perform recovery.
- bool ReadSettings(FileHandle handle, Data* out_data);
+ //
+ // If |log_read_error| is false, nothing will be logged for a read error, but
+ // this method will still return false. This is intended to be used to
+ // suppress error messages when attempting to read a newly created settings
+ // file.
scottmg 2015/10/07 17:28:33 Maybe add a comment here that |handle| is expected
Mark Mentovai 2015/10/07 17:50:09 scottmg wrote:
+ bool ReadSettings(FileHandle handle, Data* out_data, bool log_read_error);
// Writes the settings to |handle|. Logs an error and returns false on
// failure. This does not perform recovery.
@@ -155,7 +166,7 @@ class Settings {
base::FilePath file_path_;
- InitializationStateDcheck initialized_;
+ InitializationState initialized_;
DISALLOW_COPY_AND_ASSIGN(Settings);
};
« no previous file with comments | « no previous file | client/settings.cc » ('j') | client/settings.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698