Commit c466f1fe authored by Oksana Zhuravlova's avatar Oksana Zhuravlova Committed by Commit Bot

[aw][tracing] Set up bg tracing on startup

This change adds code to enable background tracing in WebView under the
following conditions:
- system tracing is configured
- the config specifies system tracing mode.

Bug: b/170513316
Change-Id: I5a38255a0098d3d91bbdd33facb23df5c9c8f2c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2508312
Commit-Queue: Oksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Reviewed-by: default avatarMichael Bai <michaelbai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823759}
parent ef0225f0
......@@ -170,6 +170,8 @@ source_set("browser") {
"tracing/aw_tracing_controller.h",
"tracing/aw_tracing_delegate.cc",
"tracing/aw_tracing_delegate.h",
"tracing/background_tracing_field_trial.cc",
"tracing/background_tracing_field_trial.h",
]
deps = [
......
......@@ -79,6 +79,9 @@ include_rules = [
"+mojo/core/embedder/embedder.h",
"+mojo/public/cpp/system",
# Background tracing support
"+services/tracing/public/cpp",
"+storage/browser/quota",
"+storage/common/quota",
......
......@@ -15,6 +15,7 @@
#include "android_webview/browser/aw_web_ui_controller_factory.h"
#include "android_webview/browser/metrics/aw_metrics_service_client.h"
#include "android_webview/browser/network_service/aw_network_change_notifier_factory.h"
#include "android_webview/browser/tracing/background_tracing_field_trial.h"
#include "android_webview/common/aw_descriptors.h"
#include "android_webview/common/aw_paths.h"
#include "android_webview/common/aw_resource.h"
......@@ -141,6 +142,8 @@ void AwBrowserMainParts::PostCreateThreads() {
heap_profiling::Mode mode = heap_profiling::GetModeForStartup();
if (mode != heap_profiling::Mode::kNone)
heap_profiling::Supervisor::GetInstance()->Start(base::NullCallback());
SetupBackgroundTracingFieldTrial();
}
} // namespace android_webview
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "android_webview/browser/tracing/background_tracing_field_trial.h"
#include "base/bind_helpers.h"
#include "content/public/browser/background_tracing_config.h"
#include "content/public/browser/background_tracing_manager.h"
#include "services/tracing/public/cpp/tracing_features.h"
namespace android_webview {
void SetupBackgroundTracingFieldTrial() {
std::unique_ptr<content::BackgroundTracingConfig> config =
content::BackgroundTracingManager::GetInstance()
->GetBackgroundTracingConfig();
if (config &&
config->tracing_mode() == content::BackgroundTracingConfig::SYSTEM &&
tracing::ShouldSetupSystemTracing()) {
// Only enable background tracing for system tracing if the system producer
// is enabled.
content::BackgroundTracingManager::GetInstance()->SetActiveScenario(
std::move(config),
base::BindRepeating(
base::DoNothing::Repeatedly<std::unique_ptr<std::string>,
content::BackgroundTracingManager::
FinishedProcessingCallback>()),
content::BackgroundTracingManager::ANONYMIZE_DATA);
}
}
} // namespace android_webview
\ No newline at end of file
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ANDROID_WEBVIEW_BROWSER_TRACING_BACKGROUND_TRACING_FIELD_TRIAL_H_
#define ANDROID_WEBVIEW_BROWSER_TRACING_BACKGROUND_TRACING_FIELD_TRIAL_H_
namespace android_webview {
void SetupBackgroundTracingFieldTrial();
} // namespace android_webview
#endif // ANDROID_WEBVIEW_BROWSER_TRACING_BACKGROUND_TRACING_FIELD_TRIAL_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment