OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/reporting/reporting_service.h" | 5 #include "net/reporting/reporting_service.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/time/tick_clock.h" | 12 #include "base/time/tick_clock.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "net/reporting/reporting_browsing_data_remover.h" |
15 #include "net/reporting/reporting_cache.h" | 16 #include "net/reporting/reporting_cache.h" |
16 #include "net/reporting/reporting_context.h" | 17 #include "net/reporting/reporting_context.h" |
17 #include "net/reporting/reporting_header_parser.h" | 18 #include "net/reporting/reporting_header_parser.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 | 20 |
20 namespace net { | 21 namespace net { |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 class ReportingServiceImpl : public ReportingService { | 25 class ReportingServiceImpl : public ReportingService { |
25 public: | 26 public: |
26 ReportingServiceImpl(std::unique_ptr<ReportingContext> context) | 27 ReportingServiceImpl(std::unique_ptr<ReportingContext> context) |
27 : context_(std::move(context)) {} | 28 : context_(std::move(context)) {} |
28 | 29 |
29 ~ReportingServiceImpl() override {} | 30 ~ReportingServiceImpl() override {} |
30 | 31 |
31 void QueueReport(const GURL& url, | 32 void QueueReport(const GURL& url, |
32 const std::string& group, | 33 const std::string& group, |
33 const std::string& type, | 34 const std::string& type, |
34 std::unique_ptr<const base::Value> body) override { | 35 std::unique_ptr<const base::Value> body) override { |
35 context_->cache()->AddReport(url, group, type, std::move(body), | 36 context_->cache()->AddReport(url, group, type, std::move(body), |
36 context_->tick_clock()->NowTicks(), 0); | 37 context_->tick_clock()->NowTicks(), 0); |
37 } | 38 } |
38 | 39 |
39 void ProcessHeader(const GURL& url, | 40 void ProcessHeader(const GURL& url, |
40 const std::string& header_value) override { | 41 const std::string& header_value) override { |
41 ReportingHeaderParser::ParseHeader(context_.get(), url, header_value); | 42 ReportingHeaderParser::ParseHeader(context_.get(), url, header_value); |
42 } | 43 } |
43 | 44 |
| 45 void RemoveBrowsingData( |
| 46 int data_type_mask, |
| 47 base::Callback<bool(const GURL&)> origin_filter) override { |
| 48 context_->browsing_data_remover()->RemoveBrowsingData(data_type_mask, |
| 49 origin_filter); |
| 50 } |
| 51 |
44 private: | 52 private: |
45 std::unique_ptr<ReportingContext> context_; | 53 std::unique_ptr<ReportingContext> context_; |
46 | 54 |
47 DISALLOW_COPY_AND_ASSIGN(ReportingServiceImpl); | 55 DISALLOW_COPY_AND_ASSIGN(ReportingServiceImpl); |
48 }; | 56 }; |
49 | 57 |
50 } // namespace | 58 } // namespace |
51 | 59 |
52 ReportingService::~ReportingService() {} | 60 ReportingService::~ReportingService() {} |
53 | 61 |
54 // static | 62 // static |
55 std::unique_ptr<ReportingService> ReportingService::Create( | 63 std::unique_ptr<ReportingService> ReportingService::Create( |
56 const ReportingPolicy& policy, | 64 const ReportingPolicy& policy, |
57 URLRequestContext* request_context) { | 65 URLRequestContext* request_context) { |
58 return base::MakeUnique<ReportingServiceImpl>( | 66 return base::MakeUnique<ReportingServiceImpl>( |
59 ReportingContext::Create(policy, request_context)); | 67 ReportingContext::Create(policy, request_context)); |
60 } | 68 } |
61 | 69 |
62 // static | 70 // static |
63 std::unique_ptr<ReportingService> ReportingService::CreateForTesting( | 71 std::unique_ptr<ReportingService> ReportingService::CreateForTesting( |
64 std::unique_ptr<ReportingContext> reporting_context) { | 72 std::unique_ptr<ReportingContext> reporting_context) { |
65 return base::MakeUnique<ReportingServiceImpl>(std::move(reporting_context)); | 73 return base::MakeUnique<ReportingServiceImpl>(std::move(reporting_context)); |
66 } | 74 } |
67 | 75 |
68 } // namespace net | 76 } // namespace net |
OLD | NEW |