OLD | NEW |
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 "chrome/browser/content_settings/content_settings_pref_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_pref_provider.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 PersistentPrefStore* user_prefs = new TestingPrefStore(); | 133 PersistentPrefStore* user_prefs = new TestingPrefStore(); |
134 OverlayUserPrefStore* otr_user_prefs = | 134 OverlayUserPrefStore* otr_user_prefs = |
135 new OverlayUserPrefStore(user_prefs); | 135 new OverlayUserPrefStore(user_prefs); |
136 | 136 |
137 PrefServiceMockBuilder builder; | 137 PrefServiceMockBuilder builder; |
138 builder.WithUserPrefs(user_prefs); | 138 builder.WithUserPrefs(user_prefs); |
139 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( | 139 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( |
140 new user_prefs::PrefRegistrySyncable); | 140 new user_prefs::PrefRegistrySyncable); |
141 PrefServiceSyncable* regular_prefs = builder.CreateSyncable(registry.get()); | 141 PrefServiceSyncable* regular_prefs = builder.CreateSyncable(registry.get()); |
142 | 142 |
143 chrome::RegisterUserPrefs(registry.get()); | 143 chrome::RegisterUserProfilePrefs(registry.get()); |
144 | 144 |
145 builder.WithUserPrefs(otr_user_prefs); | 145 builder.WithUserPrefs(otr_user_prefs); |
146 scoped_refptr<user_prefs::PrefRegistrySyncable> otr_registry( | 146 scoped_refptr<user_prefs::PrefRegistrySyncable> otr_registry( |
147 new user_prefs::PrefRegistrySyncable); | 147 new user_prefs::PrefRegistrySyncable); |
148 PrefServiceSyncable* otr_prefs = builder.CreateSyncable(otr_registry.get()); | 148 PrefServiceSyncable* otr_prefs = builder.CreateSyncable(otr_registry.get()); |
149 | 149 |
150 chrome::RegisterUserPrefs(otr_registry.get()); | 150 chrome::RegisterUserProfilePrefs(otr_registry.get()); |
151 | 151 |
152 TestingProfile::Builder profile_builder; | 152 TestingProfile::Builder profile_builder; |
153 profile_builder.SetPrefService(make_scoped_ptr(regular_prefs)); | 153 profile_builder.SetPrefService(make_scoped_ptr(regular_prefs)); |
154 scoped_ptr<TestingProfile> profile = profile_builder.Build(); | 154 scoped_ptr<TestingProfile> profile = profile_builder.Build(); |
155 | 155 |
156 TestingProfile::Builder otr_profile_builder; | 156 TestingProfile::Builder otr_profile_builder; |
157 otr_profile_builder.SetPrefService(make_scoped_ptr(otr_prefs)); | 157 otr_profile_builder.SetPrefService(make_scoped_ptr(otr_prefs)); |
158 TestingProfile* otr_profile = otr_profile_builder.Build().release(); | 158 TestingProfile* otr_profile = otr_profile_builder.Build().release(); |
159 | 159 |
160 otr_profile->set_incognito(true); | 160 otr_profile->set_incognito(true); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 secondary_url, | 413 secondary_url, |
414 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | 414 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
415 std::string(), | 415 std::string(), |
416 false)); | 416 false)); |
417 provider.ShutdownOnUIThread(); | 417 provider.ShutdownOnUIThread(); |
418 } | 418 } |
419 | 419 |
420 // http://crosbug.com/17760 | 420 // http://crosbug.com/17760 |
421 TEST_F(PrefProviderTest, Deadlock) { | 421 TEST_F(PrefProviderTest, Deadlock) { |
422 TestingPrefServiceSyncable prefs; | 422 TestingPrefServiceSyncable prefs; |
423 PrefProvider::RegisterUserPrefs(prefs.registry()); | 423 PrefProvider::RegisterProfilePrefs(prefs.registry()); |
424 | 424 |
425 // Chain of events: a preference changes, |PrefProvider| notices it, and reads | 425 // Chain of events: a preference changes, |PrefProvider| notices it, and reads |
426 // and writes the preference. When the preference is written, a notification | 426 // and writes the preference. When the preference is written, a notification |
427 // is sent, and this used to happen when |PrefProvider| was still holding its | 427 // is sent, and this used to happen when |PrefProvider| was still holding its |
428 // lock. | 428 // lock. |
429 | 429 |
430 PrefProvider provider(&prefs, false); | 430 PrefProvider provider(&prefs, false); |
431 DeadlockCheckerObserver observer(&prefs, &provider); | 431 DeadlockCheckerObserver observer(&prefs, &provider); |
432 { | 432 { |
433 DictionaryPrefUpdate update(&prefs, | 433 DictionaryPrefUpdate update(&prefs, |
434 prefs::kContentSettingsPatternPairs); | 434 prefs::kContentSettingsPatternPairs); |
435 DictionaryValue* mutable_settings = update.Get(); | 435 DictionaryValue* mutable_settings = update.Get(); |
436 mutable_settings->SetWithoutPathExpansion("www.example.com,*", | 436 mutable_settings->SetWithoutPathExpansion("www.example.com,*", |
437 new base::DictionaryValue()); | 437 new base::DictionaryValue()); |
438 } | 438 } |
439 EXPECT_TRUE(observer.notification_received()); | 439 EXPECT_TRUE(observer.notification_received()); |
440 | 440 |
441 provider.ShutdownOnUIThread(); | 441 provider.ShutdownOnUIThread(); |
442 } | 442 } |
443 | 443 |
444 } // namespace content_settings | 444 } // namespace content_settings |
OLD | NEW |