chromium/chrome/browser/error_reporting/chrome_js_error_report_processor.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/error_reporting/chrome_js_error_report_processor.h"

#include <stddef.h>

#include <string_view>
#include <tuple>
#include <utility>

#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/escape.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/system/sys_info.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/time/default_clock.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/crash/content/browser/error_reporting/javascript_error_report.h"
#include "components/crash/core/app/client_upload_info.h"
#include "components/crash/core/app/crashpad.h"
#include "components/feedback/redaction_tool/redaction_tool.h"
#include "components/startup_metric_utils/common/startup_metric_utils.h"
#include "components/variations/variations_crash_keys.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "url/gurl.h"

#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "base/build_time.h"
#endif

namespace {

constexpr char kNoBrowserNoWindow[] =;
constexpr char kRegularTabbedWindow[] =;
constexpr char kWebAppWindow[] =;
constexpr char kSystemWebAppWindow[] =;

#if BUILDFLAG(IS_CHROMEOS)
// Give up if crash_reporter hasn't finished in this long.
constexpr base::TimeDelta kMaximumWaitForCrashReporter = base::Minutes(1);
#endif

// Sometimes, the stack trace will contain an error message as the first line,
// which confuses the Crash server. This function deletes it if it is present.
void RemoveErrorMessageFromStackTrace(const std::string& error_message,
                                      std::string& stack_trace) {}

std::string RedactErrorMessage(const std::string& message) {}

// Truncate the error message to no more than 1000 characters. Long messages
// are not useful and can cause problems in internal systems (such as
// excessively long URLs used to point to error reports). Note that the
// truncation is calculated pre-character-escaping ("  " is 3 characters, not
// the 9 of "%20%20%20") so that we don't break an escape sequence.
//
// Return the original message if it's already less than 1000 characters, or
// a truncated version if it's over 1000 characters
std::string TruncateErrorMessage(const std::string& message) {}

std::string MapWindowTypeToString(WindowType window_type) {}

}  // namespace

ChromeJsErrorReportProcessor::ChromeJsErrorReportProcessor()
    :{}
ChromeJsErrorReportProcessor::~ChromeJsErrorReportProcessor() = default;

// Returns the redacted, fixed-up error report if the user consented to have it
// sent. Returns std::nullopt if the user did not consent or we otherwise
// should not send the report. All the MayBlock work should be done in here.
std::optional<JavaScriptErrorReport>
ChromeJsErrorReportProcessor::CheckConsentAndRedact(
    JavaScriptErrorReport error_report) {}

struct ChromeJsErrorReportProcessor::PlatformInfo {};

ChromeJsErrorReportProcessor::PlatformInfo
ChromeJsErrorReportProcessor::GetPlatformInfo() {}

variations::ExperimentListInfo
ChromeJsErrorReportProcessor::GetExperimentListInfo() const {}

void ChromeJsErrorReportProcessor::AddExperimentIds(ParameterMap& params) {}

// Finishes sending process once the MayBlock processing is done. On UI thread.
void ChromeJsErrorReportProcessor::OnConsentCheckCompleted(
    base::ScopedClosureRunner callback_runner,
    scoped_refptr<network::SharedURLLoaderFactory> loader_factory,
    base::TimeDelta browser_process_uptime,
    base::Time report_time,
    std::optional<JavaScriptErrorReport> error_report) {}

void ChromeJsErrorReportProcessor::CheckAndUpdateRecentErrorReports(
    const JavaScriptErrorReport& error_report,
    bool* should_send) {}

// static
void ChromeJsErrorReportProcessor::Create() {}

void ChromeJsErrorReportProcessor::SendErrorReport(
    JavaScriptErrorReport error_report,
    base::OnceClosure completion_callback,
    content::BrowserContext* browser_context) {}