Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(829)

Unified Diff: components/reporting/core/browser/reporting_service.cc

Issue 2249213002: [OBSOLETE] Reporting: Initial implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ProfileImplIOData Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698