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

Unified Diff: base/win/registry.h

Issue 632833002: Remove raw handles from base::win::RegKey (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove XP specific code. Created 6 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 | base/win/registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/win/registry.h
diff --git a/base/win/registry.h b/base/win/registry.h
index e5524b883fd24e1e24d99b85a1a0845d6ca6950c..c3e015b3bf0e59636e26b9a5a58b4b147df729b1 100644
--- a/base/win/registry.h
+++ b/base/win/registry.h
@@ -12,6 +12,8 @@
#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/stl_util.h"
+#include "base/win/object_watcher.h"
+#include "base/win/scoped_handle.h"
namespace base {
namespace win {
@@ -25,6 +27,9 @@ namespace win {
// are not touched in case of failure.
class BASE_EXPORT RegKey {
public:
+ // Called from the MessageLoop when the key changes.
+ typedef base::Callback<void()> ChangeCallback;
+
RegKey();
explicit RegKey(HKEY key);
RegKey(HKEY rootkey, const wchar_t* subkey, REGSAM access);
@@ -120,22 +125,16 @@ class BASE_EXPORT RegKey {
// Starts watching the key to see if any of its values have changed.
// The key must have been opened with the KEY_NOTIFY access privilege.
- LONG StartWatching();
-
- // If StartWatching hasn't been called, always returns false.
- // Otherwise, returns true if anything under the key has changed.
- // This can't be const because the |watch_event_| may be refreshed.
- bool HasChanged();
-
- // Will automatically be called by destructor if not manually called
- // beforehand. Returns true if it was watching, false otherwise.
- LONG StopWatching();
+ // Returns true on success.
+ // To stop watching, delete this RegKey object. To continue watching the
+ // object after the callback is invoked, call StartWatching again.
+ bool StartWatching(const ChangeCallback& callback);
- inline bool IsWatching() const { return watch_event_ != 0; }
- HANDLE watch_event() const { return watch_event_; }
HKEY Handle() const { return key_; }
private:
+ class Watcher;
+
// Calls RegDeleteKeyEx on supported platforms, alternatively falls back to
// RegDeleteKey.
static LONG RegDeleteKeyExWrapper(HKEY hKey,
@@ -147,9 +146,10 @@ class BASE_EXPORT RegKey {
static LONG RegDelRecurse(HKEY root_key,
const std::wstring& name,
REGSAM access);
+
HKEY key_; // The registry key being iterated.
- HANDLE watch_event_;
REGSAM wow64access_;
+ scoped_ptr<Watcher> key_watcher_;
DISALLOW_COPY_AND_ASSIGN(RegKey);
};
« no previous file with comments | « no previous file | base/win/registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698