diff options
author | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-10 00:53:47 +0000 |
---|---|---|
committer | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-10 00:53:47 +0000 |
commit | d9b0b8cf7f951cc0e65dfc723ef5df4ff48693ac (patch) | |
tree | 2c7f032e20446fceb4440b31522518ea87348a0c /chrome/installer/util/registry_key_backup.cc | |
parent | 3e873e5a0e9288abba9af8419ee29d8e8a708f73 (diff) | |
download | chromium_src-d9b0b8cf7f951cc0e65dfc723ef5df4ff48693ac.zip chromium_src-d9b0b8cf7f951cc0e65dfc723ef5df4ff48693ac.tar.gz chromium_src-d9b0b8cf7f951cc0e65dfc723ef5df4ff48693ac.tar.bz2 |
C++ Readability for grt.
Added CopyRegKeyWorkItem in support of IE low rights policy fixes. In so doing, I pulled RegistryKeyBackup out of DeleteRegKeyWorkItem (which I wrote back in http://codereview.chromium.org/6598065) so it could be shared between the two work items. registry_test_data is, as the name implies, some infrastructure shared among a few unit tests.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7946003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104688 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/registry_key_backup.cc')
-rw-r--r-- | chrome/installer/util/registry_key_backup.cc | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/chrome/installer/util/registry_key_backup.cc b/chrome/installer/util/registry_key_backup.cc index 93734b3..e3494614 100644 --- a/chrome/installer/util/registry_key_backup.cc +++ b/chrome/installer/util/registry_key_backup.cc @@ -22,16 +22,32 @@ class RegistryKeyBackup::KeyData { public: KeyData(); ~KeyData(); + + // Initializes this object by reading the values and subkeys of |key|. + // Security descriptors are not backed up. Returns true if the operation was + // successful; false otherwise, in which case the state of this object is not + // modified. bool Initialize(const RegKey& key); + + // Writes the contents of this object to |key|, which must have been opened + // with at least REG_SET_VALUE and KEY_CREATE_SUB_KEY access rights. Returns + // true if the operation was successful; false otherwise, in which case the + // contents of |key| may have been modified. bool WriteTo(RegKey* key) const; private: class ValueData; + // The values of this key. scoped_array<ValueData> values_; + // The names of this key's sub-keys (the data for subkey_names_[i] is in + // subkeys_[i]). scoped_array<std::wstring> subkey_names_; + // The key data of this key's sub-keys. scoped_array<KeyData> subkeys_; + // The number of values for this key. DWORD num_values_; + // The number of subkeys for this key. DWORD num_subkeys_; DISALLOW_COPY_AND_ASSIGN(KeyData); @@ -42,17 +58,35 @@ class RegistryKeyBackup::KeyData::ValueData { public: ValueData(); ~ValueData(); + + // Initializes this object with a name (the first |name_size| characters in + // |name_buffer|, |type|, and data (the first |data_size| bytes in |data|). void Initialize(const wchar_t* name_buffer, DWORD name_size, DWORD type, const uint8* data, DWORD data_size); + + // The possibly empty name of this value. const std::wstring& name_str() const { return name_; } + + // The name of this value, or NULL for the default (unnamed) value. const wchar_t* name() const { return name_.empty() ? NULL : name_.c_str(); } + + // The type of this value. DWORD type() const { return type_; } + + // A pointer to a buffer of |data_len()| bytes containing the value's data, + // or NULL if the value has no data. const uint8* data() const { return data_.empty() ? NULL : &data_[0]; } + + // The size, in bytes, of the value's data. DWORD data_len() const { return static_cast<DWORD>(data_.size()); } private: + // This value's name, or the empty string if this is the default (unnamed) + // value. std::wstring name_; + // This value's data. std::vector<uint8> data_; + // This value's type (e.g., REG_DWORD, REG_SZ, REG_QWORD, etc). DWORD type_; DISALLOW_COPY_AND_ASSIGN(ValueData); @@ -86,8 +120,6 @@ RegistryKeyBackup::KeyData::~KeyData() { } -// Initializes this object by reading the values and subkeys of |key|. -// Security descriptors are not backed up. bool RegistryKeyBackup::KeyData::Initialize(const RegKey& key) { scoped_array<ValueData> values; scoped_array<std::wstring> subkey_names; @@ -229,7 +261,6 @@ bool RegistryKeyBackup::KeyData::Initialize(const RegKey& key) { return true; } -// Writes the values and subkeys of this object into |key|. bool RegistryKeyBackup::KeyData::WriteTo(RegKey* key) const { DCHECK(key); |