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

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

Issue 2891133003: Reporting: Wire ReportingDelegate into ChromeNetworkDelegate (Closed)
Patch Set: Created 3 years, 7 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_delegate.h ('k') | net/reporting/reporting_test_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_delegate.h" 5 #include "net/reporting/reporting_delegate.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "net/base/network_delegate.h"
9 #include "net/url_request/url_request_context.h"
8 10
9 namespace net { 11 namespace net {
10 12
11 namespace { 13 namespace {
12 14
13 class ReportingDelegateImpl : public ReportingDelegate { 15 class ReportingDelegateImpl : public ReportingDelegate {
14 public: 16 public:
15 ReportingDelegateImpl() {} 17 ReportingDelegateImpl(URLRequestContext* request_context)
18 : request_context_(request_context) {
19 DCHECK(request_context);
20 }
16 21
17 ~ReportingDelegateImpl() override {} 22 ~ReportingDelegateImpl() override {}
18 23
19 bool CanQueueReport(const url::Origin& origin) const override { return true; } 24 bool CanQueueReport(const url::Origin& origin) const override {
25 return network_delegate() &&
26 network_delegate()->CanQueueReportingReport(origin);
27 }
20 28
21 bool CanSendReport(const url::Origin& origin) const override { return true; } 29 bool CanSendReport(const url::Origin& origin) const override {
30 return network_delegate() &&
31 network_delegate()->CanSendReportingReport(origin);
32 }
22 33
23 bool CanSetClient(const url::Origin& origin, 34 bool CanSetClient(const url::Origin& origin,
24 const GURL& endpoint) const override { 35 const GURL& endpoint) const override {
25 return true; 36 return network_delegate() &&
37 network_delegate()->CanSetReportingClient(origin, endpoint);
26 } 38 }
27 39
28 bool CanUseClient(const url::Origin& origin, 40 bool CanUseClient(const url::Origin& origin,
29 const GURL& endpoint) const override { 41 const GURL& endpoint) const override {
30 return true; 42 return network_delegate() &&
43 network_delegate()->CanUseReportingClient(origin, endpoint);
31 } 44 }
45
46 private:
47 const NetworkDelegate* network_delegate() const {
48 return request_context_->network_delegate();
49 }
50
51 URLRequestContext* request_context_;
32 }; 52 };
33 53
34 } // namespace 54 } // namespace
35 55
36 // static 56 // static
37 std::unique_ptr<ReportingDelegate> ReportingDelegate::Create() { 57 std::unique_ptr<ReportingDelegate> ReportingDelegate::Create(
38 return base::MakeUnique<ReportingDelegateImpl>(); 58 URLRequestContext* request_context) {
59 return base::MakeUnique<ReportingDelegateImpl>(request_context);
39 } 60 }
40 61
41 ReportingDelegate::~ReportingDelegate() {} 62 ReportingDelegate::~ReportingDelegate() {}
42 63
43 } // namespace net 64 } // namespace net
OLDNEW
« no previous file with comments | « net/reporting/reporting_delegate.h ('k') | net/reporting/reporting_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698