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

Side by Side Diff: chrome/browser/chromeos/profiles/profile_helper.h

Issue 1815853002: cros: Flush profile files at critical moments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nits and create test files to fix trybots Created 4 years, 9 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_CHROMEOS_PROFILES_PROFILE_HELPER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_
6 #define CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ 6 #define CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/browsing_data/browsing_data_remover.h" 16 #include "chrome/browser/browsing_data/browsing_data_remover.h"
16 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" 17 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h"
17 #include "components/user_manager/user_manager.h" 18 #include "components/user_manager/user_manager.h"
18 19
19 class Profile; 20 class Profile;
20 21
21 namespace base { 22 namespace base {
22 class FilePath; 23 class FilePath;
23 } 24 }
24 25
25 namespace extensions { 26 namespace extensions {
26 class ExtensionGarbageCollectorChromeOSUnitTest; 27 class ExtensionGarbageCollectorChromeOSUnitTest;
27 } 28 }
28 29
29 namespace ash { 30 namespace ash {
30 namespace test { 31 namespace test {
31 class MultiUserWindowManagerChromeOSTest; 32 class MultiUserWindowManagerChromeOSTest;
32 } // namespace test 33 } // namespace test
33 } // namespace ash 34 } // namespace ash
34 35
35 namespace chromeos { 36 namespace chromeos {
36 37
38 class FileFlusher;
39
37 // This helper class is used on Chrome OS to keep track of currently 40 // This helper class is used on Chrome OS to keep track of currently
38 // active user profile. 41 // active user profile.
39 // Whenever active user is changed (either add another user into session or 42 // Whenever active user is changed (either add another user into session or
40 // switch between users), ActiveUserHashChanged() will be called thus 43 // switch between users), ActiveUserHashChanged() will be called thus
41 // internal state |active_user_id_hash_| will be updated. 44 // internal state |active_user_id_hash_| will be updated.
42 // Typical use cases for using this class: 45 // Typical use cases for using this class:
43 // 1. Get "signin profile" which is a special type of profile that is only used 46 // 1. Get "signin profile" which is a special type of profile that is only used
44 // during signin flow: GetSigninProfile() 47 // during signin flow: GetSigninProfile()
45 // 2. Get profile dir of an active user, used by ProfileManager: 48 // 2. Get profile dir of an active user, used by ProfileManager:
46 // GetActiveUserProfileDir() 49 // GetActiveUserProfileDir()
(...skipping 30 matching lines...) Expand all
77 80
78 // Returns user profile dir in a format [u-user_id_hash]. 81 // Returns user profile dir in a format [u-user_id_hash].
79 static base::FilePath GetUserProfileDir(const std::string& user_id_hash); 82 static base::FilePath GetUserProfileDir(const std::string& user_id_hash);
80 83
81 // Returns true if |profile| is the signin Profile. This can be used during 84 // Returns true if |profile| is the signin Profile. This can be used during
82 // construction of the signin Profile to determine if that Profile is the 85 // construction of the signin Profile to determine if that Profile is the
83 // signin Profile. 86 // signin Profile.
84 static bool IsSigninProfile(const Profile* profile); 87 static bool IsSigninProfile(const Profile* profile);
85 88
86 // Returns true when |profile| corresponds to owner's profile. 89 // Returns true when |profile| corresponds to owner's profile.
87 static bool IsOwnerProfile(Profile* profile); 90 static bool IsOwnerProfile(const Profile* profile);
88 91
89 // Returns true when |profile| corresponds to the primary user profile 92 // Returns true when |profile| corresponds to the primary user profile
90 // of the current session. 93 // of the current session.
91 static bool IsPrimaryProfile(const Profile* profile); 94 static bool IsPrimaryProfile(const Profile* profile);
92 95
96 // Returns true when |profile| is for an ephemeral user.
97 static bool IsEphemeralUserProfile(const Profile* profile);
98
93 // Initialize a bunch of services that are tied to a browser profile. 99 // Initialize a bunch of services that are tied to a browser profile.
94 // TODO(dzhioev): Investigate whether or not this method is needed. 100 // TODO(dzhioev): Investigate whether or not this method is needed.
95 void ProfileStartup(Profile* profile, bool process_startup); 101 void ProfileStartup(Profile* profile, bool process_startup);
96 102
97 // Returns active user profile dir in a format [u-$hash]. 103 // Returns active user profile dir in a format [u-$hash].
98 base::FilePath GetActiveUserProfileDir(); 104 base::FilePath GetActiveUserProfileDir();
99 105
100 // Should called once after UserManager instance has been created. 106 // Should called once after UserManager instance has been created.
101 void Initialize(); 107 void Initialize();
102 108
(...skipping 19 matching lines...) Expand all
122 // TODO(dzhioev): remove this method. http://crbug.com/361528 128 // TODO(dzhioev): remove this method. http://crbug.com/361528
123 Profile* GetProfileByUserUnsafe(const user_manager::User* user); 129 Profile* GetProfileByUserUnsafe(const user_manager::User* user);
124 130
125 // Returns NULL if User is not created. 131 // Returns NULL if User is not created.
126 const user_manager::User* GetUserByProfile(const Profile* profile) const; 132 const user_manager::User* GetUserByProfile(const Profile* profile) const;
127 user_manager::User* GetUserByProfile(Profile* profile) const; 133 user_manager::User* GetUserByProfile(Profile* profile) const;
128 134
129 static std::string GetUserIdHashByUserIdForTesting( 135 static std::string GetUserIdHashByUserIdForTesting(
130 const std::string& user_id); 136 const std::string& user_id);
131 137
138 // Flushes all files of |profile|.
139 void FlushProfile(Profile* profile);
140
132 private: 141 private:
133 // TODO(nkostylev): Create a test API class that will be the only one allowed 142 // TODO(nkostylev): Create a test API class that will be the only one allowed
134 // to access private test methods. 143 // to access private test methods.
135 friend class CryptohomeAuthenticatorTest; 144 friend class CryptohomeAuthenticatorTest;
136 friend class DeviceSettingsTestBase; 145 friend class DeviceSettingsTestBase;
137 friend class ExistingUserControllerTest; 146 friend class ExistingUserControllerTest;
138 friend class extensions::ExtensionGarbageCollectorChromeOSUnitTest; 147 friend class extensions::ExtensionGarbageCollectorChromeOSUnitTest;
139 friend class FakeChromeUserManager; 148 friend class FakeChromeUserManager;
140 friend class KioskTest; 149 friend class KioskTest;
141 friend class MockUserManager; 150 friend class MockUserManager;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 208
200 // If true testing code path is used in GetUserByProfile() even if 209 // If true testing code path is used in GetUserByProfile() even if
201 // user_list_for_testing_ list is empty. In that case primary user will always 210 // user_list_for_testing_ list is empty. In that case primary user will always
202 // be returned. 211 // be returned.
203 static bool enable_profile_to_user_testing; 212 static bool enable_profile_to_user_testing;
204 213
205 // If true and enable_profile_to_user_testing is true then primary user will 214 // If true and enable_profile_to_user_testing is true then primary user will
206 // always be returned by GetUserByProfile(). 215 // always be returned by GetUserByProfile().
207 static bool always_return_primary_user_for_testing; 216 static bool always_return_primary_user_for_testing;
208 217
218 scoped_ptr<FileFlusher> profile_flusher_;
219
209 base::WeakPtrFactory<ProfileHelper> weak_factory_; 220 base::WeakPtrFactory<ProfileHelper> weak_factory_;
210 221
211 DISALLOW_COPY_AND_ASSIGN(ProfileHelper); 222 DISALLOW_COPY_AND_ASSIGN(ProfileHelper);
212 }; 223 };
213 224
214 } // namespace chromeos 225 } // namespace chromeos
215 226
216 #endif // CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ 227 #endif // CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/session/user_session_manager.cc ('k') | chrome/browser/chromeos/profiles/profile_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698