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

Side by Side Diff: chrome/browser/profiles/profile_manager.cc

Issue 937713003: Add several new TRACE call and UMA metrics for GetProfile() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo Created 5 years, 10 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) 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/browser/profiles/profile_manager.h" 5 #include "chrome/browser/profiles/profile_manager.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 // is on a read-only volume (preventing Chrome from making a new one). 367 // is on a read-only volume (preventing Chrome from making a new one).
368 // However, most callers of this function immediately dereference the result 368 // However, most callers of this function immediately dereference the result
369 // which would lead to crashes in a variety of call sites. Assert here to 369 // which would lead to crashes in a variety of call sites. Assert here to
370 // figure out how common this is. http://crbug.com/383019 370 // figure out how common this is. http://crbug.com/383019
371 CHECK(profile) << profile_manager->user_data_dir().AsUTF8Unsafe(); 371 CHECK(profile) << profile_manager->user_data_dir().AsUTF8Unsafe();
372 return profile; 372 return profile;
373 } 373 }
374 374
375 Profile* ProfileManager::GetProfile(const base::FilePath& profile_dir) { 375 Profile* ProfileManager::GetProfile(const base::FilePath& profile_dir) {
376 TRACE_EVENT0("browser", "ProfileManager::GetProfile"); 376 TRACE_EVENT0("browser", "ProfileManager::GetProfile");
377 SCOPED_UMA_HISTOGRAM_TIMER("Profile.GetProfile");
378 377
379 // If the profile is already loaded (e.g., chrome.exe launched twice), just 378 // If the profile is already loaded (e.g., chrome.exe launched twice), just
380 // return it. 379 // return it.
381 Profile* profile = GetProfileByPath(profile_dir); 380 Profile* profile = GetProfileByPath(profile_dir);
382 if (NULL != profile) 381 if (NULL != profile)
383 return profile; 382 return profile;
383 return SetupProfile(profile_dir);
384 }
384 385
385 profile = CreateProfileHelper(profile_dir); 386 Profile* ProfileManager::SetupProfile(const base::FilePath& profile_dir) {
387 TRACE_EVENT0("browser", "ProfileManager::SetupProfile");
388 SCOPED_UMA_HISTOGRAM_LONG_TIMER("Profile.SetupProfile");
389 Profile* profile = CreateProfileHelper(profile_dir);
386 DCHECK(profile); 390 DCHECK(profile);
387 if (profile) { 391 if (profile) {
388 bool result = AddProfile(profile); 392 bool result = AddProfile(profile);
389 DCHECK(result); 393 DCHECK(result);
390 } 394 }
391 return profile; 395 return profile;
392 } 396 }
393 397
394 size_t ProfileManager::GetNumberOfProfiles() { 398 size_t ProfileManager::GetNumberOfProfiles() {
395 return GetProfileInfoCache().GetNumberOfProfiles(); 399 return GetProfileInfoCache().GetNumberOfProfiles();
396 } 400 }
397 401
398 void ProfileManager::CreateProfileAsync( 402 void ProfileManager::CreateProfileAsync(
399 const base::FilePath& profile_path, 403 const base::FilePath& profile_path,
400 const CreateCallback& callback, 404 const CreateCallback& callback,
401 const base::string16& name, 405 const base::string16& name,
402 const base::string16& icon_url, 406 const base::string16& icon_url,
403 const std::string& supervised_user_id) { 407 const std::string& supervised_user_id) {
404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 408 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
405 TRACE_EVENT1("startup", 409 TRACE_EVENT1("browser,startup",
406 "ProfileManager::CreateProfileAsync", 410 "ProfileManager::CreateProfileAsync",
407 "profile_path", 411 "profile_path",
408 profile_path.value().c_str()); 412 profile_path.MaybeAsASCII());
409 413
410 // Make sure that this profile is not pending deletion. 414 // Make sure that this profile is not pending deletion.
411 if (IsProfileMarkedForDeletion(profile_path)) { 415 if (IsProfileMarkedForDeletion(profile_path)) {
412 if (!callback.is_null()) 416 if (!callback.is_null())
413 callback.Run(NULL, Profile::CREATE_STATUS_LOCAL_FAIL); 417 callback.Run(NULL, Profile::CREATE_STATUS_LOCAL_FAIL);
414 return; 418 return;
415 } 419 }
416 420
417 // Create the profile if needed and collect its ProfileInfo. 421 // Create the profile if needed and collect its ProfileInfo.
418 ProfilesInfoMap::iterator iter = profiles_info_.find(profile_path); 422 ProfilesInfoMap::iterator iter = profiles_info_.find(profile_path);
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 1073
1070 // Log the profile size after a reasonable startup delay. 1074 // Log the profile size after a reasonable startup delay.
1071 BrowserThread::PostDelayedTask( 1075 BrowserThread::PostDelayedTask(
1072 BrowserThread::FILE, FROM_HERE, 1076 BrowserThread::FILE, FROM_HERE,
1073 base::Bind(&ProfileSizeTask, profile->GetPath(), enabled_app_count), 1077 base::Bind(&ProfileSizeTask, profile->GetPath(), enabled_app_count),
1074 base::TimeDelta::FromSeconds(112)); 1078 base::TimeDelta::FromSeconds(112));
1075 } 1079 }
1076 1080
1077 Profile* ProfileManager::CreateProfileHelper(const base::FilePath& path) { 1081 Profile* ProfileManager::CreateProfileHelper(const base::FilePath& path) {
1078 TRACE_EVENT0("browser", "ProfileManager::CreateProfileHelper"); 1082 TRACE_EVENT0("browser", "ProfileManager::CreateProfileHelper");
1083 SCOPED_UMA_HISTOGRAM_TIMER("Profile.CreateProfileHelperTime");
1084
1079 return Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); 1085 return Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS);
1080 } 1086 }
1081 1087
1082 Profile* ProfileManager::CreateProfileAsyncHelper(const base::FilePath& path, 1088 Profile* ProfileManager::CreateProfileAsyncHelper(const base::FilePath& path,
1083 Delegate* delegate) { 1089 Delegate* delegate) {
1084 return Profile::CreateProfile(path, 1090 return Profile::CreateProfile(path,
1085 delegate, 1091 delegate,
1086 Profile::CREATE_MODE_ASYNCHRONOUS); 1092 Profile::CREATE_MODE_ASYNCHRONOUS);
1087 } 1093 }
1088 1094
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 last_non_supervised_profile_path.BaseName().MaybeAsASCII()); 1384 last_non_supervised_profile_path.BaseName().MaybeAsASCII());
1379 FinishDeletingProfile(profile_to_delete_path); 1385 FinishDeletingProfile(profile_to_delete_path);
1380 } 1386 }
1381 } 1387 }
1382 } 1388 }
1383 #endif 1389 #endif
1384 1390
1385 ProfileManagerWithoutInit::ProfileManagerWithoutInit( 1391 ProfileManagerWithoutInit::ProfileManagerWithoutInit(
1386 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { 1392 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) {
1387 } 1393 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698