OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_throttling_utils.h" | 5 #include "chrome/browser/chromeos/login/signin/merge_session_throttling_utils.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 // Global counter that keeps the track of session merge status for all | 57 // Global counter that keeps the track of session merge status for all |
58 // encountered profiles. This is used to determine if a throttle should | 58 // encountered profiles. This is used to determine if a throttle should |
59 // even be even added to new requests. Value of 0 (initial) means that we | 59 // even be even added to new requests. Value of 0 (initial) means that we |
60 // probably have some profiles to restore, while 1 means that all known | 60 // probably have some profiles to restore, while 1 means that all known |
61 // profiles are restored. | 61 // profiles are restored. |
62 base::AtomicRefCount g_all_profiles_restored_ = 0; | 62 base::AtomicRefCount g_all_profiles_restored_ = 0; |
63 | 63 |
64 } // namespace | 64 } // namespace |
65 | 65 |
| 66 bool ShouldAttachNavigationThrottle() { |
| 67 return user_manager::UserManager::IsInitialized(); |
| 68 } |
| 69 |
66 bool AreAllSessionMergedAlready() { | 70 bool AreAllSessionMergedAlready() { |
67 return !base::AtomicRefCountIsZero(&g_all_profiles_restored_); | 71 return !base::AtomicRefCountIsZero(&g_all_profiles_restored_); |
68 } | 72 } |
69 | 73 |
70 void BlockProfile(Profile* profile) { | 74 void BlockProfile(Profile* profile) { |
71 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 75 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
72 // Add a new profile to the list of those that we are currently blocking | 76 // Add a new profile to the list of those that we are currently blocking |
73 // blocking page loading for. | 77 // blocking page loading for. |
74 if (ProfileSet::Get()->find(profile) == ProfileSet::Get()->end()) { | 78 if (ProfileSet::Get()->find(profile) == ProfileSet::Get()->end()) { |
75 DVLOG(1) << "Blocking profile " << profile; | 79 DVLOG(1) << "Blocking profile " << profile; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 bool ShouldDelayUrl(const GURL& url) { | 178 bool ShouldDelayUrl(const GURL& url) { |
175 // If we are loading google properties while merge session is in progress, | 179 // If we are loading google properties while merge session is in progress, |
176 // we will show delayed loading page instead. | 180 // we will show delayed loading page instead. |
177 return !net::NetworkChangeNotifier::IsOffline() && | 181 return !net::NetworkChangeNotifier::IsOffline() && |
178 !AreAllSessionMergedAlready() && | 182 !AreAllSessionMergedAlready() && |
179 google_util::IsGoogleHostname(url.host_piece(), | 183 google_util::IsGoogleHostname(url.host_piece(), |
180 google_util::ALLOW_SUBDOMAIN); | 184 google_util::ALLOW_SUBDOMAIN); |
181 } | 185 } |
182 | 186 |
183 } // namespace merge_session_throttling_utils | 187 } // namespace merge_session_throttling_utils |
OLD | NEW |