chromium/chrome/browser/error_reporting/mock_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/mock_chrome_js_error_report_processor.h"

#include "base/base_paths.h"
#include "base/check.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/time/time.h"
#include "components/crash/content/browser/error_reporting/javascript_error_report.h"
#include "components/crash/content/browser/error_reporting/mock_crash_endpoint.h"
#include "components/variations/variations_crash_keys.h"

const char MockChromeJsErrorReportProcessor::
    kDefaultExperimentListStringPreEscaping[] =;  // variations::GetExperimentListInfo() always
                               // leaves a trailing comma.

const char MockChromeJsErrorReportProcessor::kDefaultExperimentListString[] =;  // The URL escaping turns the comma into %2C in the
                             // query string.

// Tricium gets confused by the #if's and thinks we should change this to
// "= default".
// NOLINTNEXTLINE
MockChromeJsErrorReportProcessor::MockChromeJsErrorReportProcessor() {}

MockChromeJsErrorReportProcessor::~MockChromeJsErrorReportProcessor() = default;

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

void MockChromeJsErrorReportProcessor::SetAsDefault() {}

// static
void MockChromeJsErrorReportProcessor::SetDefaultTo(
    scoped_refptr<JsErrorReportProcessor> new_default) {}

void MockChromeJsErrorReportProcessor::SetCrashEndpoint(
    std::string crash_endpoint) {}

void MockChromeJsErrorReportProcessor::SetCrashEndpointStaging(
    std::string crash_endpoint) {}

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

#if BUILDFLAG(IS_CHROMEOS)
std::vector<std::string>
MockChromeJsErrorReportProcessor::GetCrashReporterArgvStart() {
  // Redirect uploads to our a simple upload shim which will then send them to
  // the MockCrashEndpoint. This simulates the Chrome OS crash_reporter and
  // crash_sender in a way that allows most tests to run without changes.
  base::FilePath mock_crash_reporter_path;
  CHECK(base::PathService::Get(base::DIR_EXE, &mock_crash_reporter_path));
  mock_crash_reporter_path =
      mock_crash_reporter_path.Append("mock_chromeos_crash_reporter");
  return {mock_crash_reporter_path.value(),
          base::StrCat({"--upload_to=", crash_endpoint_})};
}
#else
std::string MockChromeJsErrorReportProcessor::GetOsVersion() {}

std::string MockChromeJsErrorReportProcessor::GetCrashEndpoint() {}

std::string MockChromeJsErrorReportProcessor::GetCrashEndpointStaging() {}

void MockChromeJsErrorReportProcessor::UpdateReportDatabase(
    std::string remote_report_id,
    base::Time report_time) {}
#endif  //  !BUILDFLAG(IS_CHROMEOS)

ScopedMockChromeJsErrorReportProcessor::ScopedMockChromeJsErrorReportProcessor(
    const MockCrashEndpoint& endpoint)
    :{}

ScopedMockChromeJsErrorReportProcessor::
    ~ScopedMockChromeJsErrorReportProcessor() {}