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

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: un-const an iterator 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
24 // only the latest requested profile is required. 27 // only the latest requested profile is required.
28 // TODO(koz): Merge this into AppListServiceImpl.
25 class ProfileLoader { 29 class ProfileLoader {
26 public: 30 public:
27 explicit ProfileLoader(ProfileManager* profile_manager); 31 explicit ProfileLoader(ProfileStore* profile_store,
32 scoped_ptr<KeepAliveService> keep_alive_service);
28 ~ProfileLoader(); 33 ~ProfileLoader();
29 34
30 bool IsAnyProfileLoading() const; 35 bool IsAnyProfileLoading() const;
31 void InvalidatePendingProfileLoads(); 36 void InvalidatePendingProfileLoads();
32 void LoadProfileInvalidatingOtherLoads( 37 void LoadProfileInvalidatingOtherLoads(
33 const base::FilePath& profile_file_path, 38 const base::FilePath& profile_file_path,
34 base::Callback<void(Profile*)> callback); 39 base::Callback<void(Profile*)> callback);
35 40
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: 41 private:
48 void OnProfileLoaded(int profile_load_sequence_id, 42 void OnProfileLoaded(int profile_load_sequence_id,
49 base::Callback<void(Profile*)> callback, 43 base::Callback<void(Profile*)> callback,
50 Profile* profile, 44 Profile* profile);
51 Profile::CreateStatus status);
52 45
53 void IncrementPendingProfileLoads(); 46 void IncrementPendingProfileLoads();
54 void DecrementPendingProfileLoads(); 47 void DecrementPendingProfileLoads();
55 48
56 ProfileManager* profile_manager_; 49 ProfileStore* profile_store_;
50 scoped_ptr<KeepAliveService> keep_alive_service_;
57 int profile_load_sequence_id_; 51 int profile_load_sequence_id_;
58 int pending_profile_loads_; 52 int pending_profile_loads_;
59 53
60 base::WeakPtrFactory<ProfileLoader> weak_factory_; 54 base::WeakPtrFactory<ProfileLoader> weak_factory_;
61 55
62 DISALLOW_COPY_AND_ASSIGN(ProfileLoader); 56 DISALLOW_COPY_AND_ASSIGN(ProfileLoader);
63 }; 57 };
64 58
65 #endif // CHROME_BROWSER_PROFILES_PROFILE_LOADER_H_ 59 #endif // CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/keep_alive_service_impl.cc ('k') | chrome/browser/ui/app_list/profile_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698