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

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

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

Powered by Google App Engine
This is Rietveld 408576698