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

Side by Side Diff: chrome/browser/profile_manager.h

Issue 13009: Rollback (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years 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
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/profile_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // This class keeps track of the currently-active profiles in the runtime. 5 // This class keeps track of the currently-active profiles in the runtime.
6 6
7 #ifndef CHROME_BROWSER_PROFILE_MANAGER_H__ 7 #ifndef CHROME_BROWSER_PROFILE_MANAGER_H__
8 #define CHROME_BROWSER_PROFILE_MANAGER_H__ 8 #define CHROME_BROWSER_PROFILE_MANAGER_H__
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/message_loop.h"
16 #include "base/non_thread_safe.h"
17 #include "base/system_monitor.h"
18 #include "base/values.h" 15 #include "base/values.h"
19 #include "chrome/browser/profile.h" 16 #include "chrome/browser/profile.h"
20 17
21 // This is a small storage class that simply represents some metadata about 18 // This is a small storage class that simply represents some metadata about
22 // profiles that are available in the current user data directory. 19 // profiles that are available in the current user data directory.
23 // These are cached in local state so profiles don't need to be scanned 20 // These are cached in local state so profiles don't need to be scanned
24 // for their metadata on every launch. 21 // for their metadata on every launch.
25 class AvailableProfile { 22 class AvailableProfile {
26 public: 23 public:
27 AvailableProfile(const std::wstring& name, 24 AvailableProfile(const std::wstring& name,
(...skipping 25 matching lines...) Expand all
53 std::wstring directory() const { return directory_; } 50 std::wstring directory() const { return directory_; }
54 51
55 private: 52 private:
56 std::wstring name_; // User-visible profile name 53 std::wstring name_; // User-visible profile name
57 std::wstring id_; // Profile identifier 54 std::wstring id_; // Profile identifier
58 std::wstring directory_; // Subdirectory containing profile (not full path) 55 std::wstring directory_; // Subdirectory containing profile (not full path)
59 56
60 DISALLOW_EVIL_CONSTRUCTORS(AvailableProfile); 57 DISALLOW_EVIL_CONSTRUCTORS(AvailableProfile);
61 }; 58 };
62 59
63 class ProfileManager : public NonThreadSafe, 60 class ProfileManager {
64 public base::SystemMonitor::PowerObserver {
65 public: 61 public:
66 ProfileManager(); 62 ProfileManager();
67 virtual ~ProfileManager(); 63 virtual ~ProfileManager();
68 64
69 // ProfileManager prefs are loaded as soon as the profile is created. 65 // ProfileManager prefs are loaded as soon as the profile is created.
70 static void RegisterUserPrefs(PrefService* prefs); 66 static void RegisterUserPrefs(PrefService* prefs);
71 67
72 // Invokes ShutdownSessionService() on all profiles. 68 // Invokes ShutdownSessionService() on all profiles.
73 static void ShutdownSessionServices(); 69 static void ShutdownSessionServices();
74 70
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 const_iterator end() { return profiles_.end(); } 115 const_iterator end() { return profiles_.end(); }
120 116
121 typedef std::vector<AvailableProfile*> AvailableProfileVector; 117 typedef std::vector<AvailableProfile*> AvailableProfileVector;
122 const AvailableProfileVector& available_profiles() const { 118 const AvailableProfileVector& available_profiles() const {
123 return available_profiles_; 119 return available_profiles_;
124 } 120 }
125 121
126 // Creates a new window with the given profile. 122 // Creates a new window with the given profile.
127 void NewWindowWithProfile(Profile* profile); 123 void NewWindowWithProfile(Profile* profile);
128 124
129 // PowerObserver notifications
130 void OnPowerStateChange(base::SystemMonitor*) {}
131 void OnSuspend(base::SystemMonitor*);
132 void OnResume(base::SystemMonitor*);
133
134 // ------------------ static utility functions ------------------- 125 // ------------------ static utility functions -------------------
135 126
136 // Returns the path to the profile directory based on the user data directory. 127 // Returns the path to the profile directory based on the user data directory.
137 static std::wstring GetDefaultProfileDir(const std::wstring& user_data_dir); 128 static std::wstring GetDefaultProfileDir(const std::wstring& user_data_dir);
138 129
139 // Returns the path to the profile given the user profile directory. 130 // Returns the path to the profile given the user profile directory.
140 static std::wstring GetDefaultProfilePath(const std::wstring& profile_dir); 131 static std::wstring GetDefaultProfilePath(const std::wstring& profile_dir);
141 132
142 // Tries to determine whether the given path represents a profile 133 // Tries to determine whether the given path represents a profile
143 // directory, and returns true if it thinks it does. 134 // directory, and returns true if it thinks it does.
(...skipping 15 matching lines...) Expand all
159 const std::wstring& id); 150 const std::wstring& id);
160 151
161 // Returns the canonical form of the given ID string. 152 // Returns the canonical form of the given ID string.
162 static std::wstring CanonicalizeID(const std::wstring& id); 153 static std::wstring CanonicalizeID(const std::wstring& id);
163 154
164 private: 155 private:
165 // Returns the AvailableProfile entry associated with the given ID, 156 // Returns the AvailableProfile entry associated with the given ID,
166 // or NULL if no match is found. 157 // or NULL if no match is found.
167 AvailableProfile* GetAvailableProfileByID(const std::wstring& id); 158 AvailableProfile* GetAvailableProfileByID(const std::wstring& id);
168 159
169 // Hooks to suspend/resume per-profile network traffic.
170 // These must be called on the IO thread.
171 static void SuspendProfile(Profile*);
172 static void ResumeProfile(Profile*);
173
174 // We keep a simple vector of profiles rather than something fancier 160 // We keep a simple vector of profiles rather than something fancier
175 // because we expect there to be a small number of profiles active. 161 // because we expect there to be a small number of profiles active.
176 ProfileVector profiles_; 162 ProfileVector profiles_;
177 163
178 AvailableProfileVector available_profiles_; 164 AvailableProfileVector available_profiles_;
179 165
180 DISALLOW_EVIL_CONSTRUCTORS(ProfileManager); 166 DISALLOW_EVIL_CONSTRUCTORS(ProfileManager);
181 }; 167 };
182 168
183 #endif // CHROME_BROWSER_PROFILE_MANAGER_H__ 169 #endif // CHROME_BROWSER_PROFILE_MANAGER_H__
184 170
OLDNEW
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/profile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698