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

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

Issue 2587883003: Revert of Force HostContentSettingsMap to be destroyed on its owning thread. (Closed)
Patch Set: Created 3 years, 12 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/host_content_settings_map.h" 5 #include "components/content_settings/core/browser/host_content_settings_map.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/threading/thread_task_runner_handle.h"
18 #include "base/time/clock.h" 17 #include "base/time/clock.h"
19 #include "build/build_config.h" 18 #include "build/build_config.h"
20 #include "components/content_settings/core/browser/content_settings_default_prov ider.h" 19 #include "components/content_settings/core/browser/content_settings_default_prov ider.h"
21 #include "components/content_settings/core/browser/content_settings_details.h" 20 #include "components/content_settings/core/browser/content_settings_details.h"
22 #include "components/content_settings/core/browser/content_settings_info.h" 21 #include "components/content_settings/core/browser/content_settings_info.h"
23 #include "components/content_settings/core/browser/content_settings_observable_p rovider.h" 22 #include "components/content_settings/core/browser/content_settings_observable_p rovider.h"
24 #include "components/content_settings/core/browser/content_settings_policy_provi der.h" 23 #include "components/content_settings/core/browser/content_settings_policy_provi der.h"
25 #include "components/content_settings/core/browser/content_settings_pref_provide r.h" 24 #include "components/content_settings/core/browser/content_settings_pref_provide r.h"
26 #include "components/content_settings/core/browser/content_settings_provider.h" 25 #include "components/content_settings/core/browser/content_settings_provider.h"
27 #include "components/content_settings/core/browser/content_settings_registry.h" 26 #include "components/content_settings/core/browser/content_settings_registry.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 content_settings::PatternPair patterns = GetPatternsFromScopingType( 171 content_settings::PatternPair patterns = GetPatternsFromScopingType(
173 website_settings_info->scoping_type(), primary_url, secondary_url); 172 website_settings_info->scoping_type(), primary_url, secondary_url);
174 return patterns; 173 return patterns;
175 } 174 }
176 175
177 } // namespace 176 } // namespace
178 177
179 HostContentSettingsMap::HostContentSettingsMap(PrefService* prefs, 178 HostContentSettingsMap::HostContentSettingsMap(PrefService* prefs,
180 bool is_incognito_profile, 179 bool is_incognito_profile,
181 bool is_guest_profile) 180 bool is_guest_profile)
182 : RefcountedKeyedService(base::ThreadTaskRunnerHandle::Get()), 181 :
183 #ifndef NDEBUG 182 #ifndef NDEBUG
184 used_from_thread_id_(base::PlatformThread::CurrentId()), 183 used_from_thread_id_(base::PlatformThread::CurrentId()),
185 #endif 184 #endif
186 prefs_(prefs), 185 prefs_(prefs),
187 is_incognito_(is_incognito_profile || is_guest_profile), 186 is_incognito_(is_incognito_profile || is_guest_profile),
188 weak_ptr_factory_(this) { 187 weak_ptr_factory_(this) {
189 DCHECK(!(is_incognito_profile && is_guest_profile)); 188 DCHECK(!(is_incognito_profile && is_guest_profile));
190 189
191 content_settings::PolicyProvider* policy_provider = 190 content_settings::PolicyProvider* policy_provider =
192 new content_settings::PolicyProvider(prefs_); 191 new content_settings::PolicyProvider(prefs_);
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 const ContentSettingsPattern& secondary_pattern, 820 const ContentSettingsPattern& secondary_pattern,
822 ContentSettingsType content_type, 821 ContentSettingsType content_type,
823 std::string resource_identifier) { 822 std::string resource_identifier) {
824 for (content_settings::Observer& observer : observers_) { 823 for (content_settings::Observer& observer : observers_) {
825 observer.OnContentSettingChanged(primary_pattern, secondary_pattern, 824 observer.OnContentSettingChanged(primary_pattern, secondary_pattern,
826 content_type, resource_identifier); 825 content_type, resource_identifier);
827 } 826 }
828 } 827 }
829 828
830 HostContentSettingsMap::~HostContentSettingsMap() { 829 HostContentSettingsMap::~HostContentSettingsMap() {
831 DCHECK(thread_checker_.CalledOnValidThread());
832 DCHECK(!prefs_); 830 DCHECK(!prefs_);
833 } 831 }
834 832
835 void HostContentSettingsMap::ShutdownOnUIThread() { 833 void HostContentSettingsMap::ShutdownOnUIThread() {
836 DCHECK(thread_checker_.CalledOnValidThread()); 834 DCHECK(thread_checker_.CalledOnValidThread());
837 DCHECK(prefs_); 835 DCHECK(prefs_);
838 prefs_ = NULL; 836 prefs_ = NULL;
839 for (const auto& provider_pair : content_settings_providers_) 837 for (const auto& provider_pair : content_settings_providers_)
840 provider_pair.second->ShutdownOnUIThread(); 838 provider_pair.second->ShutdownOnUIThread();
841 } 839 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 if (primary_pattern) 1021 if (primary_pattern)
1024 *primary_pattern = rule.primary_pattern; 1022 *primary_pattern = rule.primary_pattern;
1025 if (secondary_pattern) 1023 if (secondary_pattern)
1026 *secondary_pattern = rule.secondary_pattern; 1024 *secondary_pattern = rule.secondary_pattern;
1027 return base::WrapUnique(rule.value.get()->DeepCopy()); 1025 return base::WrapUnique(rule.value.get()->DeepCopy());
1028 } 1026 }
1029 } 1027 }
1030 } 1028 }
1031 return std::unique_ptr<base::Value>(); 1029 return std::unique_ptr<base::Value>();
1032 } 1030 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698