profile_loader.h revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
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. 4 5#ifndef CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_ 6#define CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_ 7 8#include "base/callback.h" 9#include "base/memory/weak_ptr.h" 10#include "chrome/browser/profiles/profile.h" 11 12namespace base { 13class FilePath; 14} 15 16class ProfileManager; 17 18class ProfileLoader { 19 public: 20 explicit ProfileLoader(ProfileManager* profile_manager); 21 ~ProfileLoader(); 22 23 bool AnyProfilesLoading() const; 24 void InvalidatePendingProfileLoads(); 25 void LoadProfileInvalidatingOtherLoads( 26 const base::FilePath& profile_file_path, 27 base::Callback<void(Profile*)> callback); 28 29 private: 30 void OnProfileLoaded(int profile_load_sequence_id, 31 base::Callback<void(Profile*)> callback, 32 Profile* profile, 33 Profile::CreateStatus status); 34 35 void IncrementPendingProfileLoads(); 36 void DecrementPendingProfileLoads(); 37 38 private: 39 ProfileManager* profile_manager_; 40 int profile_load_sequence_id_; 41 int pending_profile_loads_; 42 43 base::WeakPtrFactory<ProfileLoader> weak_factory_; 44 45 DISALLOW_COPY_AND_ASSIGN(ProfileLoader); 46}; 47 48#endif // CHROME_BROWSER_UI_APP_LIST_PROFILE_LOADER_H_ 49