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

Side by Side Diff: net/reporting/reporting_service.cc

Issue 2770443002: Reporting: Wrap context in service. (Closed)
Patch Set: Make requested changes. Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « net/reporting/reporting_service.h ('k') | net/reporting/reporting_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/reporting/reporting_service.h"
6
7 #include <memory>
8
9 #include "base/callback.h"
10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h"
12 #include "base/time/tick_clock.h"
13 #include "base/time/time.h"
14 #include "base/values.h"
15 #include "net/reporting/reporting_cache.h"
16 #include "net/reporting/reporting_context.h"
17 #include "net/reporting/reporting_delegate.h"
18 #include "net/reporting/reporting_header_parser.h"
19 #include "url/gurl.h"
20
21 namespace net {
22
23 namespace {
24
25 class ReportingServiceImpl : public ReportingService {
26 public:
27 ReportingServiceImpl(std::unique_ptr<ReportingContext> context)
28 : context_(std::move(context)) {}
29
30 ~ReportingServiceImpl() override {}
31
32 void QueueReport(const GURL& url,
33 const std::string& group,
34 const std::string& type,
35 std::unique_ptr<const base::Value> body) override {
36 context_->cache()->AddReport(url, group, type, std::move(body),
37 context_->tick_clock()->NowTicks(), 0);
38 }
39
40 void ProcessHeader(const GURL& url,
41 const std::string& header_value) override {
42 ReportingHeaderParser::ParseHeader(context_.get(), url, header_value);
43 }
44
45 void RemoveBrowsingData(
46 bool remove_reports,
47 bool remove_clients,
48 base::Callback<bool(const GURL&)> origin_filter) override {
49 NOTIMPLEMENTED();
shivanisha 2017/04/05 16:59:30 Is it being implemented in a future reporting CL (
Julia Tuttle 2017/04/06 17:09:49 Yes, it is being implemented in https://codereview
shivanisha 2017/04/06 17:13:01 Having it in the same CL where it is being impleme
Julia Tuttle 2017/04/06 17:51:05 Done.
50 }
51
52 private:
53 std::unique_ptr<ReportingContext> context_;
54
55 DISALLOW_COPY_AND_ASSIGN(ReportingServiceImpl);
56 };
57
58 } // namespace
59
60 ReportingService::~ReportingService() {}
61
62 // static
63 std::unique_ptr<ReportingService> ReportingService::Create(
64 const ReportingPolicy& policy,
65 URLRequestContext* request_context,
66 std::unique_ptr<ReportingDelegate> delegate) {
67 return base::MakeUnique<ReportingServiceImpl>(
68 ReportingContext::Create(policy, std::move(delegate), request_context));
69 }
70
71 // static
72 std::unique_ptr<ReportingService> ReportingService::CreateForTesting(
73 std::unique_ptr<ReportingContext> reporting_context) {
74 return base::MakeUnique<ReportingServiceImpl>(std::move(reporting_context));
75 }
76
77 } // namespace net
OLDNEW
« no previous file with comments | « net/reporting/reporting_service.h ('k') | net/reporting/reporting_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698