| 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/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
| 12 #include "base/deferred_sequenced_task_runner.h" | 12 #include "base/deferred_sequenced_task_runner.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/files/file_enumerator.h" | 14 #include "base/files/file_enumerator.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/metrics/field_trial.h" | |
| 17 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 18 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
| 19 #include "base/prefs/scoped_user_pref_update.h" | 18 #include "base/prefs/scoped_user_pref_update.h" |
| 20 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 23 #include "chrome/browser/bookmarks/bookmark_model.h" | 22 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 24 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 25 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 26 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 ProfileMetrics::LogNumberOfProfiles(this); | 780 ProfileMetrics::LogNumberOfProfiles(this); |
| 782 content::NotificationService::current()->Notify( | 781 content::NotificationService::current()->Notify( |
| 783 chrome::NOTIFICATION_PROFILE_ADDED, | 782 chrome::NOTIFICATION_PROFILE_ADDED, |
| 784 content::Source<Profile>(profile), | 783 content::Source<Profile>(profile), |
| 785 content::NotificationService::NoDetails()); | 784 content::NotificationService::NoDetails()); |
| 786 } | 785 } |
| 787 | 786 |
| 788 void ProfileManager::DoFinalInitForServices(Profile* profile, | 787 void ProfileManager::DoFinalInitForServices(Profile* profile, |
| 789 bool go_off_the_record) { | 788 bool go_off_the_record) { |
| 790 #if defined(ENABLE_EXTENSIONS) | 789 #if defined(ENABLE_EXTENSIONS) |
| 791 // Set up a field trial to determine the effectiveness of deferring | |
| 792 // creation of background extension RenderViews. | |
| 793 CR_DEFINE_STATIC_LOCAL(scoped_refptr<base::FieldTrial>, trial, ()); | |
| 794 static bool defer_creation = false; | |
| 795 | |
| 796 if (!trial.get()) { | |
| 797 const base::FieldTrial::Probability kDivisor = 100; | |
| 798 | |
| 799 // Enable the deferred creation for 50% of the users. | |
| 800 base::FieldTrial::Probability probability_per_group = 50; | |
| 801 | |
| 802 // After August 31, 2014 builds, it will always be in default group | |
| 803 // (defer_creation == false). | |
| 804 trial = base::FieldTrialList::FactoryGetFieldTrial( | |
| 805 "DeferBackgroundExtensionCreation", | |
| 806 kDivisor, | |
| 807 "RateLimited", | |
| 808 2014, | |
| 809 8, | |
| 810 31, | |
| 811 base::FieldTrial::ONE_TIME_RANDOMIZED, | |
| 812 NULL); | |
| 813 | |
| 814 // Add group for deferred creation of background extension RenderViews. | |
| 815 int defer_creation_group = | |
| 816 trial->AppendGroup("Deferred", probability_per_group); | |
| 817 defer_creation = trial->group() == defer_creation_group; | |
| 818 } | |
| 819 | |
| 820 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( | 790 extensions::ExtensionSystem::Get(profile)->InitForRegularProfile( |
| 821 !go_off_the_record, defer_creation); | 791 !go_off_the_record); |
| 822 // During tests, when |profile| is an instance of TestingProfile, | 792 // During tests, when |profile| is an instance of TestingProfile, |
| 823 // ExtensionSystem might not create an ExtensionService. | 793 // ExtensionSystem might not create an ExtensionService. |
| 824 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { | 794 if (extensions::ExtensionSystem::Get(profile)->extension_service()) { |
| 825 profile->GetHostContentSettingsMap()->RegisterExtensionService( | 795 profile->GetHostContentSettingsMap()->RegisterExtensionService( |
| 826 extensions::ExtensionSystem::Get(profile)->extension_service()); | 796 extensions::ExtensionSystem::Get(profile)->extension_service()); |
| 827 } | 797 } |
| 828 #endif | 798 #endif |
| 829 #if defined(ENABLE_MANAGED_USERS) | 799 #if defined(ENABLE_MANAGED_USERS) |
| 830 // Initialization needs to happen after extension system initialization (for | 800 // Initialization needs to happen after extension system initialization (for |
| 831 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the | 801 // extension::ManagementPolicy) and InitProfileUserPrefs (for setting the |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 ProfileManager::ProfileInfo::ProfileInfo( | 1237 ProfileManager::ProfileInfo::ProfileInfo( |
| 1268 Profile* profile, | 1238 Profile* profile, |
| 1269 bool created) | 1239 bool created) |
| 1270 : profile(profile), | 1240 : profile(profile), |
| 1271 created(created) { | 1241 created(created) { |
| 1272 } | 1242 } |
| 1273 | 1243 |
| 1274 ProfileManager::ProfileInfo::~ProfileInfo() { | 1244 ProfileManager::ProfileInfo::~ProfileInfo() { |
| 1275 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1245 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
| 1276 } | 1246 } |
| OLD | NEW |