OLD | NEW |
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_UI_APP_LIST_PROFILE_LOADER_H_ |
6 #define CHROME_BROWSER_UI_APP_LIST_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/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 | 10 |
11 namespace base { | 11 namespace base { |
12 class FilePath; | 12 class FilePath; |
13 } | 13 } |
14 | 14 |
| 15 namespace browser_lifetime { |
| 16 class ScopedKeepAlive; |
| 17 } |
| 18 |
15 class Profile; | 19 class Profile; |
16 class ProfileLoaderUnittest; | 20 class ProfileLoaderUnittest; |
17 class ProfileStore; | 21 class ProfileStore; |
18 class ScopedKeepAlive; | |
19 | 22 |
20 // This class loads profiles asynchronously and calls the provided callback once | 23 // 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 | 24 // the profile is ready. Only the callback for the most recent load request is |
22 // called, and only if the load was successful. | 25 // called, and only if the load was successful. |
23 // | 26 // |
24 // This is useful for loading profiles in response to user interaction where | 27 // This is useful for loading profiles in response to user interaction where |
25 // only the latest requested profile is required. | 28 // only the latest requested profile is required. |
26 // TODO(koz): Merge this into AppListServiceImpl. | 29 // TODO(koz): Merge this into AppListServiceImpl. |
27 class ProfileLoader { | 30 class ProfileLoader { |
28 public: | 31 public: |
(...skipping 10 matching lines...) Expand all Loading... |
39 friend class ::ProfileLoaderUnittest; | 42 friend class ::ProfileLoaderUnittest; |
40 | 43 |
41 void OnProfileLoaded(int profile_load_sequence_id, | 44 void OnProfileLoaded(int profile_load_sequence_id, |
42 base::Callback<void(Profile*)> callback, | 45 base::Callback<void(Profile*)> callback, |
43 Profile* profile); | 46 Profile* profile); |
44 | 47 |
45 void IncrementPendingProfileLoads(); | 48 void IncrementPendingProfileLoads(); |
46 void DecrementPendingProfileLoads(); | 49 void DecrementPendingProfileLoads(); |
47 | 50 |
48 ProfileStore* profile_store_; | 51 ProfileStore* profile_store_; |
49 scoped_ptr<ScopedKeepAlive> keep_alive_; | 52 scoped_ptr<browser_lifetime::ScopedKeepAlive> keep_alive_; |
50 int profile_load_sequence_id_; | 53 int profile_load_sequence_id_; |
51 int pending_profile_loads_; | 54 int pending_profile_loads_; |
52 | 55 |
53 base::WeakPtrFactory<ProfileLoader> weak_factory_; | 56 base::WeakPtrFactory<ProfileLoader> weak_factory_; |
54 | 57 |
55 DISALLOW_COPY_AND_ASSIGN(ProfileLoader); | 58 DISALLOW_COPY_AND_ASSIGN(ProfileLoader); |
56 }; | 59 }; |
57 | 60 |
58 #endif // CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_ | 61 #endif // CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_ |
OLD | NEW |