[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / components / fuchsia_component_support / feedback_registration.cc
1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/fuchsia_component_support/feedback_registration.h"
6
7 #include <fuchsia/feedback/cpp/fidl.h>
8 #include <lib/sys/cpp/component_context.h>
9
10 #include "base/check.h"
11 #include "base/fuchsia/process_context.h"
12 #include "base/strings/string_piece.h"
13 #include "base/strings/string_util.h"
14 #include "build/branding_buildflags.h"
15 #include "components/version_info/version_info.h"
16
17 namespace fuchsia_component_support {
18
19 namespace {
20
21 constexpr char kAbsoluteComponentUrlSchemPrefix[] = "fuchsia-pkg://";
22
23 }  // namespace
24
25 void RegisterProductDataForCrashReporting(
26     base::StringPiece absolute_component_url,
27     base::StringPiece crash_product_name) {
28   DCHECK(base::StartsWith(absolute_component_url,
29                           kAbsoluteComponentUrlSchemPrefix));
30
31   fuchsia::feedback::CrashReportingProduct product_data;
32   product_data.set_name(std::string(crash_product_name));
33   product_data.set_version(std::string(version_info::GetVersionNumber()));
34   // TODO(https://crbug.com/1077428): Use the actual channel when appropriate.
35   // For now, always set it to the empty string to avoid reporting "missing".
36   product_data.set_channel("");
37
38   auto crash_reporting_service =
39       base::ComponentContextForProcess()
40           ->svc()
41           ->Connect<fuchsia::feedback::CrashReportingProductRegister>();
42
43   // Only register the |crash_product_name| for official Chrome-branded builds.
44   // Otherwise, the crashes will be handled as non-component-specific crashes.
45   // Since Fuchsia handles crashes, it is possible that Fuchsia will upload a
46   // crash for an unofficial and/or unbranded build of a Chromium-based
47   // component if it is running on an official Fuchsia build. To avoid adding
48   // noise from such crash reports, which are not received on other platforms,
49   // do not set a product name for such builds.
50 #if BUILDFLAG(GOOGLE_CHROME_BRANDING) && defined(OFFICIAL_BUILD)
51   crash_reporting_service->Upsert(std::string(absolute_component_url),
52                                   std::move(product_data));
53 #endif
54 }
55
56 void RegisterProductDataForFeedback(base::StringPiece component_namespace) {
57   fuchsia::feedback::ComponentData component_data;
58   component_data.set_namespace_(std::string(component_namespace));
59   // TODO(https://crbug.com/1077428): Add release channel to the annotations.
60   component_data.mutable_annotations()->push_back(
61       {"version", std::string(version_info::GetVersionNumber())});
62   base::ComponentContextForProcess()
63       ->svc()
64       ->Connect<fuchsia::feedback::ComponentDataRegister>()
65       ->Upsert(std::move(component_data), []() {});
66 }
67
68 }  // namespace fuchsia_component_support