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

Unified Diff: client/settings_mac.h

Issue 988063003: Define the Settings interface for a CrashReportDatabase and provide a Mac implementation. (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 9 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: client/settings_mac.h
diff --git a/client/settings_mac.h b/client/settings_mac.h
new file mode 100644
index 0000000000000000000000000000000000000000..968c0443d8bcf126e6130843b6794cbeb335372b
--- /dev/null
+++ b/client/settings_mac.h
@@ -0,0 +1,64 @@
+// Copyright 2015 The Crashpad Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef CRASHPAD_CLIENT_SETTINGS_MAC_H_
+#define CRASHPAD_CLIENT_SETTINGS_MAC_H_
+
+#import <Foundation/Foundation.h>
+
+#include "base/files/file_path.h"
+#include "base/mac/scoped_nsobject.h"
+#include "client/settings.h"
+#include "util/file/file_io.h"
+
+namespace crashpad {
+namespace internal {
+
+//! \brief An implementation of the Settings interface, which stores the values
+//! in a property list (plist) file.
+//!
+//! This class makes use of Foundation, and as such requires the presence of an
+//! autorelease pool to properly manage memory.
+class SettingsMac : public Settings {
+ public:
+ explicit SettingsMac(const base::FilePath& prefs_file);
+ ~SettingsMac() override;
+
+ bool Initialize();
+
+ // Settings:
+ bool GetClientID(std::string* client_id) override;
+ bool GetUploadsEnabled(bool* enabled) override;
+ bool SetUploadsEnabled(bool enabled) override;
+ bool GetLastUploadAttemptTime(time_t* time) override;
+ bool SetLastUploadAttemptTime(time_t time) override;
+
+ private:
+ base::scoped_nsobject<NSMutableDictionary> ReadPlist(FileHandle fd);
+ bool WritePlist(FileHandle fd, NSDictionary* plist);
+
+ base::scoped_nsobject<id> GetSetting(NSString* key);
+ bool SetSetting(NSString* key, NSObject* value);
+
+ const char* prefs_file() { return prefs_file_.value().c_str(); };
+
+ base::FilePath prefs_file_;
+
+ DISALLOW_COPY_AND_ASSIGN(SettingsMac);
+};
+
+} // namespace internal
+} // namespace crashpad
+
+#endif // CRASHPAD_CLIENT_SETTINGS_MAC_H_

Powered by Google App Engine
This is Rietveld 408576698