| 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 "components/content_settings/core/browser/content_settings_pref_provide
r.h" | 5 #include "components/content_settings/core/browser/content_settings_pref_provide
r.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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // A helper for observing an preference changes and testing whether | 58 // A helper for observing an preference changes and testing whether |
| 59 // |PrefProvider| holds a lock when the preferences change. | 59 // |PrefProvider| holds a lock when the preferences change. |
| 60 class DeadlockCheckerObserver { | 60 class DeadlockCheckerObserver { |
| 61 public: | 61 public: |
| 62 // |DeadlockCheckerObserver| doesn't take the ownership of |prefs| or | 62 // |DeadlockCheckerObserver| doesn't take the ownership of |prefs| or |
| 63 // |provider|. | 63 // |provider|. |
| 64 DeadlockCheckerObserver(PrefService* prefs, PrefProvider* provider) | 64 DeadlockCheckerObserver(PrefService* prefs, PrefProvider* provider) |
| 65 : provider_(provider), | 65 : provider_(provider), |
| 66 notification_received_(false) { | 66 notification_received_(false) { |
| 67 pref_change_registrar_.Init(prefs); | 67 pref_change_registrar_.Init(prefs); |
| 68 for (ContentSettingsPref* pref : provider_->content_settings_prefs_) { | 68 for (const auto& pair : provider_->content_settings_prefs_) { |
| 69 const ContentSettingsPref* pref = pair.second; |
| 69 pref_change_registrar_.Add( | 70 pref_change_registrar_.Add( |
| 70 pref->pref_name_, | 71 pref->pref_name_, |
| 71 base::Bind( | 72 base::Bind( |
| 72 &DeadlockCheckerObserver::OnContentSettingsPatternPairsChanged, | 73 &DeadlockCheckerObserver::OnContentSettingsPatternPairsChanged, |
| 73 base::Unretained(this), base::Unretained(pref))); | 74 base::Unretained(this), base::Unretained(pref))); |
| 74 } | 75 } |
| 75 } | 76 } |
| 76 virtual ~DeadlockCheckerObserver() {} | 77 virtual ~DeadlockCheckerObserver() {} |
| 77 | 78 |
| 78 bool notification_received() const { | 79 bool notification_received() const { |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 for (const char* pref : nonempty_prefs) { | 618 for (const char* pref : nonempty_prefs) { |
| 618 DictionaryPrefUpdate update(&prefs, pref); | 619 DictionaryPrefUpdate update(&prefs, pref); |
| 619 const base::DictionaryValue* dictionary = update.Get(); | 620 const base::DictionaryValue* dictionary = update.Get(); |
| 620 EXPECT_EQ(1u, dictionary->size()); | 621 EXPECT_EQ(1u, dictionary->size()); |
| 621 } | 622 } |
| 622 | 623 |
| 623 provider.ShutdownOnUIThread(); | 624 provider.ShutdownOnUIThread(); |
| 624 } | 625 } |
| 625 | 626 |
| 626 } // namespace content_settings | 627 } // namespace content_settings |
| OLD | NEW |