diff options
Diffstat (limited to 'chrome/browser/policy/device_token_fetcher.cc')
-rw-r--r-- | chrome/browser/policy/device_token_fetcher.cc | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/chrome/browser/policy/device_token_fetcher.cc b/chrome/browser/policy/device_token_fetcher.cc index 8f42544..678c90f 100644 --- a/chrome/browser/policy/device_token_fetcher.cc +++ b/chrome/browser/policy/device_token_fetcher.cc @@ -8,11 +8,11 @@ #include "base/path_service.h" #include "base/singleton.h" #include "base/string_util.h" -#include "chrome/browser/guid.h" #include "chrome/browser/net/gaia/token_service.h" #include "chrome/browser/policy/proto/device_management_local.pb.h" -#include "chrome/browser/profile.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_paths.h" +#include "chrome/common/guid.h" #include "chrome/common/net/gaia/gaia_constants.h" #include "chrome/common/notification_details.h" #include "chrome/common/notification_service.h" @@ -57,6 +57,31 @@ namespace policy { namespace em = enterprise_management; +DeviceTokenFetcher::ObserverRegistrar::ObserverRegistrar() {} + +DeviceTokenFetcher::ObserverRegistrar::~ObserverRegistrar() { + RemoveAll(); +} + +void DeviceTokenFetcher::ObserverRegistrar::Init( + DeviceTokenFetcher* token_fetcher) { + token_fetcher_ = token_fetcher; +} + +void DeviceTokenFetcher::ObserverRegistrar::AddObserver( + DeviceTokenFetcher::Observer* observer) { + observers_.push_back(observer); + token_fetcher_->AddObserver(observer); +} + +void DeviceTokenFetcher::ObserverRegistrar::RemoveAll() { + for (std::vector<DeviceTokenFetcher::Observer*>::iterator it = + observers_.begin(); it != observers_.end(); ++it) { + token_fetcher_->RemoveObserver(*it); + } + observers_.clear(); +} + DeviceTokenFetcher::DeviceTokenFetcher( DeviceManagementBackend* backend, Profile* profile, @@ -88,6 +113,8 @@ DeviceTokenFetcher::DeviceTokenFetcher( #endif } +DeviceTokenFetcher::~DeviceTokenFetcher() {} + void DeviceTokenFetcher::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { |