Plugin Power Saver: Throttled Plugins should block TCPSocket reads.
[chromium-blink-merge.git] / google_apis / gaia / identity_provider.cc
blob842891e67f37d4f3600756806c9250abfcfb00b9
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "google_apis/gaia/identity_provider.h"
7 IdentityProvider::Observer::~Observer() {}
9 IdentityProvider::~IdentityProvider() {}
11 void IdentityProvider::AddActiveAccountRefreshTokenObserver(
12 OAuth2TokenService::Observer* observer) {
13 OAuth2TokenService* token_service = GetTokenService();
14 if (!token_service || token_service_observers_.HasObserver(observer))
15 return;
17 token_service_observers_.AddObserver(observer);
18 if (++token_service_observer_count_ == 1)
19 token_service->AddObserver(this);
22 void IdentityProvider::RemoveActiveAccountRefreshTokenObserver(
23 OAuth2TokenService::Observer* observer) {
24 OAuth2TokenService* token_service = GetTokenService();
25 if (!token_service || !token_service_observers_.HasObserver(observer))
26 return;
28 token_service_observers_.RemoveObserver(observer);
29 if (--token_service_observer_count_ == 0)
30 token_service->RemoveObserver(this);
33 void IdentityProvider::AddObserver(Observer* observer) {
34 observers_.AddObserver(observer);
37 void IdentityProvider::RemoveObserver(Observer* observer) {
38 observers_.RemoveObserver(observer);
41 void IdentityProvider::OnRefreshTokenAvailable(const std::string& account_id) {
42 if (account_id != GetActiveAccountId())
43 return;
44 FOR_EACH_OBSERVER(OAuth2TokenService::Observer,
45 token_service_observers_,
46 OnRefreshTokenAvailable(account_id));
49 void IdentityProvider::OnRefreshTokenRevoked(const std::string& account_id) {
50 if (account_id != GetActiveAccountId())
51 return;
52 FOR_EACH_OBSERVER(OAuth2TokenService::Observer,
53 token_service_observers_,
54 OnRefreshTokenRevoked(account_id));
57 void IdentityProvider::OnRefreshTokensLoaded() {
58 FOR_EACH_OBSERVER(OAuth2TokenService::Observer,
59 token_service_observers_,
60 OnRefreshTokensLoaded());
63 IdentityProvider::IdentityProvider() : token_service_observer_count_(0) {}
65 void IdentityProvider::FireOnActiveAccountLogin() {
66 FOR_EACH_OBSERVER(Observer, observers_, OnActiveAccountLogin());
69 void IdentityProvider::FireOnActiveAccountLogout() {
70 FOR_EACH_OBSERVER(Observer, observers_, OnActiveAccountLogout());