Index: base/win/registry.h |
diff --git a/base/win/registry.h b/base/win/registry.h |
index af1aee7dce9d56d01cf911444bbf017bd67259eb..ba5b2f86b2392bbbc192593ff827545e73842736 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,10 @@ namespace win { |
// are not touched in case of failure. |
class BASE_EXPORT RegKey { |
public: |
+ // Called from the MessageLoop when the key changes. To continue watching the |
eroman
2014/10/10 21:34:35
This comment seems more appropriate as part of Sta
rvargas (doing something else)
2014/10/10 22:22:05
Moved the last part to StartWatching() but I'm not
|
+ // object, StartWatching must be called again. |
+ typedef base::Callback<void()> ChangeCallback; |
+ |
RegKey(); |
explicit RegKey(HKEY key); |
RegKey(HKEY rootkey, const wchar_t* subkey, REGSAM access); |
@@ -120,22 +126,15 @@ 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. |
+ 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,14 @@ class BASE_EXPORT RegKey { |
static LONG RegDelRecurse(HKEY root_key, |
const std::wstring& name, |
REGSAM access); |
+ |
+ // objectWatcher::Delegate notification. |
+ void OnObjectSignaled(HANDLE object); |
+ |
HKEY key_; // The registry key being iterated. |
- HANDLE watch_event_; |
REGSAM wow64access_; |
+ scoped_ptr<Watcher> key_watcher_; |
+ ChangeCallback callback_; |
eroman
2014/10/10 21:34:35
I suggest keeping this as an internal detail of Wa
rvargas (doing something else)
2014/10/10 22:22:05
Done.
|
DISALLOW_COPY_AND_ASSIGN(RegKey); |
}; |