OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/chromeos/login/signin/merge_session_xhr_request_waiter.
h" | 5 #include "chrome/browser/chromeos/login/signin/merge_session_xhr_request_waiter.
h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 weak_ptr_factory_.GetWeakPtr()), | 52 weak_ptr_factory_.GetWeakPtr()), |
53 base::TimeDelta::FromMilliseconds(kMaxRequestWaitTimeMS)); | 53 base::TimeDelta::FromMilliseconds(kMaxRequestWaitTimeMS)); |
54 } else { | 54 } else { |
55 NotifyBlockingDone(); | 55 NotifyBlockingDone(); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 void MergeSessionXHRRequestWaiter::OnSessionRestoreStateChanged( | 59 void MergeSessionXHRRequestWaiter::OnSessionRestoreStateChanged( |
60 Profile* user_profile, | 60 Profile* user_profile, |
61 OAuth2LoginManager::SessionRestoreState state) { | 61 OAuth2LoginManager::SessionRestoreState state) { |
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 62 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
63 | 63 |
64 OAuth2LoginManager* manager = | 64 OAuth2LoginManager* manager = |
65 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(profile_); | 65 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(profile_); |
66 DVLOG(1) << "Merge session throttle should " | 66 DVLOG(1) << "Merge session throttle should " |
67 << (!manager->ShouldBlockTabLoading() ? | 67 << (!manager->ShouldBlockTabLoading() ? |
68 " NOT" : "") | 68 " NOT" : "") |
69 << " be blocking now, " | 69 << " be blocking now, " |
70 << state; | 70 << state; |
71 if (!manager->ShouldBlockTabLoading()) { | 71 if (!manager->ShouldBlockTabLoading()) { |
72 DVLOG(1) << "Unblocking XHR request throttle due to session merge"; | 72 DVLOG(1) << "Unblocking XHR request throttle due to session merge"; |
73 manager->RemoveObserver(this); | 73 manager->RemoveObserver(this); |
74 NotifyBlockingDone(); | 74 NotifyBlockingDone(); |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 void MergeSessionXHRRequestWaiter::OnTimeout() { | 78 void MergeSessionXHRRequestWaiter::OnTimeout() { |
79 DVLOG(1) << "Unblocking XHR request throttle due to timeout"; | 79 DVLOG(1) << "Unblocking XHR request throttle due to timeout"; |
80 NotifyBlockingDone(); | 80 NotifyBlockingDone(); |
81 } | 81 } |
82 | 82 |
83 void MergeSessionXHRRequestWaiter::NotifyBlockingDone() { | 83 void MergeSessionXHRRequestWaiter::NotifyBlockingDone() { |
84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 84 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
85 if (!callback_.is_null()) { | 85 if (!callback_.is_null()) { |
86 BrowserThread::PostTask( | 86 BrowserThread::PostTask( |
87 BrowserThread::IO, FROM_HERE, callback_); | 87 BrowserThread::IO, FROM_HERE, callback_); |
88 } | 88 } |
89 weak_ptr_factory_.InvalidateWeakPtrs(); | 89 weak_ptr_factory_.InvalidateWeakPtrs(); |
90 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 90 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
91 } | 91 } |
92 | 92 |
93 } // namespace chromeos | 93 } // namespace chromeos |
OLD | NEW |