Commit fe1a134d authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

[heap profiler] Reenable sampling profiler on Android.

It has been temporarily disabled within r666174.

BUG=973430

Change-Id: I747e166f1c6dcba478da897d0c661c5bb6cf2371
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1726661Reviewed-by: default avatarMike Wittman <wittman@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682977}
parent c19200de
......@@ -1874,6 +1874,7 @@ if (is_android) {
"//chrome/browser/ui",
"//chrome/child",
"//chrome/common",
"//chrome/common/profiler",
"//chrome/gpu",
"//chrome/renderer",
"//components/gwp_asan/buildflags",
......
......@@ -13,6 +13,7 @@
#include "base/trace_event/trace_event.h"
#include "chrome/browser/android/chrome_startup_flags.h"
#include "chrome/browser/android/metrics/uma_utils.h"
#include "chrome/common/profiler/main_thread_stack_sampling_profiler.h"
#include "components/policy/core/browser/android/android_combined_policy_provider.h"
#include "components/safe_browsing/buildflags.h"
#include "components/startup_metric_utils/browser/startup_metric_utils.h"
......@@ -25,17 +26,16 @@
using safe_browsing::SafeBrowsingApiHandler;
// ChromeMainDelegateAndroid is created when the library is loaded. It is always
// done in the process's main Java thread. But for non browser process, e.g.
// done in the process' main Java thread. But for a non-browser process, e.g.
// renderer process, it is not the native Chrome's main thread.
ChromeMainDelegateAndroid::ChromeMainDelegateAndroid() {
}
ChromeMainDelegateAndroid::~ChromeMainDelegateAndroid() {
}
ChromeMainDelegateAndroid::ChromeMainDelegateAndroid() = default;
ChromeMainDelegateAndroid::~ChromeMainDelegateAndroid() = default;
bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) {
// Start the sampling profiler as early as possible.
sampling_profiler_ = std::make_unique<MainThreadStackSamplingProfiler>();
#if BUILDFLAG(SAFE_BROWSING_DB_REMOTE)
safe_browsing_api_handler_.reset(
new safe_browsing::SafeBrowsingApiHandlerBridge());
......
......@@ -12,6 +12,8 @@
#include "components/safe_browsing/buildflags.h"
#include "content/public/browser/browser_main_runner.h"
class MainThreadStackSamplingProfiler;
namespace safe_browsing {
class SafeBrowsingApiHandler;
}
......@@ -32,6 +34,7 @@ class ChromeMainDelegateAndroid : public ChromeMainDelegate {
void ProcessExiting(const std::string& process_type) override;
private:
std::unique_ptr<MainThreadStackSamplingProfiler> sampling_profiler_;
std::unique_ptr<content::BrowserMainRunner> browser_runner_;
#if BUILDFLAG(SAFE_BROWSING_DB_REMOTE)
......
......@@ -159,12 +159,8 @@ std::unique_ptr<ThreadProfiler> ThreadProfiler::CreateAndStartOnMainThread() {
// static
void ThreadProfiler::SetMainThreadTaskRunner(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
#if !defined(OS_ANDROID)
// TODO(asvitkine): The code path where we create the profiler instance in
// chrome_main.cc does not run on Android.
DCHECK(g_main_thread_instance);
g_main_thread_instance->SetMainThreadTaskRunnerImpl(task_runner);
#endif
}
void ThreadProfiler::SetAuxUnwinderFactory(
......
......@@ -5673,6 +5673,7 @@ test("chrome_app_unittests") {
"//base/test:test_support",
"//chrome/browser",
"//chrome/child",
"//chrome/common/profiler",
"//chrome/gpu",
"//components/crash/core/common",
"//components/flags_ui:switches",
......
......@@ -200,14 +200,12 @@ int LaunchChromeTests(size_t parallel_jobs,
const auto& command_line = *base::CommandLine::ForCurrentProcess();
#if !defined(OS_ANDROID)
// Initialize sampling profiler for tests that relaunching a browser. This
// mimics the behavior in standalone Chrome, where this is done in
// chrome/app/chrome_main.cc, which does not get called by tests.
std::unique_ptr<MainThreadStackSamplingProfiler> sampling_profiler;
if (command_line.HasSwitch(content::kLaunchAsBrowser))
sampling_profiler = std::make_unique<MainThreadStackSamplingProfiler>();
#endif
#if defined(OS_LINUX) || defined(OS_ANDROID)
ChromeCrashReporterClient::Create();
......
......@@ -250,12 +250,8 @@ void CallStackProfileBuilder::SetParentProfileCollectorForChildProcess(
void CallStackProfileBuilder::PassProfilesToMetricsProvider(
SampledProfile sampled_profile) {
if (sampled_profile.process() == BROWSER_PROCESS) {
// TODO(crbug.com/973430): Remove the check once profile reporting on
// Android is sorted out.
#if !defined(OS_ANDROID)
GetBrowserProcessReceiverCallbackInstance().Run(profile_start_time_,
std::move(sampled_profile));
#endif
} else {
g_child_call_stack_profile_collector.Get()
.ChildCallStackProfileCollector::Collect(profile_start_time_,
......
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