| 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" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/sequence_checker.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" | 15 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" |
| 16 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" | 16 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "components/google/core/browser/google_util.h" | 18 #include "components/google/core/browser/google_util.h" |
| 19 #include "components/user_manager/user_manager.h" | 19 #include "components/user_manager/user_manager.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 #include "net/base/network_change_notifier.h" | 22 #include "net/base/network_change_notifier.h" |
| 23 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 24 | 24 |
| 25 using content::BrowserThread; | 25 using content::BrowserThread; |
| 26 using content::WebContents; | 26 using content::WebContents; |
| 27 | 27 |
| 28 namespace merge_session_throttling_utils { | 28 namespace merge_session_throttling_utils { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 const int64_t kMaxSessionRestoreTimeInSec = 60; | 32 const int64_t kMaxSessionRestoreTimeInSec = 60; |
| 33 | 33 |
| 34 // The set of blocked profiles. | 34 // The set of blocked profiles. |
| 35 class ProfileSet : public base::NonThreadSafe, public std::set<Profile*> { | 35 class ProfileSet : public std::set<Profile*> { |
| 36 public: | 36 public: |
| 37 ProfileSet() {} | 37 ProfileSet() {} |
| 38 | 38 |
| 39 virtual ~ProfileSet() {} | 39 virtual ~ProfileSet() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); } |
| 40 | 40 |
| 41 static ProfileSet* Get(); | 41 static ProfileSet* Get(); |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 friend struct ::base::LazyInstanceTraitsBase<ProfileSet>; | 44 friend struct ::base::LazyInstanceTraitsBase<ProfileSet>; |
| 45 | 45 |
| 46 SEQUENCE_CHECKER(sequence_checker_); |
| 47 |
| 46 DISALLOW_COPY_AND_ASSIGN(ProfileSet); | 48 DISALLOW_COPY_AND_ASSIGN(ProfileSet); |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 // Set of all of profiles for which restore session is in progress. | 51 // Set of all of profiles for which restore session is in progress. |
| 50 // This static member is accessible only form UI thread. | 52 // This static member is accessible only form UI thread. |
| 51 base::LazyInstance<ProfileSet>::DestructorAtExit g_blocked_profiles = | 53 base::LazyInstance<ProfileSet>::DestructorAtExit g_blocked_profiles = |
| 52 LAZY_INSTANCE_INITIALIZER; | 54 LAZY_INSTANCE_INITIALIZER; |
| 53 | 55 |
| 54 ProfileSet* ProfileSet::Get() { | 56 ProfileSet* ProfileSet::Get() { |
| 55 return g_blocked_profiles.Pointer(); | 57 return g_blocked_profiles.Pointer(); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 204 |
| 203 default: | 205 default: |
| 204 break; | 206 break; |
| 205 } | 207 } |
| 206 } | 208 } |
| 207 | 209 |
| 208 return pending_session_restore; | 210 return pending_session_restore; |
| 209 } | 211 } |
| 210 | 212 |
| 211 } // namespace merge_session_throttling_utils | 213 } // namespace merge_session_throttling_utils |
| OLD | NEW |