OLD | NEW |
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" |
11 #include "base/deferred_sequenced_task_runner.h" | 11 #include "base/deferred_sequenced_task_runner.h" |
12 #include "base/files/file_enumerator.h" | 12 #include "base/files/file_enumerator.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram_macros.h" |
16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
17 #include "base/prefs/scoped_user_pref_update.h" | 17 #include "base/prefs/scoped_user_pref_update.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
21 #include "base/trace_event/trace_event.h" | 21 #include "base/trace_event/trace_event.h" |
22 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 22 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/chrome_notification_types.h" | 24 #include "chrome/browser/chrome_notification_types.h" |
25 #include "chrome/browser/download/download_service.h" | 25 #include "chrome/browser/download/download_service.h" |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 // |profile| could be null if the user doesn't have a profile yet and the path | 366 // |profile| could be null if the user doesn't have a profile yet and the path |
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 // If the profile is already loaded (e.g., chrome.exe launched twice), just | 379 // If the profile is already loaded (e.g., chrome.exe launched twice), just |
378 // return it. | 380 // return it. |
379 Profile* profile = GetProfileByPath(profile_dir); | 381 Profile* profile = GetProfileByPath(profile_dir); |
380 if (NULL != profile) | 382 if (NULL != profile) |
381 return profile; | 383 return profile; |
382 | 384 |
383 profile = CreateProfileHelper(profile_dir); | 385 profile = CreateProfileHelper(profile_dir); |
384 DCHECK(profile); | 386 DCHECK(profile); |
385 if (profile) { | 387 if (profile) { |
386 bool result = AddProfile(profile); | 388 bool result = AddProfile(profile); |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 last_non_supervised_profile_path.BaseName().MaybeAsASCII()); | 1368 last_non_supervised_profile_path.BaseName().MaybeAsASCII()); |
1367 FinishDeletingProfile(profile_to_delete_path); | 1369 FinishDeletingProfile(profile_to_delete_path); |
1368 } | 1370 } |
1369 } | 1371 } |
1370 } | 1372 } |
1371 #endif | 1373 #endif |
1372 | 1374 |
1373 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1375 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
1374 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1376 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
1375 } | 1377 } |
OLD | NEW |