| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This class keeps track of the currently-active profiles in the runtime. | 5 // This class keeps track of the currently-active profiles in the runtime. |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ | 7 #ifndef CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ |
| 8 #define CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ | 8 #define CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ |
| 9 | 9 |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 | 11 |
| 12 #include <list> | 12 #include <list> |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
| 17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 18 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/memory/linked_ptr.h" | 20 #include "base/memory/linked_ptr.h" |
| 21 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
| 22 #include "base/threading/non_thread_safe.h" | 22 #include "base/threading/thread_checker.h" |
| 23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/profiles/profile_metrics.h" | 25 #include "chrome/browser/profiles/profile_metrics.h" |
| 26 #include "chrome/browser/profiles/profile_shortcut_manager.h" | 26 #include "chrome/browser/profiles/profile_shortcut_manager.h" |
| 27 #include "chrome/browser/ui/browser_list_observer.h" | 27 #include "chrome/browser/ui/browser_list_observer.h" |
| 28 #include "chrome/common/features.h" | 28 #include "chrome/common/features.h" |
| 29 #include "content/public/browser/notification_observer.h" | 29 #include "content/public/browser/notification_observer.h" |
| 30 #include "content/public/browser/notification_registrar.h" | 30 #include "content/public/browser/notification_registrar.h" |
| 31 | 31 |
| 32 class ProfileAttributesStorage; | 32 class ProfileAttributesStorage; |
| 33 class ProfileInfoCache; | 33 class ProfileInfoCache; |
| 34 | 34 |
| 35 class ProfileManager : public base::NonThreadSafe, | 35 class ProfileManager : public content::NotificationObserver, |
| 36 public content::NotificationObserver, | |
| 37 public Profile::Delegate { | 36 public Profile::Delegate { |
| 38 public: | 37 public: |
| 39 typedef base::Callback<void(Profile*, Profile::CreateStatus)> CreateCallback; | 38 typedef base::Callback<void(Profile*, Profile::CreateStatus)> CreateCallback; |
| 40 typedef base::Callback<void(Profile*)> ProfileLoadedCallback; | 39 typedef base::Callback<void(Profile*)> ProfileLoadedCallback; |
| 41 | 40 |
| 42 explicit ProfileManager(const base::FilePath& user_data_dir); | 41 explicit ProfileManager(const base::FilePath& user_data_dir); |
| 43 ~ProfileManager() override; | 42 ~ProfileManager() override; |
| 44 | 43 |
| 45 #if BUILDFLAG(ENABLE_SESSION_SERVICE) | 44 #if BUILDFLAG(ENABLE_SESSION_SERVICE) |
| 46 // Invokes SessionServiceFactory::ShutdownForProfile() for all profiles. | 45 // Invokes SessionServiceFactory::ShutdownForProfile() for all profiles. |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 // Manages the process of creating, deleteing and updating Desktop shortcuts. | 419 // Manages the process of creating, deleteing and updating Desktop shortcuts. |
| 421 std::unique_ptr<ProfileShortcutManager> profile_shortcut_manager_; | 420 std::unique_ptr<ProfileShortcutManager> profile_shortcut_manager_; |
| 422 | 421 |
| 423 // For keeping track of the last active profiles. | 422 // For keeping track of the last active profiles. |
| 424 std::map<Profile*, int> browser_counts_; | 423 std::map<Profile*, int> browser_counts_; |
| 425 // On startup we launch the active profiles in the order they became active | 424 // On startup we launch the active profiles in the order they became active |
| 426 // during the last run. This is why they are kept in a list, not in a set. | 425 // during the last run. This is why they are kept in a list, not in a set. |
| 427 std::vector<Profile*> active_profiles_; | 426 std::vector<Profile*> active_profiles_; |
| 428 bool closing_all_browsers_; | 427 bool closing_all_browsers_; |
| 429 | 428 |
| 429 // TODO(chrome/browser/profiles/OWNERS): Usage of this in profile_manager.cc |
| 430 // should likely be turned into DCHECK_CURRENTLY_ON(BrowserThread::UI) for |
| 431 // consistency with surrounding code in the same file but that wasn't trivial |
| 432 // enough to do as part of the mass refactor CL which introduced |
| 433 // |thread_checker_|, ref. https://codereview.chromium.org/2907253003/#msg37. |
| 434 THREAD_CHECKER(thread_checker_); |
| 435 |
| 430 DISALLOW_COPY_AND_ASSIGN(ProfileManager); | 436 DISALLOW_COPY_AND_ASSIGN(ProfileManager); |
| 431 }; | 437 }; |
| 432 | 438 |
| 433 // Same as the ProfileManager, but doesn't initialize some services of the | 439 // Same as the ProfileManager, but doesn't initialize some services of the |
| 434 // profile. This one is useful in unittests. | 440 // profile. This one is useful in unittests. |
| 435 class ProfileManagerWithoutInit : public ProfileManager { | 441 class ProfileManagerWithoutInit : public ProfileManager { |
| 436 public: | 442 public: |
| 437 explicit ProfileManagerWithoutInit(const base::FilePath& user_data_dir); | 443 explicit ProfileManagerWithoutInit(const base::FilePath& user_data_dir); |
| 438 | 444 |
| 439 protected: | 445 protected: |
| 440 void DoFinalInitForServices(Profile*, bool) override {} | 446 void DoFinalInitForServices(Profile*, bool) override {} |
| 441 void DoFinalInitLogging(Profile*) override {} | 447 void DoFinalInitLogging(Profile*) override {} |
| 442 }; | 448 }; |
| 443 | 449 |
| 444 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ | 450 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ |
| OLD | NEW |