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

Side by Side Diff: extensions/browser/api/declarative/rules_cache_delegate.cc

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "extensions/browser/api/declarative/rules_cache_delegate.h" 5 #include "extensions/browser/api/declarative/rules_cache_delegate.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "content/public/browser/browser_context.h" 9 #include "content/public/browser/browser_context.h"
10 #include "content/public/browser/notification_details.h" 10 #include "content/public/browser/notification_details.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 system.ready().Post( 87 system.ready().Post(
88 FROM_HERE, 88 FROM_HERE,
89 base::Bind(&RulesCacheDelegate::ReadRulesForInstalledExtensions, 89 base::Bind(&RulesCacheDelegate::ReadRulesForInstalledExtensions,
90 weak_ptr_factory_.GetWeakPtr())); 90 weak_ptr_factory_.GetWeakPtr()));
91 system.ready().Post(FROM_HERE, 91 system.ready().Post(FROM_HERE,
92 base::Bind(&RulesCacheDelegate::CheckIfReady, 92 base::Bind(&RulesCacheDelegate::CheckIfReady,
93 weak_ptr_factory_.GetWeakPtr())); 93 weak_ptr_factory_.GetWeakPtr()));
94 } 94 }
95 95
96 void RulesCacheDelegate::WriteToStorage(const std::string& extension_id, 96 void RulesCacheDelegate::WriteToStorage(const std::string& extension_id,
97 scoped_ptr<base::Value> value) { 97 std::unique_ptr<base::Value> value) {
98 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 98 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
99 if (!browser_context_) 99 if (!browser_context_)
100 return; 100 return;
101 101
102 const base::ListValue* rules = NULL; 102 const base::ListValue* rules = NULL;
103 CHECK(value->GetAsList(&rules)); 103 CHECK(value->GetAsList(&rules));
104 bool rules_stored_previously = GetDeclarativeRulesStored(extension_id); 104 bool rules_stored_previously = GetDeclarativeRulesStored(extension_id);
105 bool store_rules = !rules->empty(); 105 bool store_rules = !rules->empty();
106 SetDeclarativeRulesStored(extension_id, store_rules); 106 SetDeclarativeRulesStored(extension_id, store_rules);
107 if (!rules_stored_previously && !store_rules) 107 if (!rules_stored_previously && !store_rules)
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 store->GetExtensionValue( 174 store->GetExtensionValue(
175 extension_id, 175 extension_id,
176 storage_key_, 176 storage_key_,
177 base::Bind(&RulesCacheDelegate::ReadFromStorageCallback, 177 base::Bind(&RulesCacheDelegate::ReadFromStorageCallback,
178 weak_ptr_factory_.GetWeakPtr(), 178 weak_ptr_factory_.GetWeakPtr(),
179 extension_id)); 179 extension_id));
180 } 180 }
181 181
182 void RulesCacheDelegate::ReadFromStorageCallback( 182 void RulesCacheDelegate::ReadFromStorageCallback(
183 const std::string& extension_id, 183 const std::string& extension_id,
184 scoped_ptr<base::Value> value) { 184 std::unique_ptr<base::Value> value) {
185 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 185 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
186 content::BrowserThread::PostTask( 186 content::BrowserThread::PostTask(
187 rules_registry_thread_, 187 rules_registry_thread_,
188 FROM_HERE, 188 FROM_HERE,
189 base::Bind(&RulesRegistry::DeserializeAndAddRules, 189 base::Bind(&RulesRegistry::DeserializeAndAddRules,
190 registry_, 190 registry_,
191 extension_id, 191 extension_id,
192 base::Passed(&value))); 192 base::Passed(&value)));
193 193
194 waiting_for_extensions_.erase(extension_id); 194 waiting_for_extensions_.erase(extension_id);
(...skipping 28 matching lines...) Expand all
223 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING)); 223 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING));
224 224
225 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(browser_context_); 225 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(browser_context_);
226 extension_prefs->UpdateExtensionPref( 226 extension_prefs->UpdateExtensionPref(
227 extension_id, 227 extension_id,
228 rules_stored_key_, 228 rules_stored_key_,
229 new base::FundamentalValue(rules_stored)); 229 new base::FundamentalValue(rules_stored));
230 } 230 }
231 231
232 } // namespace extensions 232 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/declarative/rules_cache_delegate.h ('k') | extensions/browser/api/declarative/rules_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698