Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / app_list / profile_loader.h
blob724ea825bd7b0d63605e3b024fe36b8e5b351400
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_
6 #define CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
11 namespace base {
12 class FilePath;
15 class Profile;
16 class ProfileLoaderUnittest;
17 class ProfileStore;
18 class ScopedKeepAlive;
20 // This class loads profiles asynchronously and calls the provided callback once
21 // the profile is ready. Only the callback for the most recent load request is
22 // called, and only if the load was successful.
24 // This is useful for loading profiles in response to user interaction where
25 // only the latest requested profile is required.
26 // TODO(koz): Merge this into AppListServiceImpl.
27 class ProfileLoader {
28 public:
29 explicit ProfileLoader(ProfileStore* profile_store);
30 ~ProfileLoader();
32 bool IsAnyProfileLoading() const;
33 void InvalidatePendingProfileLoads();
34 void LoadProfileInvalidatingOtherLoads(
35 const base::FilePath& profile_file_path,
36 base::Callback<void(Profile*)> callback);
38 private:
39 friend class ::ProfileLoaderUnittest;
41 void OnProfileLoaded(int profile_load_sequence_id,
42 base::Callback<void(Profile*)> callback,
43 Profile* profile);
45 void IncrementPendingProfileLoads();
46 void DecrementPendingProfileLoads();
48 ProfileStore* profile_store_;
49 scoped_ptr<ScopedKeepAlive> keep_alive_;
50 int profile_load_sequence_id_;
51 int pending_profile_loads_;
53 base::WeakPtrFactory<ProfileLoader> weak_factory_;
55 DISALLOW_COPY_AND_ASSIGN(ProfileLoader);
58 #endif // CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_