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

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

Issue 2900553004: Reporting: Add histograms. (Closed)
Patch Set: rebase Created 3 years, 5 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_header_parser.cc ('k') | net/reporting/reporting_report.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_network_change_observer.h" 5 #include "net/reporting/reporting_network_change_observer.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "net/base/network_change_notifier.h" 8 #include "net/base/network_change_notifier.h"
9 #include "net/reporting/reporting_cache.h" 9 #include "net/reporting/reporting_cache.h"
10 #include "net/reporting/reporting_context.h" 10 #include "net/reporting/reporting_context.h"
11 #include "net/reporting/reporting_policy.h" 11 #include "net/reporting/reporting_policy.h"
12 #include "net/reporting/reporting_report.h"
12 13
13 namespace net { 14 namespace net {
14 15
15 namespace { 16 namespace {
16 17
17 class ReportingNetworkChangeObserverImpl 18 class ReportingNetworkChangeObserverImpl
18 : public ReportingNetworkChangeObserver, 19 : public ReportingNetworkChangeObserver,
19 public NetworkChangeNotifier::NetworkChangeObserver { 20 public NetworkChangeNotifier::NetworkChangeObserver {
20 public: 21 public:
21 ReportingNetworkChangeObserverImpl(ReportingContext* context) 22 ReportingNetworkChangeObserverImpl(ReportingContext* context)
22 : context_(context) { 23 : context_(context) {
23 NetworkChangeNotifier::AddNetworkChangeObserver(this); 24 NetworkChangeNotifier::AddNetworkChangeObserver(this);
24 } 25 }
25 26
26 // ReportingNetworkChangeObserver implementation: 27 // ReportingNetworkChangeObserver implementation:
27 ~ReportingNetworkChangeObserverImpl() override { 28 ~ReportingNetworkChangeObserverImpl() override {
28 NetworkChangeNotifier::RemoveNetworkChangeObserver(this); 29 NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
29 } 30 }
30 31
31 // NetworkChangeNotifier::NetworkChangeObserver implementation: 32 // NetworkChangeNotifier::NetworkChangeObserver implementation:
32 void OnNetworkChanged(NetworkChangeNotifier::ConnectionType type) override { 33 void OnNetworkChanged(NetworkChangeNotifier::ConnectionType type) override {
33 // Every network change will be preceded by a call with CONNECTION_NONE, and 34 // Every network change will be preceded by a call with CONNECTION_NONE, and
34 // NetworkChangeNotifier suggests that destructive actions be performed in 35 // NetworkChangeNotifier suggests that destructive actions be performed in
35 // the call with CONNECTION_NONE, so clear reports and/or clients only in 36 // the call with CONNECTION_NONE, so clear reports and/or clients only in
36 // that case. 37 // that case.
37 if (type != NetworkChangeNotifier::ConnectionType::CONNECTION_NONE) 38 if (type != NetworkChangeNotifier::ConnectionType::CONNECTION_NONE)
38 return; 39 return;
39 40
40 if (context_->policy().clear_reports_on_network_changes) 41 if (context_->policy().clear_reports_on_network_changes)
41 context_->cache()->RemoveAllReports(); 42 context_->cache()->RemoveAllReports(
43 ReportingReport::Outcome::ERASED_NETWORK_CHANGED);
42 44
43 if (context_->policy().clear_clients_on_network_changes) 45 if (context_->policy().clear_clients_on_network_changes)
44 context_->cache()->RemoveAllClients(); 46 context_->cache()->RemoveAllClients();
45 } 47 }
46 48
47 private: 49 private:
48 ReportingContext* context_; 50 ReportingContext* context_;
49 51
50 DISALLOW_COPY_AND_ASSIGN(ReportingNetworkChangeObserverImpl); 52 DISALLOW_COPY_AND_ASSIGN(ReportingNetworkChangeObserverImpl);
51 }; 53 };
52 54
53 } // namespace 55 } // namespace
54 56
55 // static 57 // static
56 std::unique_ptr<ReportingNetworkChangeObserver> 58 std::unique_ptr<ReportingNetworkChangeObserver>
57 ReportingNetworkChangeObserver::Create(ReportingContext* context) { 59 ReportingNetworkChangeObserver::Create(ReportingContext* context) {
58 return base::MakeUnique<ReportingNetworkChangeObserverImpl>(context); 60 return base::MakeUnique<ReportingNetworkChangeObserverImpl>(context);
59 } 61 }
60 62
61 ReportingNetworkChangeObserver::~ReportingNetworkChangeObserver() {} 63 ReportingNetworkChangeObserver::~ReportingNetworkChangeObserver() {}
62 64
63 } // namespace net 65 } // namespace net
OLDNEW
« no previous file with comments | « net/reporting/reporting_header_parser.cc ('k') | net/reporting/reporting_report.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698