Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: chrome/browser/profiles/profile_loader.h

Issue 16766003: Move ProfileLoader to chrome/browser/profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gyp-def out profile_loader* on android Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_ 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_LOADER_H_
6 #define CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_ 6 #define CHROME_BROWSER_PROFILES_PROFILE_LOADER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile_manager.h"
11 12
12 namespace base { 13 namespace base {
13 class FilePath; 14 class FilePath;
14 } 15 }
15 16
16 class ProfileManager; 17 class ProfileManager;
17 18
19 // This class loads profiles asynchronously and calls the provided callback once
20 // the profile is ready. Only the callback for the most recent load request is
21 // called, and only if the load was successful.
22 //
23 // This is useful for loading profiles in response to user interaction where
24 // only the latest requested profile is required.
18 class ProfileLoader { 25 class ProfileLoader {
19 public: 26 public:
20 explicit ProfileLoader(ProfileManager* profile_manager); 27 explicit ProfileLoader(ProfileManager* profile_manager);
21 ~ProfileLoader(); 28 ~ProfileLoader();
22 29
23 bool AnyProfilesLoading() const; 30 bool IsAnyProfileLoading() const;
24 void InvalidatePendingProfileLoads(); 31 void InvalidatePendingProfileLoads();
25 void LoadProfileInvalidatingOtherLoads( 32 void LoadProfileInvalidatingOtherLoads(
26 const base::FilePath& profile_file_path, 33 const base::FilePath& profile_file_path,
27 base::Callback<void(Profile*)> callback); 34 base::Callback<void(Profile*)> callback);
28 35
36 protected:
37 // These just call through to the ProfileManager.
38 // Virtual so they can be mocked out in tests.
39 virtual Profile* GetProfileByPath(const base::FilePath& path);
40 virtual void CreateProfileAsync(
41 const base::FilePath& profile_path,
42 const ProfileManager::CreateCallback& callback,
43 const string16& name,
44 const string16& icon_url,
45 bool is_managed);
46
29 private: 47 private:
30 void OnProfileLoaded(int profile_load_sequence_id, 48 void OnProfileLoaded(int profile_load_sequence_id,
31 base::Callback<void(Profile*)> callback, 49 base::Callback<void(Profile*)> callback,
32 Profile* profile, 50 Profile* profile,
33 Profile::CreateStatus status); 51 Profile::CreateStatus status);
34 52
35 void IncrementPendingProfileLoads(); 53 void IncrementPendingProfileLoads();
36 void DecrementPendingProfileLoads(); 54 void DecrementPendingProfileLoads();
37 55
38 private:
39 ProfileManager* profile_manager_; 56 ProfileManager* profile_manager_;
40 int profile_load_sequence_id_; 57 int profile_load_sequence_id_;
41 int pending_profile_loads_; 58 int pending_profile_loads_;
42 59
43 base::WeakPtrFactory<ProfileLoader> weak_factory_; 60 base::WeakPtrFactory<ProfileLoader> weak_factory_;
44 61
45 DISALLOW_COPY_AND_ASSIGN(ProfileLoader); 62 DISALLOW_COPY_AND_ASSIGN(ProfileLoader);
46 }; 63 };
47 64
48 #endif // CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_ 65 #endif // CHROME_BROWSER_PROFILES_PROFILE_LOADER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698