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

Side by Side Diff: chrome/test/base/testing_profile.cc

Issue 16018004: Clean up after moving ProfileKeyedService files to a component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/test/base/testing_profile.h" 5 #include "chrome/test/base/testing_profile.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 #else 165 #else
166 const char TestingProfile::kTestUserProfileDir[] = "Default"; 166 const char TestingProfile::kTestUserProfileDir[] = "Default";
167 #endif 167 #endif
168 168
169 TestingProfile::TestingProfile() 169 TestingProfile::TestingProfile()
170 : start_time_(Time::Now()), 170 : start_time_(Time::Now()),
171 testing_prefs_(NULL), 171 testing_prefs_(NULL),
172 incognito_(false), 172 incognito_(false),
173 original_profile_(NULL), 173 original_profile_(NULL),
174 last_session_exited_cleanly_(true), 174 last_session_exited_cleanly_(true),
175 profile_dependency_manager_( 175 browser_context_dependency_manager_(
176 BrowserContextDependencyManager::GetInstance()), 176 BrowserContextDependencyManager::GetInstance()),
177 delegate_(NULL) { 177 delegate_(NULL) {
178 CreateTempProfileDir(); 178 CreateTempProfileDir();
179 profile_path_ = temp_dir_.path(); 179 profile_path_ = temp_dir_.path();
180 180
181 Init(); 181 Init();
182 FinishInit(); 182 FinishInit();
183 } 183 }
184 184
185 TestingProfile::TestingProfile(const base::FilePath& path) 185 TestingProfile::TestingProfile(const base::FilePath& path)
186 : start_time_(Time::Now()), 186 : start_time_(Time::Now()),
187 testing_prefs_(NULL), 187 testing_prefs_(NULL),
188 incognito_(false), 188 incognito_(false),
189 original_profile_(NULL), 189 original_profile_(NULL),
190 last_session_exited_cleanly_(true), 190 last_session_exited_cleanly_(true),
191 profile_path_(path), 191 profile_path_(path),
192 profile_dependency_manager_( 192 browser_context_dependency_manager_(
193 BrowserContextDependencyManager::GetInstance()), 193 BrowserContextDependencyManager::GetInstance()),
194 delegate_(NULL) { 194 delegate_(NULL) {
195 Init(); 195 Init();
196 FinishInit(); 196 FinishInit();
197 } 197 }
198 198
199 TestingProfile::TestingProfile(const base::FilePath& path, 199 TestingProfile::TestingProfile(const base::FilePath& path,
200 Delegate* delegate) 200 Delegate* delegate)
201 : start_time_(Time::Now()), 201 : start_time_(Time::Now()),
202 testing_prefs_(NULL), 202 testing_prefs_(NULL),
203 incognito_(false), 203 incognito_(false),
204 original_profile_(NULL), 204 original_profile_(NULL),
205 last_session_exited_cleanly_(true), 205 last_session_exited_cleanly_(true),
206 profile_path_(path), 206 profile_path_(path),
207 profile_dependency_manager_( 207 browser_context_dependency_manager_(
208 BrowserContextDependencyManager::GetInstance()), 208 BrowserContextDependencyManager::GetInstance()),
209 delegate_(delegate) { 209 delegate_(delegate) {
210 Init(); 210 Init();
211 if (delegate_) { 211 if (delegate_) {
212 base::MessageLoop::current()->PostTask( 212 base::MessageLoop::current()->PostTask(
213 FROM_HERE, 213 FROM_HERE,
214 base::Bind(&TestingProfile::FinishInit, base::Unretained(this))); 214 base::Bind(&TestingProfile::FinishInit, base::Unretained(this)));
215 } else { 215 } else {
216 FinishInit(); 216 FinishInit();
217 } 217 }
218 } 218 }
219 219
220 TestingProfile::TestingProfile( 220 TestingProfile::TestingProfile(
221 const base::FilePath& path, 221 const base::FilePath& path,
222 Delegate* delegate, 222 Delegate* delegate,
223 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, 223 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy,
224 scoped_ptr<PrefServiceSyncable> prefs) 224 scoped_ptr<PrefServiceSyncable> prefs)
225 : start_time_(Time::Now()), 225 : start_time_(Time::Now()),
226 prefs_(prefs.release()), 226 prefs_(prefs.release()),
227 testing_prefs_(NULL), 227 testing_prefs_(NULL),
228 incognito_(false), 228 incognito_(false),
229 original_profile_(NULL), 229 original_profile_(NULL),
230 last_session_exited_cleanly_(true), 230 last_session_exited_cleanly_(true),
231 extension_special_storage_policy_(extension_policy), 231 extension_special_storage_policy_(extension_policy),
232 profile_path_(path), 232 profile_path_(path),
233 profile_dependency_manager_( 233 browser_context_dependency_manager_(
234 BrowserContextDependencyManager::GetInstance()), 234 BrowserContextDependencyManager::GetInstance()),
235 delegate_(delegate) { 235 delegate_(delegate) {
236 236
237 // If no profile path was supplied, create one. 237 // If no profile path was supplied, create one.
238 if (profile_path_.empty()) { 238 if (profile_path_.empty()) {
239 CreateTempProfileDir(); 239 CreateTempProfileDir();
240 profile_path_ = temp_dir_.path(); 240 profile_path_ = temp_dir_.path();
241 } 241 }
242 242
243 Init(); 243 Init();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 file_util::CreateDirectory(profile_path_); 296 file_util::CreateDirectory(profile_path_);
297 297
298 // TODO(joaodasilva): remove this once this PKS isn't created in ProfileImpl 298 // TODO(joaodasilva): remove this once this PKS isn't created in ProfileImpl
299 // anymore, after converting the PrefService to a PKS. Until then it must 299 // anymore, after converting the PrefService to a PKS. Until then it must
300 // be associated with a TestingProfile too. 300 // be associated with a TestingProfile too.
301 CreateProfilePolicyConnector(); 301 CreateProfilePolicyConnector();
302 302
303 extensions::ExtensionSystemFactory::GetInstance()->SetTestingFactory( 303 extensions::ExtensionSystemFactory::GetInstance()->SetTestingFactory(
304 this, extensions::TestExtensionSystem::Build); 304 this, extensions::TestExtensionSystem::Build);
305 305
306 profile_dependency_manager_->CreateBrowserContextServices(this, true); 306 browser_context_dependency_manager_->CreateBrowserContextServices(this, true);
307 307
308 #if defined(ENABLE_NOTIFICATIONS) 308 #if defined(ENABLE_NOTIFICATIONS)
309 // Install profile keyed service factory hooks for dummy/test services 309 // Install profile keyed service factory hooks for dummy/test services
310 DesktopNotificationServiceFactory::GetInstance()->SetTestingFactory( 310 DesktopNotificationServiceFactory::GetInstance()->SetTestingFactory(
311 this, CreateTestDesktopNotificationService); 311 this, CreateTestDesktopNotificationService);
312 #endif 312 #endif
313 } 313 }
314 314
315 void TestingProfile::FinishInit() { 315 void TestingProfile::FinishInit() {
316 DCHECK(content::NotificationService::current()); 316 DCHECK(content::NotificationService::current());
317 content::NotificationService::current()->Notify( 317 content::NotificationService::current()->Notify(
318 chrome::NOTIFICATION_PROFILE_CREATED, 318 chrome::NOTIFICATION_PROFILE_CREATED,
319 content::Source<Profile>(static_cast<Profile*>(this)), 319 content::Source<Profile>(static_cast<Profile*>(this)),
320 content::NotificationService::NoDetails()); 320 content::NotificationService::NoDetails());
321 321
322 if (delegate_) 322 if (delegate_)
323 delegate_->OnProfileCreated(this, true, false); 323 delegate_->OnProfileCreated(this, true, false);
324 } 324 }
325 325
326 TestingProfile::~TestingProfile() { 326 TestingProfile::~TestingProfile() {
327 MaybeSendDestroyedNotification(); 327 MaybeSendDestroyedNotification();
328 328
329 profile_dependency_manager_->DestroyBrowserContextServices(this); 329 browser_context_dependency_manager_->DestroyBrowserContextServices(this);
330 330
331 if (host_content_settings_map_) 331 if (host_content_settings_map_)
332 host_content_settings_map_->ShutdownOnUIThread(); 332 host_content_settings_map_->ShutdownOnUIThread();
333 333
334 DestroyTopSites(); 334 DestroyTopSites();
335 335
336 if (pref_proxy_config_tracker_.get()) 336 if (pref_proxy_config_tracker_.get())
337 pref_proxy_config_tracker_->DetachFromPrefService(); 337 pref_proxy_config_tracker_->DetachFromPrefService();
338 } 338 }
339 339
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 808
809 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { 809 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() {
810 DCHECK(!build_called_); 810 DCHECK(!build_called_);
811 build_called_ = true; 811 build_called_ = true;
812 return scoped_ptr<TestingProfile>(new TestingProfile( 812 return scoped_ptr<TestingProfile>(new TestingProfile(
813 path_, 813 path_,
814 delegate_, 814 delegate_,
815 extension_policy_, 815 extension_policy_,
816 pref_service_.Pass())); 816 pref_service_.Pass()));
817 } 817 }
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698