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

Side by Side Diff: chrome/browser/ui/app_list/profile_loader.h

Issue 24707002: Add unit tests for AppListServiceImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, add IsManaged() check Created 7 years, 2 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
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_PROFILES_PROFILE_LOADER_H_ 5 #ifndef CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_LOADER_H_ 6 #define CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile_manager.h" 12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/ui/app_list/keep_alive_service.h"
14 #include "chrome/browser/ui/app_list/profile_store.h"
12 15
13 namespace base { 16 namespace base {
14 class FilePath; 17 class FilePath;
15 } 18 }
16 19
17 class ProfileManager; 20 class ProfileManager;
18 21
19 // This class loads profiles asynchronously and calls the provided callback once 22 // 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 23 // the profile is ready. Only the callback for the most recent load request is
21 // called, and only if the load was successful. 24 // called, and only if the load was successful.
22 // 25 //
23 // This is useful for loading profiles in response to user interaction where 26 // This is useful for loading profiles in response to user interaction where
benwells 2013/09/26 06:55:29 Please add a TODO to remove this class and fold it
koz (OOO until 15th September) 2013/09/26 22:12:47 Added TODO.
24 // only the latest requested profile is required. 27 // only the latest requested profile is required.
25 class ProfileLoader { 28 class ProfileLoader {
26 public: 29 public:
27 explicit ProfileLoader(ProfileManager* profile_manager); 30 explicit ProfileLoader(ProfileStore* profile_store,
31 scoped_ptr<KeepAliveService> keep_alive_service);
28 ~ProfileLoader(); 32 ~ProfileLoader();
29 33
30 bool IsAnyProfileLoading() const; 34 bool IsAnyProfileLoading() const;
31 void InvalidatePendingProfileLoads(); 35 void InvalidatePendingProfileLoads();
32 void LoadProfileInvalidatingOtherLoads( 36 void LoadProfileInvalidatingOtherLoads(
33 const base::FilePath& profile_file_path, 37 const base::FilePath& profile_file_path,
34 base::Callback<void(Profile*)> callback); 38 base::Callback<void(Profile*)> callback);
35 39
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 const std::string& managed_user_id);
46
47 private: 40 private:
48 void OnProfileLoaded(int profile_load_sequence_id, 41 void OnProfileLoaded(int profile_load_sequence_id,
49 base::Callback<void(Profile*)> callback, 42 base::Callback<void(Profile*)> callback,
50 Profile* profile, 43 Profile* profile);
51 Profile::CreateStatus status);
52 44
53 void IncrementPendingProfileLoads(); 45 void IncrementPendingProfileLoads();
54 void DecrementPendingProfileLoads(); 46 void DecrementPendingProfileLoads();
55 47
56 ProfileManager* profile_manager_; 48 ProfileStore* profile_store_;
49 scoped_ptr<KeepAliveService> keep_alive_service_;
57 int profile_load_sequence_id_; 50 int profile_load_sequence_id_;
58 int pending_profile_loads_; 51 int pending_profile_loads_;
59 52
60 base::WeakPtrFactory<ProfileLoader> weak_factory_; 53 base::WeakPtrFactory<ProfileLoader> weak_factory_;
61 54
62 DISALLOW_COPY_AND_ASSIGN(ProfileLoader); 55 DISALLOW_COPY_AND_ASSIGN(ProfileLoader);
63 }; 56 };
64 57
65 #endif // CHROME_BROWSER_PROFILES_PROFILE_LOADER_H_ 58 #endif // CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698