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

Unified Diff: ios/chrome/browser/browser_state/browser_state_info_cache.cc

Issue 2884933002: Remove raw base::DictionaryValue::SetWithoutPathExpansion (Closed)
Patch Set: Include Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/browser_state/browser_state_info_cache.h ('k') | ipc/ipc_message_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/browser_state/browser_state_info_cache.cc
diff --git a/ios/chrome/browser/browser_state/browser_state_info_cache.cc b/ios/chrome/browser/browser_state/browser_state_info_cache.cc
index 28041e9145997f46e981daa4ade72aa337858029..7972b0614eb5e85eb44a66083d761a6676bb98b5 100644
--- a/ios/chrome/browser/browser_state/browser_state_info_cache.cc
+++ b/ios/chrome/browser/browser_state/browser_state_info_cache.cc
@@ -8,9 +8,11 @@
#include <algorithm>
#include <memory>
+#include <utility>
#include "base/i18n/case_conversion.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/scoped_user_pref_update.h"
@@ -51,7 +53,7 @@ void BrowserStateInfoCache::AddBrowserState(
std::unique_ptr<base::DictionaryValue> info(new base::DictionaryValue);
info->SetString(kGAIAIdKey, gaia_id);
info->SetString(kUserNameKey, user_name);
- cache->SetWithoutPathExpansion(key, info.release());
+ cache->SetWithoutPathExpansion(key, std::move(info));
AddBrowserStateCacheKey(key);
for (auto& observer : observer_list_)
@@ -147,14 +149,13 @@ void BrowserStateInfoCache::SetAuthInfoOfBrowserStateAtIndex(
return;
}
- std::unique_ptr<base::DictionaryValue> info(
- GetInfoForBrowserStateAtIndex(index)->DeepCopy());
+ auto info = base::MakeUnique<base::DictionaryValue>(
+ *GetInfoForBrowserStateAtIndex(index));
info->SetString(kGAIAIdKey, gaia_id);
info->SetString(kUserNameKey, user_name);
- // This takes ownership of |info|.
- SetInfoForBrowserStateAtIndex(index, info.release());
+ SetInfoForBrowserStateAtIndex(index, std::move(info));
}
void BrowserStateInfoCache::SetBrowserStateIsAuthErrorAtIndex(size_t index,
@@ -162,11 +163,10 @@ void BrowserStateInfoCache::SetBrowserStateIsAuthErrorAtIndex(size_t index,
if (value == BrowserStateIsAuthErrorAtIndex(index))
return;
- std::unique_ptr<base::DictionaryValue> info(
- GetInfoForBrowserStateAtIndex(index)->DeepCopy());
+ auto info = base::MakeUnique<base::DictionaryValue>(
+ *GetInfoForBrowserStateAtIndex(index));
info->SetBoolean(kIsAuthErrorKey, value);
- // This takes ownership of |info|.
- SetInfoForBrowserStateAtIndex(index, info.release());
+ SetInfoForBrowserStateAtIndex(index, std::move(info));
}
const base::FilePath& BrowserStateInfoCache::GetUserDataDir() const {
@@ -190,10 +190,10 @@ BrowserStateInfoCache::GetInfoForBrowserStateAtIndex(size_t index) const {
void BrowserStateInfoCache::SetInfoForBrowserStateAtIndex(
size_t index,
- base::DictionaryValue* info) {
+ std::unique_ptr<base::DictionaryValue> info) {
DictionaryPrefUpdate update(prefs_, prefs::kBrowserStateInfoCache);
base::DictionaryValue* cache = update.Get();
- cache->SetWithoutPathExpansion(sorted_keys_[index], info);
+ cache->SetWithoutPathExpansion(sorted_keys_[index], std::move(info));
}
std::string BrowserStateInfoCache::CacheKeyFromBrowserStatePath(
« no previous file with comments | « ios/chrome/browser/browser_state/browser_state_info_cache.h ('k') | ipc/ipc_message_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698