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

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

Issue 598173003: Run clang-modernize -use-nullptr over src/extensions/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 "content/public/browser/browser_context.h" 7 #include "content/public/browser/browser_context.h"
8 #include "content/public/browser/notification_details.h" 8 #include "content/public/browser/notification_details.h"
9 #include "content/public/browser/notification_source.h" 9 #include "content/public/browser/notification_source.h"
10 #include "extensions/browser/api/declarative/rules_registry.h" 10 #include "extensions/browser/api/declarative/rules_registry.h"
(...skipping 19 matching lines...) Expand all
30 } // namespace 30 } // namespace
31 31
32 namespace extensions { 32 namespace extensions {
33 33
34 // RulesCacheDelegate 34 // RulesCacheDelegate
35 35
36 const char RulesCacheDelegate::kRulesStoredKey[] = 36 const char RulesCacheDelegate::kRulesStoredKey[] =
37 "has_declarative_rules"; 37 "has_declarative_rules";
38 38
39 RulesCacheDelegate::RulesCacheDelegate(bool log_storage_init_delay) 39 RulesCacheDelegate::RulesCacheDelegate(bool log_storage_init_delay)
40 : browser_context_(NULL), 40 : browser_context_(nullptr),
41 log_storage_init_delay_(log_storage_init_delay), 41 log_storage_init_delay_(log_storage_init_delay),
42 notified_registry_(false), 42 notified_registry_(false),
43 weak_ptr_factory_(this) { 43 weak_ptr_factory_(this) {
44 } 44 }
45 45
46 RulesCacheDelegate::~RulesCacheDelegate() {} 46 RulesCacheDelegate::~RulesCacheDelegate() {}
47 47
48 // Returns the key to use for storing whether the rules have been stored. 48 // Returns the key to use for storing whether the rules have been stored.
49 // static 49 // static
50 std::string RulesCacheDelegate::GetRulesStoredKey(const std::string& event_name, 50 std::string RulesCacheDelegate::GetRulesStoredKey(const std::string& event_name,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 base::Bind(&RulesCacheDelegate::CheckIfReady, 90 base::Bind(&RulesCacheDelegate::CheckIfReady,
91 weak_ptr_factory_.GetWeakPtr())); 91 weak_ptr_factory_.GetWeakPtr()));
92 } 92 }
93 93
94 void RulesCacheDelegate::WriteToStorage(const std::string& extension_id, 94 void RulesCacheDelegate::WriteToStorage(const std::string& extension_id,
95 scoped_ptr<base::Value> value) { 95 scoped_ptr<base::Value> value) {
96 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 96 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
97 if (!browser_context_) 97 if (!browser_context_)
98 return; 98 return;
99 99
100 const base::ListValue* rules = NULL; 100 const base::ListValue* rules = nullptr;
101 CHECK(value->GetAsList(&rules)); 101 CHECK(value->GetAsList(&rules));
102 bool rules_stored_previously = GetDeclarativeRulesStored(extension_id); 102 bool rules_stored_previously = GetDeclarativeRulesStored(extension_id);
103 bool store_rules = !rules->empty(); 103 bool store_rules = !rules->empty();
104 SetDeclarativeRulesStored(extension_id, store_rules); 104 SetDeclarativeRulesStored(extension_id, store_rules);
105 if (!rules_stored_previously && !store_rules) 105 if (!rules_stored_previously && !store_rules)
106 return; 106 return;
107 107
108 StateStore* store = ExtensionSystem::Get(browser_context_)->rules_store(); 108 StateStore* store = ExtensionSystem::Get(browser_context_)->rules_store();
109 if (store) 109 if (store)
110 store->SetExtensionValue(extension_id, storage_key_, value.Pass()); 110 store->SetExtensionValue(extension_id, storage_key_, value.Pass());
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING)); 221 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING));
222 222
223 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(browser_context_); 223 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(browser_context_);
224 extension_prefs->UpdateExtensionPref( 224 extension_prefs->UpdateExtensionPref(
225 extension_id, 225 extension_id,
226 rules_stored_key_, 226 rules_stored_key_,
227 new base::FundamentalValue(rules_stored)); 227 new base::FundamentalValue(rules_stored));
228 } 228 }
229 229
230 } // namespace extensions 230 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698