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

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

Issue 100573002: Move directory creation functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 bool success = PathService::Get(base::DIR_TEMP, &system_tmp_dir); 287 bool success = PathService::Get(base::DIR_TEMP, &system_tmp_dir);
288 288
289 // We're severly screwed if we can't get the system temporary 289 // We're severly screwed if we can't get the system temporary
290 // directory. Die now to avoid writing to the filesystem root 290 // directory. Die now to avoid writing to the filesystem root
291 // or other bad places. 291 // or other bad places.
292 CHECK(success); 292 CHECK(success);
293 293
294 base::FilePath fallback_dir( 294 base::FilePath fallback_dir(
295 system_tmp_dir.AppendASCII("TestingProfilePath")); 295 system_tmp_dir.AppendASCII("TestingProfilePath"));
296 base::DeleteFile(fallback_dir, true); 296 base::DeleteFile(fallback_dir, true);
297 file_util::CreateDirectory(fallback_dir); 297 base::CreateDirectory(fallback_dir);
298 if (!temp_dir_.Set(fallback_dir)) { 298 if (!temp_dir_.Set(fallback_dir)) {
299 // That shouldn't happen, but if it does, try to recover. 299 // That shouldn't happen, but if it does, try to recover.
300 LOG(ERROR) << "Failed to use a fallback temporary directory."; 300 LOG(ERROR) << "Failed to use a fallback temporary directory.";
301 301
302 // We're screwed if this fails, see CHECK above. 302 // We're screwed if this fails, see CHECK above.
303 CHECK(temp_dir_.Set(system_tmp_dir)); 303 CHECK(temp_dir_.Set(system_tmp_dir));
304 } 304 }
305 } 305 }
306 } 306 }
307 307
308 void TestingProfile::Init() { 308 void TestingProfile::Init() {
309 // If threads have been initialized, we should be on the UI thread. 309 // If threads have been initialized, we should be on the UI thread.
310 DCHECK(!content::BrowserThread::IsThreadInitialized( 310 DCHECK(!content::BrowserThread::IsThreadInitialized(
311 content::BrowserThread::UI) || 311 content::BrowserThread::UI) ||
312 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 312 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
313 313
314 // Normally this would happen during browser startup, but for tests 314 // Normally this would happen during browser startup, but for tests
315 // we need to trigger creation of Profile-related services. 315 // we need to trigger creation of Profile-related services.
316 ChromeBrowserMainExtraPartsProfiles:: 316 ChromeBrowserMainExtraPartsProfiles::
317 EnsureBrowserContextKeyedServiceFactoriesBuilt(); 317 EnsureBrowserContextKeyedServiceFactoriesBuilt();
318 318
319 if (prefs_.get()) 319 if (prefs_.get())
320 user_prefs::UserPrefs::Set(this, prefs_.get()); 320 user_prefs::UserPrefs::Set(this, prefs_.get());
321 else 321 else
322 CreateTestingPrefService(); 322 CreateTestingPrefService();
323 323
324 if (!base::PathExists(profile_path_)) 324 if (!base::PathExists(profile_path_))
325 file_util::CreateDirectory(profile_path_); 325 base::CreateDirectory(profile_path_);
326 326
327 // TODO(joaodasilva): remove this once this PKS isn't created in ProfileImpl 327 // TODO(joaodasilva): remove this once this PKS isn't created in ProfileImpl
328 // anymore, after converting the PrefService to a PKS. Until then it must 328 // anymore, after converting the PrefService to a PKS. Until then it must
329 // be associated with a TestingProfile too. 329 // be associated with a TestingProfile too.
330 if (!IsOffTheRecord()) 330 if (!IsOffTheRecord())
331 CreateProfilePolicyConnector(); 331 CreateProfilePolicyConnector();
332 332
333 extensions::ExtensionSystemFactory::GetInstance()->SetTestingFactory( 333 extensions::ExtensionSystemFactory::GetInstance()->SetTestingFactory(
334 this, extensions::TestExtensionSystem::Build); 334 this, extensions::TestExtensionSystem::Build);
335 335
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 return scoped_ptr<TestingProfile>(new TestingProfile( 910 return scoped_ptr<TestingProfile>(new TestingProfile(
911 path_, 911 path_,
912 delegate_, 912 delegate_,
913 extension_policy_, 913 extension_policy_,
914 pref_service_.Pass(), 914 pref_service_.Pass(),
915 incognito_, 915 incognito_,
916 managed_user_id_, 916 managed_user_id_,
917 policy_service_.Pass(), 917 policy_service_.Pass(),
918 testing_factories_)); 918 testing_factories_));
919 } 919 }
OLDNEW
« no previous file with comments | « chrome/test/base/in_process_browser_test.cc ('k') | chrome/test/chromedriver/chrome/zip_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698