| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/api/prefs/pref_change_registrar.h" | 5 #include "chrome/browser/api/prefs/pref_change_registrar.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/api/prefs/pref_service_base.h" |
| 9 | 9 |
| 10 PrefChangeRegistrar::PrefChangeRegistrar() : service_(NULL) {} | 10 PrefChangeRegistrar::PrefChangeRegistrar() : service_(NULL) {} |
| 11 | 11 |
| 12 PrefChangeRegistrar::~PrefChangeRegistrar() { | 12 PrefChangeRegistrar::~PrefChangeRegistrar() { |
| 13 // If you see an invalid memory access in this destructor, this | 13 // If you see an invalid memory access in this destructor, this |
| 14 // PrefChangeRegistrar might be subscribed to an OffTheRecordProfileImpl that | 14 // PrefChangeRegistrar might be subscribed to an OffTheRecordProfileImpl that |
| 15 // has been destroyed. This should not happen any more but be warned. | 15 // has been destroyed. This should not happen any more but be warned. |
| 16 // Feel free to contact battre@chromium.org in case this happens. | 16 // Feel free to contact battre@chromium.org in case this happens. |
| 17 RemoveAll(); | 17 RemoveAll(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 void PrefChangeRegistrar::Init(PrefService* service) { | 20 void PrefChangeRegistrar::Init(PrefServiceBase* service) { |
| 21 DCHECK(IsEmpty() || service_ == service); | 21 DCHECK(IsEmpty() || service_ == service); |
| 22 service_ = service; | 22 service_ = service; |
| 23 } | 23 } |
| 24 | 24 |
| 25 void PrefChangeRegistrar::Add(const char* path, | 25 void PrefChangeRegistrar::Add(const char* path, |
| 26 content::NotificationObserver* obs) { | 26 content::NotificationObserver* obs) { |
| 27 if (!service_) { | 27 if (!service_) { |
| 28 NOTREACHED(); | 28 NOTREACHED(); |
| 29 return; | 29 return; |
| 30 } | 30 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 60 it != observers_.end(); ++it) { | 60 it != observers_.end(); ++it) { |
| 61 service_->RemovePrefObserver(it->first.c_str(), it->second); | 61 service_->RemovePrefObserver(it->first.c_str(), it->second); |
| 62 } | 62 } |
| 63 observers_.clear(); | 63 observers_.clear(); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool PrefChangeRegistrar::IsEmpty() const { | 67 bool PrefChangeRegistrar::IsEmpty() const { |
| 68 return observers_.empty(); | 68 return observers_.empty(); |
| 69 } | 69 } |
| OLD | NEW |