summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 23:24:57 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 23:24:57 +0000
commitc40b440c5c8978011baf6349f604fe9b7d29204d (patch)
tree0abfc3c97a0465717dfae831bcaf313269afd3fc /base
parent0d5ab150cfde6fdd4ff9d9927e0d95c2b570257c (diff)
downloadchromium_src-c40b440c5c8978011baf6349f604fe9b7d29204d.zip
chromium_src-c40b440c5c8978011baf6349f604fe9b7d29204d.tar.gz
chromium_src-c40b440c5c8978011baf6349f604fe9b7d29204d.tar.bz2
Order function definitions in base/win/registry.cc according to the header.
BUG=68682 TEST=trybots Review URL: http://codereview.chromium.org/6354002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71511 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/win/registry.cc328
-rw-r--r--base/win/registry.h2
2 files changed, 168 insertions, 162 deletions
diff --git a/base/win/registry.cc b/base/win/registry.cc
index dbb8d7a..3c14a6c 100644
--- a/base/win/registry.cc
+++ b/base/win/registry.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,136 +14,7 @@
namespace base {
namespace win {
-RegistryValueIterator::RegistryValueIterator(HKEY root_key,
- const wchar_t* folder_key) {
- base::ThreadRestrictions::AssertIOAllowed();
-
- LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_);
- if (result != ERROR_SUCCESS) {
- key_ = NULL;
- } else {
- DWORD count = 0;
- result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL, &count,
- NULL, NULL, NULL, NULL);
-
- if (result != ERROR_SUCCESS) {
- ::RegCloseKey(key_);
- key_ = NULL;
- } else {
- index_ = count - 1;
- }
- }
-
- Read();
-}
-
-RegistryValueIterator::~RegistryValueIterator() {
- base::ThreadRestrictions::AssertIOAllowed();
- if (key_)
- ::RegCloseKey(key_);
-}
-
-bool RegistryValueIterator::Valid() const {
- return key_ != NULL && index_ >= 0;
-}
-
-void RegistryValueIterator::operator++() {
- --index_;
- Read();
-}
-
-bool RegistryValueIterator::Read() {
- base::ThreadRestrictions::AssertIOAllowed();
- if (Valid()) {
- DWORD ncount = arraysize(name_);
- value_size_ = sizeof(value_);
- LRESULT r = ::RegEnumValue(key_, index_, name_, &ncount, NULL, &type_,
- reinterpret_cast<BYTE*>(value_), &value_size_);
- if (ERROR_SUCCESS == r)
- return true;
- }
-
- name_[0] = '\0';
- value_[0] = '\0';
- value_size_ = 0;
- return false;
-}
-
-DWORD RegistryValueIterator::ValueCount() const {
- base::ThreadRestrictions::AssertIOAllowed();
- DWORD count = 0;
- HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL,
- &count, NULL, NULL, NULL, NULL);
-
- if (result != ERROR_SUCCESS)
- return 0;
-
- return count;
-}
-
-RegistryKeyIterator::RegistryKeyIterator(HKEY root_key,
- const wchar_t* folder_key) {
- base::ThreadRestrictions::AssertIOAllowed();
- LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_);
- if (result != ERROR_SUCCESS) {
- key_ = NULL;
- } else {
- DWORD count = 0;
- HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, &count, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL);
-
- if (result != ERROR_SUCCESS) {
- ::RegCloseKey(key_);
- key_ = NULL;
- } else {
- index_ = count - 1;
- }
- }
-
- Read();
-}
-
-RegistryKeyIterator::~RegistryKeyIterator() {
- base::ThreadRestrictions::AssertIOAllowed();
- if (key_)
- ::RegCloseKey(key_);
-}
-
-bool RegistryKeyIterator::Valid() const {
- return key_ != NULL && index_ >= 0;
-}
-
-void RegistryKeyIterator::operator++() {
- --index_;
- Read();
-}
-
-bool RegistryKeyIterator::Read() {
- base::ThreadRestrictions::AssertIOAllowed();
- if (Valid()) {
- DWORD ncount = arraysize(name_);
- FILETIME written;
- LRESULT r = ::RegEnumKeyEx(key_, index_, name_, &ncount, NULL, NULL,
- NULL, &written);
- if (ERROR_SUCCESS == r)
- return true;
- }
-
- name_[0] = '\0';
- return false;
-}
-
-DWORD RegistryKeyIterator::SubkeyCount() const {
- base::ThreadRestrictions::AssertIOAllowed();
- DWORD count = 0;
- HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, &count, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL);
-
- if (result != ERROR_SUCCESS)
- return 0;
-
- return count;
-}
+// RegKey ----------------------------------------------------------------------
RegKey::RegKey()
: key_(NULL),
@@ -168,15 +39,6 @@ RegKey::~RegKey() {
Close();
}
-void RegKey::Close() {
- base::ThreadRestrictions::AssertIOAllowed();
- StopWatching();
- if (key_) {
- ::RegCloseKey(key_);
- key_ = NULL;
- }
-}
-
bool RegKey::Create(HKEY rootkey, const wchar_t* subkey, REGSAM access) {
DWORD disposition_value;
return CreateWithDisposition(rootkey, subkey, &disposition_value, access);
@@ -244,6 +106,15 @@ bool RegKey::OpenKey(const wchar_t* name, REGSAM access) {
return (result == ERROR_SUCCESS);
}
+void RegKey::Close() {
+ base::ThreadRestrictions::AssertIOAllowed();
+ StopWatching();
+ if (key_) {
+ ::RegCloseKey(key_);
+ key_ = NULL;
+ }
+}
+
DWORD RegKey::ValueCount() const {
base::ThreadRestrictions::AssertIOAllowed();
DWORD count = 0;
@@ -265,6 +136,23 @@ bool RegKey::ReadName(int index, std::wstring* name) const {
return true;
}
+bool RegKey::DeleteKey(const wchar_t* name) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ if (!key_)
+ return false;
+ LSTATUS ret = SHDeleteKey(key_, name);
+ if (ERROR_SUCCESS != ret)
+ SetLastError(ret);
+ return ERROR_SUCCESS == ret;
+}
+
+bool RegKey::DeleteValue(const wchar_t* value_name) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ DCHECK(value_name);
+ HRESULT result = RegDeleteValue(key_, value_name);
+ return (result == ERROR_SUCCESS);
+}
+
bool RegKey::ValueExists(const wchar_t* name) {
base::ThreadRestrictions::AssertIOAllowed();
if (!key_)
@@ -355,23 +243,6 @@ bool RegKey::WriteValue(const wchar_t* name, DWORD value) {
static_cast<DWORD>(sizeof(value)), REG_DWORD);
}
-bool RegKey::DeleteKey(const wchar_t* name) {
- base::ThreadRestrictions::AssertIOAllowed();
- if (!key_)
- return false;
- LSTATUS ret = SHDeleteKey(key_, name);
- if (ERROR_SUCCESS != ret)
- SetLastError(ret);
- return ERROR_SUCCESS == ret;
-}
-
-bool RegKey::DeleteValue(const wchar_t* value_name) {
- base::ThreadRestrictions::AssertIOAllowed();
- DCHECK(value_name);
- HRESULT result = RegDeleteValue(key_, value_name);
- return (result == ERROR_SUCCESS);
-}
-
bool RegKey::StartWatching() {
if (!watch_event_)
watch_event_ = CreateEvent(NULL, TRUE, FALSE, NULL);
@@ -393,6 +264,16 @@ bool RegKey::StartWatching() {
}
}
+bool RegKey::HasChanged() {
+ if (watch_event_) {
+ if (WaitForSingleObject(watch_event_, 0) == WAIT_OBJECT_0) {
+ StartWatching();
+ return true;
+ }
+ }
+ return false;
+}
+
bool RegKey::StopWatching() {
if (watch_event_) {
CloseHandle(watch_event_);
@@ -402,13 +283,138 @@ bool RegKey::StopWatching() {
return false;
}
-bool RegKey::HasChanged() {
- if (watch_event_) {
- if (WaitForSingleObject(watch_event_, 0) == WAIT_OBJECT_0) {
- StartWatching();
+// RegistryValueIterator ------------------------------------------------------
+
+RegistryValueIterator::RegistryValueIterator(HKEY root_key,
+ const wchar_t* folder_key) {
+ base::ThreadRestrictions::AssertIOAllowed();
+
+ LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_);
+ if (result != ERROR_SUCCESS) {
+ key_ = NULL;
+ } else {
+ DWORD count = 0;
+ result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL, &count,
+ NULL, NULL, NULL, NULL);
+
+ if (result != ERROR_SUCCESS) {
+ ::RegCloseKey(key_);
+ key_ = NULL;
+ } else {
+ index_ = count - 1;
+ }
+ }
+
+ Read();
+}
+
+RegistryValueIterator::~RegistryValueIterator() {
+ base::ThreadRestrictions::AssertIOAllowed();
+ if (key_)
+ ::RegCloseKey(key_);
+}
+
+DWORD RegistryValueIterator::ValueCount() const {
+ base::ThreadRestrictions::AssertIOAllowed();
+ DWORD count = 0;
+ HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL, NULL,
+ &count, NULL, NULL, NULL, NULL);
+
+ if (result != ERROR_SUCCESS)
+ return 0;
+
+ return count;
+}
+
+bool RegistryValueIterator::Valid() const {
+ return key_ != NULL && index_ >= 0;
+}
+
+void RegistryValueIterator::operator++() {
+ --index_;
+ Read();
+}
+
+bool RegistryValueIterator::Read() {
+ base::ThreadRestrictions::AssertIOAllowed();
+ if (Valid()) {
+ DWORD ncount = arraysize(name_);
+ value_size_ = sizeof(value_);
+ LRESULT r = ::RegEnumValue(key_, index_, name_, &ncount, NULL, &type_,
+ reinterpret_cast<BYTE*>(value_), &value_size_);
+ if (ERROR_SUCCESS == r)
return true;
+ }
+
+ name_[0] = '\0';
+ value_[0] = '\0';
+ value_size_ = 0;
+ return false;
+}
+
+// RegistryKeyIterator --------------------------------------------------------
+
+RegistryKeyIterator::RegistryKeyIterator(HKEY root_key,
+ const wchar_t* folder_key) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_);
+ if (result != ERROR_SUCCESS) {
+ key_ = NULL;
+ } else {
+ DWORD count = 0;
+ HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, &count, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL);
+
+ if (result != ERROR_SUCCESS) {
+ ::RegCloseKey(key_);
+ key_ = NULL;
+ } else {
+ index_ = count - 1;
}
}
+
+ Read();
+}
+
+RegistryKeyIterator::~RegistryKeyIterator() {
+ base::ThreadRestrictions::AssertIOAllowed();
+ if (key_)
+ ::RegCloseKey(key_);
+}
+
+DWORD RegistryKeyIterator::SubkeyCount() const {
+ base::ThreadRestrictions::AssertIOAllowed();
+ DWORD count = 0;
+ HRESULT result = ::RegQueryInfoKey(key_, NULL, 0, NULL, &count, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL);
+
+ if (result != ERROR_SUCCESS)
+ return 0;
+
+ return count;
+}
+
+bool RegistryKeyIterator::Valid() const {
+ return key_ != NULL && index_ >= 0;
+}
+
+void RegistryKeyIterator::operator++() {
+ --index_;
+ Read();
+}
+
+bool RegistryKeyIterator::Read() {
+ base::ThreadRestrictions::AssertIOAllowed();
+ if (Valid()) {
+ DWORD ncount = arraysize(name_);
+ FILETIME written;
+ LRESULT r = ::RegEnumKeyEx(key_, index_, name_, &ncount, NULL, NULL,
+ NULL, &written);
+ if (ERROR_SUCCESS == r)
+ return true;
+ }
+
+ name_[0] = '\0';
return false;
}
diff --git a/base/win/registry.h b/base/win/registry.h
index 96a2bb3..2f06641 100644
--- a/base/win/registry.h
+++ b/base/win/registry.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.