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

Side by Side Diff: components/domain_reliability/monitor.h

Issue 945923002: Fix memory leak and crash when parsing baked-in configs in domain reliability monitor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « components/domain_reliability/config.cc ('k') | components/domain_reliability/monitor.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef COMPONENTS_DOMAIN_RELIABILITY_MONITOR_H_ 5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_MONITOR_H_
6 #define COMPONENTS_DOMAIN_RELIABILITY_MONITOR_H_ 6 #define COMPONENTS_DOMAIN_RELIABILITY_MONITOR_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // The top-level object that measures requests and hands off the measurements 42 // The top-level object that measures requests and hands off the measurements
43 // to the proper |DomainReliabilityContext|. 43 // to the proper |DomainReliabilityContext|.
44 class DOMAIN_RELIABILITY_EXPORT DomainReliabilityMonitor 44 class DOMAIN_RELIABILITY_EXPORT DomainReliabilityMonitor
45 : public net::NetworkChangeNotifier::NetworkChangeObserver { 45 : public net::NetworkChangeNotifier::NetworkChangeObserver {
46 public: 46 public:
47 // Creates a Monitor. |local_state_pref_service| must live on |pref_thread| 47 // Creates a Monitor. |local_state_pref_service| must live on |pref_thread|
48 // (which should be the current thread); |network_thread| is the thread 48 // (which should be the current thread); |network_thread| is the thread
49 // on which requests will actually be monitored and reported. 49 // on which requests will actually be monitored and reported.
50 DomainReliabilityMonitor( 50 DomainReliabilityMonitor(
51 const std::string& upload_reporter_string, 51 const std::string& upload_reporter_string,
52 scoped_refptr<base::SingleThreadTaskRunner> pref_thread, 52 const scoped_refptr<base::SingleThreadTaskRunner>& pref_thread,
53 scoped_refptr<base::SingleThreadTaskRunner> network_thread); 53 const scoped_refptr<base::SingleThreadTaskRunner>& network_thread);
54 54
55 // Same, but specifies a mock interface for time functions for testing. 55 // Same, but specifies a mock interface for time functions for testing.
56 DomainReliabilityMonitor( 56 DomainReliabilityMonitor(
57 const std::string& upload_reporter_string, 57 const std::string& upload_reporter_string,
58 scoped_refptr<base::SingleThreadTaskRunner> pref_thread, 58 const scoped_refptr<base::SingleThreadTaskRunner>& pref_thread,
59 scoped_refptr<base::SingleThreadTaskRunner> network_thread, 59 const scoped_refptr<base::SingleThreadTaskRunner>& network_thread,
60 scoped_ptr<MockableTime> time); 60 scoped_ptr<MockableTime> time);
61 61
62 // Must be called from the pref thread if |MoveToNetworkThread| was not 62 // Must be called from the pref thread if |MoveToNetworkThread| was not
63 // called, or from the network thread if it was called. 63 // called, or from the network thread if it was called.
64 ~DomainReliabilityMonitor() override; 64 ~DomainReliabilityMonitor() override;
65 65
66 // Must be called before |InitURLRequestContext| on the same thread on which 66 // Must be called before |InitURLRequestContext| on the same thread on which
67 // the Monitor was constructed. Moves (most of) the Monitor to the network 67 // the Monitor was constructed. Moves (most of) the Monitor to the network
68 // thread passed in the constructor. 68 // thread passed in the constructor.
69 void MoveToNetworkThread(); 69 void MoveToNetworkThread();
70 70
71 // All public methods below this point must be called on the network thread 71 // All public methods below this point must be called on the network thread
72 // after |MoveToNetworkThread| is called on the pref thread. 72 // after |MoveToNetworkThread| is called on the pref thread.
73 73
74 // Initializes the Monitor's URLRequestContextGetter. 74 // Initializes the Monitor's URLRequestContextGetter.
75 // 75 //
76 // Must be called on the network thread, after |MoveToNetworkThread|. 76 // Must be called on the network thread, after |MoveToNetworkThread|.
77 void InitURLRequestContext(net::URLRequestContext* url_request_context); 77 void InitURLRequestContext(net::URLRequestContext* url_request_context);
78 78
79 // Same, but for unittests where the Getter is readily available. 79 // Same, but for unittests where the Getter is readily available.
80 void InitURLRequestContext( 80 void InitURLRequestContext(
81 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); 81 const scoped_refptr<net::URLRequestContextGetter>&
82 url_request_context_getter);
82 83
83 // Populates the monitor with contexts that were configured at compile time. 84 // Populates the monitor with contexts that were configured at compile time.
84 void AddBakedInConfigs(); 85 void AddBakedInConfigs();
85 86
86 // Sets whether the uploader will discard uploads. Must be called after 87 // Sets whether the uploader will discard uploads. Must be called after
87 // |InitURLRequestContext|. 88 // |InitURLRequestContext|.
88 void SetDiscardUploads(bool discard_uploads); 89 void SetDiscardUploads(bool discard_uploads);
89 90
90 // Should be called when |request| is about to follow a redirect. Will 91 // Should be called when |request| is about to follow a redirect. Will
91 // examine and possibly log the redirect request. Must be called after 92 // examine and possibly log the redirect request. Must be called after
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 bool discard_uploads_set_; 173 bool discard_uploads_set_;
173 174
174 base::WeakPtrFactory<DomainReliabilityMonitor> weak_factory_; 175 base::WeakPtrFactory<DomainReliabilityMonitor> weak_factory_;
175 176
176 DISALLOW_COPY_AND_ASSIGN(DomainReliabilityMonitor); 177 DISALLOW_COPY_AND_ASSIGN(DomainReliabilityMonitor);
177 }; 178 };
178 179
179 } // namespace domain_reliability 180 } // namespace domain_reliability
180 181
181 #endif // COMPONENTS_DOMAIN_RELIABILITY_MONITOR_H_ 182 #endif // COMPONENTS_DOMAIN_RELIABILITY_MONITOR_H_
OLDNEW
« no previous file with comments | « components/domain_reliability/config.cc ('k') | components/domain_reliability/monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698