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

Unified Diff: content/browser/net/reporting_service_proxy.cc

Issue 2881593002: Reporting: Plumb into RenderFrame via Mojo (Closed)
Patch Set: Fix #includes and DEPS. Created 3 years, 6 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: content/browser/net/reporting_service_proxy.cc
diff --git a/content/browser/net/reporting_service_proxy.cc b/content/browser/net/reporting_service_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c6785a2261f67dfe64cf20dbaaad02e7a00761e2
--- /dev/null
+++ b/content/browser/net/reporting_service_proxy.cc
@@ -0,0 +1,83 @@
+// Copyright 2017 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 "content/browser/net/reporting_service_proxy.h"
+
+#include <memory>
+#include <string>
+#include <utility>
+
+#include "base/memory/ref_counted.h"
+#include "base/values.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/site_instance.h"
+#include "content/public/browser/storage_partition.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+#include "net/reporting/reporting_service.h"
+#include "net/url_request/url_request_context.h"
+#include "net/url_request/url_request_context_getter.h"
+#include "third_party/WebKit/public/platform/reporting.mojom.h"
+#include "url/gurl.h"
+
+namespace content {
+
+namespace {
+
+class ReportingServiceProxyImpl : public mojom::ReportingServiceProxy {
+ public:
+ ReportingServiceProxyImpl(
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter)
+ : request_context_getter_(std::move(request_context_getter)) {}
+
+ // mojom::ReportingServiceProxy:
+ void QueueReport(const GURL& url,
+ const std::string& group,
+ const std::string& type,
+ std::unique_ptr<base::Value> body) override {
+ std::unique_ptr<const base::Value> const_body =
+ base::WrapUnique(body.release());
+
+ net::URLRequestContext* request_context =
+ request_context_getter_->GetURLRequestContext();
+ if (!request_context)
+ return;
+
+ net::ReportingService* reporting_service =
+ request_context->reporting_service();
+ if (!reporting_service)
+ return;
+
+ reporting_service->QueueReport(url, group, type, std::move(const_body));
+ }
+
+ private:
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
+};
+
+void CreateReportingServiceProxyOnNetworkTaskRunner(
+ mojom::ReportingServiceProxyRequest request,
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter) {
+ mojo::MakeStrongBinding(base::MakeUnique<ReportingServiceProxyImpl>(
+ std::move(request_context_getter)),
+ std::move(request));
+}
+
+} // namespace
+
+// static
+void CreateReportingServiceProxy(
+ StoragePartition* storage_partition,
+ const service_manager::BindSourceInfo& source_info,
+ mojom::ReportingServiceProxyRequest request) {
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter(
+ storage_partition->GetURLRequestContext());
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner(
+ request_context_getter->GetNetworkTaskRunner());
+ network_task_runner->PostTask(
+ FROM_HERE,
+ base::BindOnce(&CreateReportingServiceProxyOnNetworkTaskRunner,
+ std::move(request), std::move(request_context_getter)));
+}
+
+} // namespace content
« no previous file with comments | « content/browser/net/reporting_service_proxy.h ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698