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

Side by Side Diff: components/content_settings/core/browser/content_settings_pref.cc

Issue 1076153002: Coverting std::String() to ResourceIdentifier() in content_settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/content_settings/core/browser/content_settings_pref.h" 5 #include "components/content_settings/core/browser/content_settings_pref.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 DCHECK(prefs_); 155 DCHECK(prefs_);
156 156
157 OriginIdentifierValueMap* map_to_modify = &incognito_value_map_; 157 OriginIdentifierValueMap* map_to_modify = &incognito_value_map_;
158 if (!is_incognito_) 158 if (!is_incognito_)
159 map_to_modify = &value_map_; 159 map_to_modify = &value_map_;
160 160
161 std::vector<Rule> rules_to_delete; 161 std::vector<Rule> rules_to_delete;
162 { 162 {
163 base::AutoLock auto_lock(lock_); 163 base::AutoLock auto_lock(lock_);
164 scoped_ptr<RuleIterator> rule_iterator( 164 scoped_ptr<RuleIterator> rule_iterator(
165 map_to_modify->GetRuleIterator(content_type_, std::string(), NULL)); 165 map_to_modify->GetRuleIterator(content_type_,
166 ResourceIdentifier(),
167 NULL));
166 // Copy the rules; we cannot call |UpdatePref| while holding |lock_|. 168 // Copy the rules; we cannot call |UpdatePref| while holding |lock_|.
167 while (rule_iterator->HasNext()) 169 while (rule_iterator->HasNext())
168 rules_to_delete.push_back(rule_iterator->Next()); 170 rules_to_delete.push_back(rule_iterator->Next());
169 171
170 map_to_modify->DeleteValues(content_type_, std::string()); 172 map_to_modify->DeleteValues(content_type_, ResourceIdentifier());
171 } 173 }
172 174
173 for (std::vector<Rule>::const_iterator it = rules_to_delete.begin(); 175 for (std::vector<Rule>::const_iterator it = rules_to_delete.begin();
174 it != rules_to_delete.end(); ++it) { 176 it != rules_to_delete.end(); ++it) {
175 UpdatePref(it->primary_pattern, 177 UpdatePref(it->primary_pattern,
176 it->secondary_pattern, 178 it->secondary_pattern,
177 std::string(), 179 ResourceIdentifier(),
178 NULL); 180 NULL);
179 if (IsContentSettingsTypeSyncable(content_type_)) { 181 if (IsContentSettingsTypeSyncable(content_type_)) {
180 UpdateOldPref(it->primary_pattern, 182 UpdateOldPref(it->primary_pattern,
181 it->secondary_pattern, 183 it->secondary_pattern,
182 std::string(), 184 ResourceIdentifier(),
183 NULL); 185 NULL);
184 } 186 }
185 } 187 }
186 notify_callback_.Run(ContentSettingsPattern(), 188 notify_callback_.Run(ContentSettingsPattern(),
187 ContentSettingsPattern(), 189 ContentSettingsPattern(),
188 content_type_, 190 content_type_,
189 std::string()); 191 ResourceIdentifier());
190 } 192 }
191 193
192 void ContentSettingsPref::UpdateLastUsage( 194 void ContentSettingsPref::UpdateLastUsage(
193 const ContentSettingsPattern& primary_pattern, 195 const ContentSettingsPattern& primary_pattern,
194 const ContentSettingsPattern& secondary_pattern, 196 const ContentSettingsPattern& secondary_pattern,
195 base::Clock* clock) { 197 base::Clock* clock) {
196 // Don't write if in incognito. 198 // Don't write if in incognito.
197 if (is_incognito_) { 199 if (is_incognito_) {
198 return; 200 return;
199 } 201 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 DCHECK(thread_checker_.CalledOnValidThread()); 411 DCHECK(thread_checker_.CalledOnValidThread());
410 412
411 if (updating_preferences_) 413 if (updating_preferences_)
412 return; 414 return;
413 415
414 ReadContentSettingsFromPrefAndWriteToOldPref(); 416 ReadContentSettingsFromPrefAndWriteToOldPref();
415 417
416 notify_callback_.Run(ContentSettingsPattern(), 418 notify_callback_.Run(ContentSettingsPattern(),
417 ContentSettingsPattern(), 419 ContentSettingsPattern(),
418 content_type_, 420 content_type_,
419 std::string()); 421 ResourceIdentifier());
420 } 422 }
421 423
422 void ContentSettingsPref::UpdatePref( 424 void ContentSettingsPref::UpdatePref(
423 const ContentSettingsPattern& primary_pattern, 425 const ContentSettingsPattern& primary_pattern,
424 const ContentSettingsPattern& secondary_pattern, 426 const ContentSettingsPattern& secondary_pattern,
425 const ResourceIdentifier& resource_identifier, 427 const ResourceIdentifier& resource_identifier,
426 const base::Value* value) { 428 const base::Value* value) {
427 // Ensure that |lock_| is not held by this thread, since this function will 429 // Ensure that |lock_| is not held by this thread, since this function will
428 // send out notifications (by |~DictionaryPrefUpdate|). 430 // send out notifications (by |~DictionaryPrefUpdate|).
429 AssertLockNotHeld(); 431 AssertLockNotHeld();
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 671
670 void ContentSettingsPref::AssertLockNotHeld() const { 672 void ContentSettingsPref::AssertLockNotHeld() const {
671 #if !defined(NDEBUG) 673 #if !defined(NDEBUG)
672 // |Lock::Acquire()| will assert if the lock is held by this thread. 674 // |Lock::Acquire()| will assert if the lock is held by this thread.
673 lock_.Acquire(); 675 lock_.Acquire();
674 lock_.Release(); 676 lock_.Release();
675 #endif 677 #endif
676 } 678 }
677 679
678 } // namespace content_settings 680 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698