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

Side by Side Diff: base/win/registry.cc

Issue 1995983002: Fix "unused variable" warnings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/win/registry.h" 5 #include "base/win/registry.h"
6 6
7 #include <shlwapi.h> 7 #include <shlwapi.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 // Mask to pull WOW64 access flags out of REGSAM access. 34 // Mask to pull WOW64 access flags out of REGSAM access.
35 const REGSAM kWow64AccessMask = KEY_WOW64_32KEY | KEY_WOW64_64KEY; 35 const REGSAM kWow64AccessMask = KEY_WOW64_32KEY | KEY_WOW64_64KEY;
36 36
37 } // namespace 37 } // namespace
38 38
39 // Watches for modifications to a key. 39 // Watches for modifications to a key.
40 class RegKey::Watcher : public ObjectWatcher::Delegate { 40 class RegKey::Watcher : public ObjectWatcher::Delegate {
41 public: 41 public:
42 explicit Watcher(RegKey* owner) : owner_(owner) {} 42 Watcher() {}
43 ~Watcher() override {} 43 ~Watcher() override {}
44 44
45 bool StartWatching(HKEY key, const ChangeCallback& callback); 45 bool StartWatching(HKEY key, const ChangeCallback& callback);
46 46
47 // Implementation of ObjectWatcher::Delegate. 47 // Implementation of ObjectWatcher::Delegate.
48 void OnObjectSignaled(HANDLE object) override { 48 void OnObjectSignaled(HANDLE object) override {
49 DCHECK(watch_event_.IsValid() && watch_event_.Get() == object); 49 DCHECK(watch_event_.IsValid() && watch_event_.Get() == object);
50 ChangeCallback callback = callback_; 50 ChangeCallback callback = callback_;
51 callback_.Reset(); 51 callback_.Reset();
52 callback.Run(); 52 callback.Run();
53 } 53 }
54 54
55 private: 55 private:
56 RegKey* owner_;
57 ScopedHandle watch_event_; 56 ScopedHandle watch_event_;
58 ObjectWatcher object_watcher_; 57 ObjectWatcher object_watcher_;
59 ChangeCallback callback_; 58 ChangeCallback callback_;
60 DISALLOW_COPY_AND_ASSIGN(Watcher); 59 DISALLOW_COPY_AND_ASSIGN(Watcher);
61 }; 60 };
62 61
63 bool RegKey::Watcher::StartWatching(HKEY key, const ChangeCallback& callback) { 62 bool RegKey::Watcher::StartWatching(HKEY key, const ChangeCallback& callback) {
64 DCHECK(key); 63 DCHECK(key);
65 DCHECK(callback_.is_null()); 64 DCHECK(callback_.is_null());
66 65
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 DWORD dtype) { 405 DWORD dtype) {
407 DCHECK(data || !dsize); 406 DCHECK(data || !dsize);
408 407
409 LONG result = RegSetValueEx(key_, name, 0, dtype, 408 LONG result = RegSetValueEx(key_, name, 0, dtype,
410 reinterpret_cast<LPBYTE>(const_cast<void*>(data)), dsize); 409 reinterpret_cast<LPBYTE>(const_cast<void*>(data)), dsize);
411 return result; 410 return result;
412 } 411 }
413 412
414 bool RegKey::StartWatching(const ChangeCallback& callback) { 413 bool RegKey::StartWatching(const ChangeCallback& callback) {
415 if (!key_watcher_) 414 if (!key_watcher_)
416 key_watcher_.reset(new Watcher(this)); 415 key_watcher_.reset(new Watcher());
417 416
418 if (!key_watcher_->StartWatching(key_, callback)) 417 if (!key_watcher_->StartWatching(key_, callback))
419 return false; 418 return false;
420 419
421 return true; 420 return true;
422 } 421 }
423 422
424 // static 423 // static
425 LONG RegKey::RegDeleteKeyExWrapper(HKEY hKey, 424 LONG RegKey::RegDeleteKeyExWrapper(HKEY hKey,
426 const wchar_t* lpSubKey, 425 const wchar_t* lpSubKey,
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 } else { 672 } else {
674 index_ = count - 1; 673 index_ = count - 1;
675 } 674 }
676 } 675 }
677 676
678 Read(); 677 Read();
679 } 678 }
680 679
681 } // namespace win 680 } // namespace win
682 } // namespace base 681 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698