Commit 596db341 authored by Jenny Zhang's avatar Jenny Zhang Committed by Commit Bot

Enable Lacros to send a simple feedback report with all Lacros data.

The simple lacros feedback report includes the following:

1. Lacros feedback reports are sent with ChromeOS product id, so
that they will be found under ChromeOS product on Listnr.

2. Prefix the chrome version string with "Lacros ", so that lacros
reports can be filtered by "Version" (for example "Lacros") on Listnr.

3. Attach lacros user log in the system log.

Bug:1109387
TEST:
1. Open Lacros browser, send a feedback report by clicking
"Report an issue" under Help menu.
2. Verify the report can be found at
http://listnr site. The chrome version string should have
a "Lacros " at the beginning, for example, "Lacros 86.0.4238.0".
3. Verify the report contains both system_logs.zip and histograms.zip.
The system log should contain lacros log data from
/home/chronos/user/lacros/lacros.log under "lacros_user_log" section.

Change-Id: I66578c33b027fd5334f5df3f0c42b5460b79faf3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2370804
Commit-Queue: Jenny Zhang <jennyz@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801514}
parent c5596591
......@@ -4110,6 +4110,8 @@ static_library("browser") {
sources += [
"lacros/lacros_chrome_service_delegate_impl.cc",
"lacros/lacros_chrome_service_delegate_impl.h",
"lacros/system_logs/user_log_files_log_source.cc",
"lacros/system_logs/user_log_files_log_source.h",
"metrics/lacros_metrics_provider.cc",
"metrics/lacros_metrics_provider.h",
"notifications/notification_platform_bridge_chromeos.cc",
......
......@@ -7,6 +7,7 @@
#include <memory>
#include "build/build_config.h"
#include "build/lacros_buildflags.h"
#include "chrome/browser/feedback/system_logs/log_sources/chrome_internal_log_source.h"
#include "chrome/browser/feedback/system_logs/log_sources/crash_ids_source.h"
#include "chrome/browser/feedback/system_logs/log_sources/memory_details_log_source.h"
......@@ -25,6 +26,10 @@
#include "chrome/browser/chromeos/system_logs/ui_hierarchy_log_source.h"
#endif
#if BUILDFLAG(IS_LACROS)
#include "chrome/browser/lacros/system_logs/user_log_files_log_source.h"
#endif
namespace system_logs {
SystemLogsFetcher* BuildChromeSystemLogsFetcher(bool scrub_data) {
......@@ -50,6 +55,10 @@ SystemLogsFetcher* BuildChromeSystemLogsFetcher(bool scrub_data) {
fetcher->AddSource(std::make_unique<UiHierarchyLogSource>(scrub_data));
#endif
#if BUILDFLAG(IS_LACROS)
fetcher->AddSource(std::make_unique<UserLogFilesLogSource>());
#endif
return fetcher;
}
......
......@@ -68,6 +68,9 @@ constexpr char kExtensionsListKey[] = "extensions";
constexpr char kPowerApiListKey[] = "chrome.power extensions";
constexpr char kDataReductionProxyKey[] = "data_reduction_proxy";
constexpr char kChromeVersionTag[] = "CHROME VERSION";
#if BUILDFLAG(IS_LACROS)
constexpr char kLacrosChromeVersionPrefix[] = "Lacros ";
#endif
#if defined(OS_CHROMEOS)
constexpr char kArcPolicyComplianceReportKey[] =
"CHROMEOS_ARC_POLICY_COMPLIANCE_REPORT";
......@@ -266,7 +269,14 @@ void ChromeInternalLogSource::Fetch(SysLogsSourceCallback callback) {
auto response = std::make_unique<SystemLogsResponse>();
#if BUILDFLAG(IS_LACROS)
// Add a Lacros prefix string in the chrome version string to
// differentiate lacros chrome vs ash chrome in the feedback report.
response->emplace(kChromeVersionTag,
kLacrosChromeVersionPrefix + chrome::GetVersionString());
#else
response->emplace(kChromeVersionTag, chrome::GetVersionString());
#endif
#if defined(OS_CHROMEOS)
response->emplace(kChromeEnrollmentTag, GetEnrollmentStatusString());
......
// 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 "chrome/browser/lacros/system_logs/user_log_files_log_source.h"
#include "base/files/file_path.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "components/feedback/feedback_util.h"
#include "content/public/browser/browser_thread.h"
namespace system_logs {
namespace {
constexpr char kDefaultLogPath[] = "/home/chronos/user/lacros/lacros.log";
constexpr char kLogKey[] = "lacros_user_log";
// Maximum buffer size for user logs in bytes.
const int64_t kMaxLogSize = 1024 * 1024;
constexpr char kLogTruncated[] = "<earlier logs truncated>\n";
constexpr char kNotAvailable[] = "<not available>";
} // namespace
UserLogFilesLogSource::UserLogFilesLogSource()
: SystemLogsSource("UserLoggedFiles") {}
UserLogFilesLogSource::~UserLogFilesLogSource() = default;
void UserLogFilesLogSource::Fetch(SysLogsSourceCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(!callback.is_null());
auto response = std::make_unique<SystemLogsResponse>();
auto* response_ptr = response.get();
const base::FilePath log_file_path = base::FilePath(kDefaultLogPath);
base::ThreadPool::PostTaskAndReply(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(&UserLogFilesLogSource::ReadFile,
weak_ptr_factory_.GetWeakPtr(), log_file_path, kLogKey,
response_ptr),
base::BindOnce(std::move(callback), std::move(response)));
}
void UserLogFilesLogSource::ReadFile(const base::FilePath& log_file_path,
const std::string& log_key,
SystemLogsResponse* response) {
std::string value;
const bool read_success =
feedback_util::ReadEndOfFile(log_file_path, kMaxLogSize, &value);
if (read_success && value.length() == kMaxLogSize) {
value.replace(0, strlen(kLogTruncated), kLogTruncated);
LOG(WARNING) << "Large log file was likely truncated: " << log_file_path;
}
response->emplace(log_key, (read_success && !value.empty()) ? std::move(value)
: kNotAvailable);
}
} // namespace system_logs
// 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 CHROME_BROWSER_LACROS_SYSTEM_LOGS_USER_LOG_FILES_LOG_SOURCE_H_
#define CHROME_BROWSER_LACROS_SYSTEM_LOGS_USER_LOG_FILES_LOG_SOURCE_H_
#include <string>
#include "base/memory/weak_ptr.h"
#include "components/feedback/system_logs/system_logs_source.h"
namespace base {
class FilePath;
}
namespace system_logs {
// This class gathers log data from Lacros user log files.
class UserLogFilesLogSource : public SystemLogsSource {
public:
UserLogFilesLogSource();
UserLogFilesLogSource(const UserLogFilesLogSource&) = delete;
~UserLogFilesLogSource() override;
UserLogFilesLogSource& operator=(const UserLogFilesLogSource&) = delete;
// SystemLogsSource override:
void Fetch(SysLogsSourceCallback callback) override;
private:
void ReadFile(const base::FilePath& log_file_path,
const std::string& log_key,
SystemLogsResponse* response);
base::WeakPtrFactory<UserLogFilesLogSource> weak_ptr_factory_{this};
};
} // namespace system_logs
#endif // CHROME_BROWSER_LACROS_SYSTEM_LOGS_USER_LOG_FILES_LOG_SOURCE_H_
......@@ -61,6 +61,7 @@ source_set("unit_tests") {
deps = [
":feedback",
"//base",
"//build:lacros_buildflags",
"//components/feedback/proto",
"//components/keyed_service/core",
"//components/prefs:test_support",
......
......@@ -7,6 +7,7 @@
#include <utility>
#include "base/memory/ptr_util.h"
#include "build/lacros_buildflags.h"
#include "components/feedback/feedback_report.h"
#include "components/feedback/feedback_util.h"
#include "components/feedback/proto/common.pb.h"
......@@ -17,7 +18,7 @@
namespace {
#if defined(OS_CHROMEOS)
#if defined(OS_CHROMEOS) || BUILDFLAG(IS_LACROS)
constexpr int kChromeOSProductId = 208;
#else
constexpr int kChromeBrowserProductId = 237;
......@@ -123,7 +124,7 @@ void FeedbackCommon::PrepareReport(
// Set whether we're reporting from ChromeOS or Chrome on another platform.
userfeedback::ChromeData chrome_data;
#if defined(OS_CHROMEOS)
#if defined(OS_CHROMEOS) || BUILDFLAG(IS_LACROS)
const userfeedback::ChromeData_ChromePlatform chrome_platform =
userfeedback::ChromeData_ChromePlatform_CHROME_OS;
const int default_product_id = kChromeOSProductId;
......
......@@ -5,6 +5,7 @@
#include "components/feedback/feedback_common.h"
#include "base/bind.h"
#include "build/lacros_buildflags.h"
#include "components/feedback/feedback_report.h"
#include "components/feedback/proto/common.pb.h"
#include "components/feedback/proto/dom.pb.h"
......@@ -22,8 +23,8 @@ constexpr char kLongLog[] = TEN_LINES TEN_LINES TEN_LINES TEN_LINES TEN_LINES;
constexpr char kLogsAttachmentName[] = "system_logs.zip";
constexpr int kTestProductId = 3490;
#if defined(OS_CHROMEOS)
constexpr int kDefaultProductId = 208; // ChromeOS default product ID.
#if defined(OS_CHROMEOS) || BUILDFLAG(IS_LACROS)
constexpr int kDefaultProductId = 208; // ChromeOS & Lacros default product ID.
#else
constexpr int kDefaultProductId = 237; // Chrome default product ID.
#endif // defined(OS_CHROMEOS)
......
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