summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroysteine <oysteine@chromium.org>2015-08-27 15:50:56 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-27 22:51:56 +0000
commit5542fc35e7c9fb4d233898bcd42a8bbea15f7e69 (patch)
tree9422c7b65e1eba7a7ad0699d91f95ff375c1d997
parent9d44d4f3f57d87133a4ba7fb851f03018a650a34 (diff)
downloadchromium_src-5542fc35e7c9fb4d233898bcd42a8bbea15f7e69.zip
chromium_src-5542fc35e7c9fb4d233898bcd42a8bbea15f7e69.tar.gz
chromium_src-5542fc35e7c9fb4d233898bcd42a8bbea15f7e69.tar.bz2
Background tracing: Defer validation on missing profile
If the profile hasn't been loaded or hasn't been created yet by the time we activate a tracing scenario, we skip validation rather than forcing a profile creation, and rely on the validation happening when the trace is finalized instead. R=shatch BUG=514863 Review URL: https://codereview.chromium.org/1314263003 Cr-Commit-Position: refs/heads/master@{#346017}
-rw-r--r--chrome/browser/tracing/chrome_tracing_delegate.cc49
1 files changed, 39 insertions, 10 deletions
diff --git a/chrome/browser/tracing/chrome_tracing_delegate.cc b/chrome/browser/tracing/chrome_tracing_delegate.cc
index 0fd3a20..bc333821 100644
--- a/chrome/browser/tracing/chrome_tracing_delegate.cc
+++ b/chrome/browser/tracing/chrome_tracing_delegate.cc
@@ -49,21 +49,33 @@ scoped_ptr<content::TraceUploader> ChromeTracingDelegate::GetTraceUploader(
new TraceCrashServiceUploader(request_context));
}
-bool ChromeTracingDelegate::IsAllowedToBeginBackgroundScenario(
- const content::BackgroundTracingConfig& config,
- bool requires_anonymized_data) {
- Profile* profile = g_browser_process->profile_manager()
- ->GetLastUsedProfile()
- ->GetOriginalProfile();
- DCHECK(profile);
+namespace {
+
+enum PermitMissingProfile { PROFILE_REQUIRED, PROFILE_NOT_REQUIRED };
+
+bool ProfileAllowsScenario(const content::BackgroundTracingConfig& config,
+ PermitMissingProfile profile_permission) {
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ if (!profile_manager)
+ return false;
+
+ Profile* profile = profile_manager->GetProfileByPath(
+ profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir()));
+
+ // If the profile hasn't loaded or been created yet, we allow the scenario
+ // to start up, but not be finalized.
+ if (!profile) {
+ if (profile_permission == PROFILE_REQUIRED)
+ return false;
+ else
+ return true;
+ }
+
// Safeguard, in case background tracing is responsible for a crash on
// startup.
if (profile->GetLastSessionExitType() == Profile::EXIT_CRASHED)
return false;
- if (requires_anonymized_data && chrome::IsOffTheRecordSessionActive())
- return false;
-
if (config.tracing_mode() == content::BackgroundTracingConfig::PREEMPTIVE) {
PrefService* local_state = g_browser_process->local_state();
DCHECK(local_state);
@@ -81,12 +93,29 @@ bool ChromeTracingDelegate::IsAllowedToBeginBackgroundScenario(
return true;
}
+} // namespace
+
+bool ChromeTracingDelegate::IsAllowedToBeginBackgroundScenario(
+ const content::BackgroundTracingConfig& config,
+ bool requires_anonymized_data) {
+ if (!ProfileAllowsScenario(config, PROFILE_NOT_REQUIRED))
+ return false;
+
+ if (requires_anonymized_data && chrome::IsOffTheRecordSessionActive())
+ return false;
+
+ return true;
+}
+
bool ChromeTracingDelegate::IsAllowedToEndBackgroundScenario(
const content::BackgroundTracingConfig& config,
bool requires_anonymized_data) {
if (requires_anonymized_data && incognito_launched_)
return false;
+ if (!ProfileAllowsScenario(config, PROFILE_REQUIRED))
+ return false;
+
if (config.tracing_mode() == content::BackgroundTracingConfig::PREEMPTIVE) {
PrefService* local_state = g_browser_process->local_state();
DCHECK(local_state);