summaryrefslogtreecommitdiffstats
path: root/base/win
diff options
context:
space:
mode:
authoramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-21 06:25:33 +0000
committeramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-21 06:25:33 +0000
commite0304c48b7720bf7a985e99601c02f9af73b28aa (patch)
tree09ba10e3c35aae559886f8498f90ae76afc14e70 /base/win
parent1a660dec676cdbd7b45a9ba11f9c4947fe9bae30 (diff)
downloadchromium_src-e0304c48b7720bf7a985e99601c02f9af73b28aa.zip
chromium_src-e0304c48b7720bf7a985e99601c02f9af73b28aa.tar.gz
chromium_src-e0304c48b7720bf7a985e99601c02f9af73b28aa.tar.bz2
Remove sanity check in RegKey to prevent usage of checking
return value as a bool BUG=none TEST=none Review URL: http://codereview.chromium.org/6346010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72110 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/win')
-rw-r--r--base/win/registry.cc34
-rw-r--r--base/win/registry.h67
2 files changed, 34 insertions, 67 deletions
diff --git a/base/win/registry.cc b/base/win/registry.cc
index b7108a2..09cf485 100644
--- a/base/win/registry.cc
+++ b/base/win/registry.cc
@@ -39,12 +39,12 @@ RegKey::~RegKey() {
Close();
}
-GONG RegKey::Create(HKEY rootkey, const wchar_t* subkey, REGSAM access) {
+LONG RegKey::Create(HKEY rootkey, const wchar_t* subkey, REGSAM access) {
DWORD disposition_value;
return CreateWithDisposition(rootkey, subkey, &disposition_value, access);
}
-GONG RegKey::CreateWithDisposition(HKEY rootkey, const wchar_t* subkey,
+LONG RegKey::CreateWithDisposition(HKEY rootkey, const wchar_t* subkey,
DWORD* disposition, REGSAM access) {
base::ThreadRestrictions::AssertIOAllowed();
DCHECK(rootkey && subkey && access && disposition);
@@ -56,7 +56,7 @@ GONG RegKey::CreateWithDisposition(HKEY rootkey, const wchar_t* subkey,
return result;
}
-GONG RegKey::Open(HKEY rootkey, const wchar_t* subkey, REGSAM access) {
+LONG RegKey::Open(HKEY rootkey, const wchar_t* subkey, REGSAM access) {
base::ThreadRestrictions::AssertIOAllowed();
DCHECK(rootkey && subkey && access);
Close();
@@ -65,7 +65,7 @@ GONG RegKey::Open(HKEY rootkey, const wchar_t* subkey, REGSAM access) {
return result;
}
-GONG RegKey::CreateKey(const wchar_t* name, REGSAM access) {
+LONG RegKey::CreateKey(const wchar_t* name, REGSAM access) {
base::ThreadRestrictions::AssertIOAllowed();
DCHECK(name && access);
@@ -78,7 +78,7 @@ GONG RegKey::CreateKey(const wchar_t* name, REGSAM access) {
return result;
}
-GONG RegKey::OpenKey(const wchar_t* name, REGSAM access) {
+LONG RegKey::OpenKey(const wchar_t* name, REGSAM access) {
base::ThreadRestrictions::AssertIOAllowed();
DCHECK(name && access);
@@ -108,7 +108,7 @@ DWORD RegKey::ValueCount() const {
return (result != ERROR_SUCCESS) ? 0 : count;
}
-GONG RegKey::ReadName(int index, std::wstring* name) const {
+LONG RegKey::ReadName(int index, std::wstring* name) const {
base::ThreadRestrictions::AssertIOAllowed();
wchar_t buf[256];
DWORD bufsize = arraysize(buf);
@@ -119,7 +119,7 @@ GONG RegKey::ReadName(int index, std::wstring* name) const {
return r;
}
-GONG RegKey::DeleteKey(const wchar_t* name) {
+LONG RegKey::DeleteKey(const wchar_t* name) {
base::ThreadRestrictions::AssertIOAllowed();
DCHECK(key_);
DCHECK(name);
@@ -127,7 +127,7 @@ GONG RegKey::DeleteKey(const wchar_t* name) {
return result;
}
-GONG RegKey::DeleteValue(const wchar_t* value_name) {
+LONG RegKey::DeleteValue(const wchar_t* value_name) {
base::ThreadRestrictions::AssertIOAllowed();
DCHECK(key_);
DCHECK(value_name);
@@ -141,7 +141,7 @@ bool RegKey::ValueExists(const wchar_t* name) const {
return result == ERROR_SUCCESS;
}
-GONG RegKey::ReadValue(const wchar_t* name, void* data, DWORD* dsize,
+LONG RegKey::ReadValue(const wchar_t* name, void* data, DWORD* dsize,
DWORD* dtype) const {
base::ThreadRestrictions::AssertIOAllowed();
LONG result = RegQueryValueEx(key_, name, 0, dtype,
@@ -149,7 +149,7 @@ GONG RegKey::ReadValue(const wchar_t* name, void* data, DWORD* dsize,
return result;
}
-GONG RegKey::ReadValue(const wchar_t* name, std::wstring* value) const {
+LONG RegKey::ReadValue(const wchar_t* name, std::wstring* value) const {
base::ThreadRestrictions::AssertIOAllowed();
DCHECK(value);
const size_t kMaxStringLength = 1024; // This is after expansion.
@@ -180,7 +180,7 @@ GONG RegKey::ReadValue(const wchar_t* name, std::wstring* value) const {
return result;
}
-GONG RegKey::ReadValueDW(const wchar_t* name, DWORD* value) const {
+LONG RegKey::ReadValueDW(const wchar_t* name, DWORD* value) const {
DCHECK(value);
DWORD type = REG_DWORD;
DWORD size = sizeof(DWORD);
@@ -197,7 +197,7 @@ GONG RegKey::ReadValueDW(const wchar_t* name, DWORD* value) const {
return result;
}
-GONG RegKey::ReadInt64(const wchar_t* name, int64* value) const {
+LONG RegKey::ReadInt64(const wchar_t* name, int64* value) const {
DCHECK(value);
DWORD type = REG_QWORD;
int64 local_value = 0;
@@ -215,7 +215,7 @@ GONG RegKey::ReadInt64(const wchar_t* name, int64* value) const {
return result;
}
-GONG RegKey::WriteValue(const wchar_t* name, const void * data,
+LONG RegKey::WriteValue(const wchar_t* name, const void * data,
DWORD dsize, DWORD dtype) {
base::ThreadRestrictions::AssertIOAllowed();
DCHECK(data);
@@ -225,16 +225,16 @@ GONG RegKey::WriteValue(const wchar_t* name, const void * data,
return result;
}
-GONG RegKey::WriteValue(const wchar_t * name, const wchar_t* value) {
+LONG RegKey::WriteValue(const wchar_t * name, const wchar_t* value) {
return WriteValue(name, value,
static_cast<DWORD>(sizeof(*value) * (wcslen(value) + 1)), REG_SZ);
}
-GONG RegKey::WriteValue(const wchar_t* name, DWORD value) {
+LONG RegKey::WriteValue(const wchar_t* name, DWORD value) {
return WriteValue(name, &value, static_cast<DWORD>(sizeof(value)), REG_DWORD);
}
-GONG RegKey::StartWatching() {
+LONG RegKey::StartWatching() {
DCHECK(key_);
if (!watch_event_)
watch_event_ = CreateEvent(NULL, TRUE, FALSE, NULL);
@@ -264,7 +264,7 @@ bool RegKey::HasChanged() {
return false;
}
-GONG RegKey::StopWatching() {
+LONG RegKey::StopWatching() {
LONG result = ERROR_INVALID_HANDLE;
if (watch_event_) {
CloseHandle(watch_event_);
diff --git a/base/win/registry.h b/base/win/registry.h
index 790fe7d..cd5421d 100644
--- a/base/win/registry.h
+++ b/base/win/registry.h
@@ -11,39 +11,6 @@
#include "base/basictypes.h"
-// Please ignore this part. This temporary hack exists
-// to detect if the return value is used as 'bool'.
-// Todo(amit): remove this before (or soon after) checkin.
-struct CatchBoolChecks {
- CatchBoolChecks(LONG l) : l_(l) {}
- LONG l_;
- operator LONG() { return l_; }
- LONG value() const { return l_; }
- bool operator == (LONG l) const { return l == l_; }
- bool operator != (LONG l) const { return l != l_; }
- private:
- // If you hit a compile error here, you most likely attempting to use the
- // return value of a RegKey helper as a bool. Please note that RegKey
- // methods return LONG now instead of bool.
- operator bool () { return false; }
-};
-
-inline bool operator == (const LONG& l, const CatchBoolChecks& g) {
- return g.value() == l;
-}
-
-inline bool operator != (const LONG& l, const CatchBoolChecks& g) {
- return g.value() != l;
-}
-
-using std::ostream;
-inline ostream& operator <<(ostream &os, const CatchBoolChecks& g) {
- os << g.value();
- return os;
-}
-
-typedef CatchBoolChecks GONG;
-
namespace base {
namespace win {
@@ -60,52 +27,52 @@ class RegKey {
RegKey(HKEY rootkey, const wchar_t* subkey, REGSAM access);
~RegKey();
- GONG Create(HKEY rootkey, const wchar_t* subkey, REGSAM access);
+ LONG Create(HKEY rootkey, const wchar_t* subkey, REGSAM access);
- GONG CreateWithDisposition(HKEY rootkey, const wchar_t* subkey,
+ LONG CreateWithDisposition(HKEY rootkey, const wchar_t* subkey,
DWORD* disposition, REGSAM access);
- GONG Open(HKEY rootkey, const wchar_t* subkey, REGSAM access);
+ LONG Open(HKEY rootkey, const wchar_t* subkey, REGSAM access);
// Creates a subkey or open it if it already exists.
- GONG CreateKey(const wchar_t* name, REGSAM access);
+ LONG CreateKey(const wchar_t* name, REGSAM access);
// Opens a subkey
- GONG OpenKey(const wchar_t* name, REGSAM access);
+ LONG OpenKey(const wchar_t* name, REGSAM access);
void Close();
DWORD ValueCount() const;
// Determine the nth value's name.
- GONG ReadName(int index, std::wstring* name) const;
+ LONG ReadName(int index, std::wstring* name) const;
// True while the key is valid.
bool Valid() const { return key_ != NULL; }
// Kill a key and everything that live below it; please be careful when using
// it.
- GONG DeleteKey(const wchar_t* name);
+ LONG DeleteKey(const wchar_t* name);
// Deletes a single value within the key.
- GONG DeleteValue(const wchar_t* name);
+ LONG DeleteValue(const wchar_t* name);
bool ValueExists(const wchar_t* name) const;
- GONG ReadValue(const wchar_t* name, void* data, DWORD* dsize,
+ LONG ReadValue(const wchar_t* name, void* data, DWORD* dsize,
DWORD* dtype) const;
- GONG ReadValue(const wchar_t* name, std::wstring* value) const;
- GONG ReadValueDW(const wchar_t* name, DWORD* value) const;
- GONG ReadInt64(const wchar_t* name, int64* value) const;
+ LONG ReadValue(const wchar_t* name, std::wstring* value) const;
+ LONG ReadValueDW(const wchar_t* name, DWORD* value) const;
+ LONG ReadInt64(const wchar_t* name, int64* value) const;
- GONG WriteValue(const wchar_t* name, const void* data, DWORD dsize,
+ LONG WriteValue(const wchar_t* name, const void* data, DWORD dsize,
DWORD dtype);
- GONG WriteValue(const wchar_t* name, const wchar_t* value);
- GONG WriteValue(const wchar_t* name, DWORD value);
+ LONG WriteValue(const wchar_t* name, const wchar_t* value);
+ LONG WriteValue(const wchar_t* name, DWORD value);
// 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.
- GONG StartWatching();
+ LONG StartWatching();
// If StartWatching hasn't been called, always returns false.
// Otherwise, returns true if anything under the key has changed.
@@ -114,7 +81,7 @@ class RegKey {
// Will automatically be called by destructor if not manually called
// beforehand. Returns true if it was watching, false otherwise.
- GONG StopWatching();
+ LONG StopWatching();
inline bool IsWatching() const { return watch_event_ != 0; }
HANDLE watch_event() const { return watch_event_; }