Commit da3861ea authored by David Dorwin's avatar David Dorwin Committed by Commit Bot

[fuchsia] Register crash product names for components

Crashes in WebEngine are reported as FuchsiaWebEngine, and crashes in
CastRunner are reported as FuchsiaCastRunner.
The version is also reported. The channel is the empty string for now.

Bug: 1050339
Test: While the components are running, run `fx bugreport`. Then verify the mapping is registered in the bugreport's inspect.json at crash_reports.cmx > fidl > crash_register > mappings.
Change-Id: I86ffc4c0c1af19f9f34a462ee7fce77068cbded1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315796Reviewed-by: default avatarWez <wez@chromium.org>
Commit-Queue: David Dorwin <ddorwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791383}
parent 78240e99
......@@ -11,6 +11,7 @@ import("//testing/test.gni")
source_set("base") {
sources = [
"config_reader.cc",
"feedback_registration.cc",
"fuchsia_dir_scheme.cc",
"init_logging.cc",
"inspect.cc",
......@@ -19,6 +20,7 @@ source_set("base") {
]
public = [
"config_reader.h",
"feedback_registration.h",
"fuchsia_dir_scheme.h",
"init_logging.h",
"inspect.h",
......@@ -28,8 +30,10 @@ source_set("base") {
deps = [
"//base",
"//components/version_info",
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.feedback",
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.mem",
"//third_party/fuchsia-sdk/sdk/pkg/fdio",
"//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
"//third_party/fuchsia-sdk/sdk/pkg/sys_inspect_cpp",
"//url",
]
......
// 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 "fuchsia/base/feedback_registration.h"
#include <fuchsia/feedback/cpp/fidl.h>
#include <lib/sys/cpp/component_context.h>
#include "base/fuchsia/process_context.h"
#include "base/strings/string_piece.h"
#include "components/version_info/version_info.h"
namespace cr_fuchsia {
void RegisterCrashReportingFields(base::StringPiece component_url,
base::StringPiece crash_product_name) {
fuchsia::feedback::CrashReportingProduct product_data;
product_data.set_name(crash_product_name.as_string());
product_data.set_version(version_info::GetVersionNumber());
// TODO(https://crbug.com/1077428): Use the actual channel when appropriate.
// For now, always set it to the empty string to avoid reporting "missing".
product_data.set_channel("");
base::ComponentContextForProcess()
->svc()
->Connect<fuchsia::feedback::CrashReportingProductRegister>()
->Upsert(component_url.as_string(), std::move(product_data));
}
} // namespace cr_fuchsia
// 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 FUCHSIA_BASE_FEEDBACK_REGISTRATION_H_
#define FUCHSIA_BASE_FEEDBACK_REGISTRATION_H_
#include "base/strings/string_piece_forward.h"
namespace cr_fuchsia {
// Overrides the default Fuchsia product info in crash reports.
// Crashes for the component |component_url| will contain |crash_product_name|,
// the version from version_info, and an appropriate value for the release
// channel. |component_url| must match the current component. The calling
// process must have access to "fuchsia.feedback.CrashReportingProductRegister".
void RegisterCrashReportingFields(base::StringPiece component_url,
base::StringPiece crash_product_name);
} // namespace cr_fuchsia
#endif // FUCHSIA_BASE_FEEDBACK_REGISTRATION_H_
\ No newline at end of file
......@@ -8,6 +8,7 @@
],
"services": [
"fuchsia.feedback.ComponentDataRegister",
"fuchsia.feedback.CrashReportingProductRegister",
"fuchsia.logger.LogSink",
"fuchsia.process.Launcher"
]
......
......@@ -16,6 +16,7 @@
#include "base/run_loop.h"
#include "base/task/single_thread_task_executor.h"
#include "components/version_info/version_info.h"
#include "fuchsia/base/feedback_registration.h"
#include "fuchsia/base/init_logging.h"
#include "fuchsia/base/inspect.h"
#include "fuchsia/base/lifecycle_impl.h"
......@@ -23,6 +24,12 @@
namespace {
constexpr char kFeedbackAnnotationsNamespace[] = "web-engine";
constexpr char kCrashProductName[] = "FuchsiaWebEngine";
// TODO(https://fxbug.dev/51490): Use a programmatic mechanism to obtain this.
constexpr char kComponentUrl[] =
"fuchsia-pkg://fuchsia.com/web_engine#meta/context_provider.cmx";
std::string GetVersionString() {
std::string version_string = version_info::GetVersionNumber();
#if !defined(OFFICIAL_BUILD)
......@@ -31,11 +38,13 @@ std::string GetVersionString() {
return version_string;
}
// TODO(ddorwin): Move to feedback_registration.h.
// TODO(https://crbug.com/1010222): Add annotations at Context startup, once
// Contexts are moved out to run in their own components.
void RegisterFeedbackAnnotations() {
fuchsia::feedback::ComponentData component_data;
component_data.set_namespace_("web-engine");
component_data.set_namespace_(kFeedbackAnnotationsNamespace);
// TODO(https://crbug.com/1077428): Add release channel to the annotations.
component_data.mutable_annotations()->push_back(
{"version", version_info::GetVersionNumber()});
base::ComponentContextForProcess()
......@@ -49,6 +58,8 @@ void RegisterFeedbackAnnotations() {
int ContextProviderMain() {
base::SingleThreadTaskExecutor main_task_executor(base::MessagePumpType::UI);
cr_fuchsia::RegisterCrashReportingFields(kComponentUrl, kCrashProductName);
if (!cr_fuchsia::InitLoggingFromCommandLine(
*base::CommandLine::ForCurrentProcess())) {
return 1;
......
per-file *.cmx=set noparent
per-file *.cmx=file://fuchsia/SECURITY_OWNERS
......@@ -8,6 +8,7 @@
"fuchsia.accessibility.semantics.SemanticsManager",
"fuchsia.camera3.DeviceWatcher",
"fuchsia.device.NameProvider",
"fuchsia.feedback.CrashReportingProductRegister",
"fuchsia.fonts.Provider",
"fuchsia.intl.PropertyProvider",
"fuchsia.logger.LogSink",
......
......@@ -13,6 +13,7 @@
#include "base/task/single_thread_task_executor.h"
#include "base/values.h"
#include "fuchsia/base/config_reader.h"
#include "fuchsia/base/feedback_registration.h"
#include "fuchsia/base/fuchsia_dir_scheme.h"
#include "fuchsia/base/init_logging.h"
#include "fuchsia/base/inspect.h"
......@@ -20,6 +21,11 @@
namespace {
constexpr char kCrashProductName[] = "FuchsiaCastRunner";
// TODO(https://fxbug.dev/51490): Use a programmatic mechanism to obtain this.
constexpr char kComponentUrl[] =
"fuchsia-pkg://fuchsia.com/cast_runner#meta/cast_runner.cmx";
bool IsHeadless() {
constexpr char kHeadlessConfigKey[] = "headless";
......@@ -38,6 +44,8 @@ int main(int argc, char** argv) {
base::SingleThreadTaskExecutor io_task_executor(base::MessagePumpType::IO);
base::RunLoop run_loop;
cr_fuchsia::RegisterCrashReportingFields(kComponentUrl, kCrashProductName);
base::CommandLine::Init(argc, argv);
CHECK(cr_fuchsia::InitLoggingFromCommandLine(
*base::CommandLine::ForCurrentProcess()))
......
per-file *.cmx=set noparent
per-file *.cmx=file://fuchsia/SECURITY_OWNERS
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