| Index: components/reporting/core/browser/reporting_service.cc
|
| diff --git a/components/reporting/core/browser/reporting_service.cc b/components/reporting/core/browser/reporting_service.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..94e5f2e696af8607b5724999732cc9ac187da19b
|
| --- /dev/null
|
| +++ b/components/reporting/core/browser/reporting_service.cc
|
| @@ -0,0 +1,71 @@
|
| +// Copyright 2016 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 "components/reporting/core/browser/reporting_service.h"
|
| +
|
| +#include "base/memory/ptr_util.h"
|
| +#include "components/reporting/core/browser/reporting_manager.h"
|
| +#include "components/reporting/core/browser/reporting_uploader.h"
|
| +#include "mojo/public/cpp/bindings/binding_set.h"
|
| +
|
| +namespace reporting {
|
| +
|
| +namespace {
|
| +
|
| +class ReportingServiceImpl : public ReportingService {
|
| + public:
|
| + ReportingServiceImpl(
|
| + scoped_refptr<net::URLRequestContextGetter> context,
|
| + const base::Callback<bool(const GURL&)>& is_origin_secure)
|
| + : ReportingService(),
|
| + manager_(base::MakeUnique<ReportingManager>(
|
| + ReportingUploader::Create(context),
|
| + is_origin_secure)) {}
|
| +
|
| + ~ReportingServiceImpl() override {}
|
| +
|
| + void QueueReport(std::unique_ptr<base::Value> body,
|
| + const GURL& url,
|
| + const GURL& origin,
|
| + const std::string& group,
|
| + const std::string& type) override {
|
| + auto report = base::MakeUnique<ReportingReport>();
|
| + report->body = std::move(body);
|
| + report->url = url.GetAsReferrer();
|
| + report->origin = origin;
|
| + report->group = group;
|
| + report->type = type;
|
| +
|
| + if (manager_)
|
| + manager_->QueueReport(std::move(report));
|
| + }
|
| +
|
| + void ProcessHeader(const GURL& origin,
|
| + const std::string& header_value) override {
|
| + if (manager_)
|
| + manager_->ProcessHeader(origin, header_value);
|
| + }
|
| +
|
| + void AddBinding(mojom::ReportingServiceRequest request) override {
|
| + bindings_.AddBinding(this, std::move(request));
|
| + }
|
| +
|
| + private:
|
| + std::unique_ptr<ReportingManager> manager_;
|
| + mojo::BindingSet<mojom::ReportingService> bindings_;
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +ReportingService::~ReportingService() {}
|
| +
|
| +std::unique_ptr<ReportingService> ReportingService::Create(
|
| + scoped_refptr<net::URLRequestContextGetter> context,
|
| + const base::Callback<bool(const GURL&)>& is_origin_secure) {
|
| + return base::MakeUnique<ReportingServiceImpl>(context, is_origin_secure);
|
| +}
|
| +
|
| +ReportingService::ReportingService() {}
|
| +
|
| +} // namespace reporting
|
|
|