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

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

Issue 2336043007: Domain Reliability: Don't crash on shutdown with uploads pending (Closed)
Patch Set: Remove outdated comment. Created 4 years 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/dispatcher.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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // Initializes the Monitor's URLRequestContextGetter. 81 // Initializes the Monitor's URLRequestContextGetter.
82 // 82 //
83 // Must be called on the network thread, after |MoveToNetworkThread|. 83 // Must be called on the network thread, after |MoveToNetworkThread|.
84 void InitURLRequestContext(net::URLRequestContext* url_request_context); 84 void InitURLRequestContext(net::URLRequestContext* url_request_context);
85 85
86 // Same, but for unittests where the Getter is readily available. 86 // Same, but for unittests where the Getter is readily available.
87 void InitURLRequestContext( 87 void InitURLRequestContext(
88 const scoped_refptr<net::URLRequestContextGetter>& 88 const scoped_refptr<net::URLRequestContextGetter>&
89 url_request_context_getter); 89 url_request_context_getter);
90 90
91 // Shuts down the monitor prior to destruction. Currently, ensures that there
92 // are no pending uploads, to avoid hairy lifetime issues at destruction.
93 void Shutdown();
94
91 // Populates the monitor with contexts that were configured at compile time. 95 // Populates the monitor with contexts that were configured at compile time.
92 void AddBakedInConfigs(); 96 void AddBakedInConfigs();
93 97
94 // Sets whether the uploader will discard uploads. Must be called after 98 // Sets whether the uploader will discard uploads. Must be called after
95 // |InitURLRequestContext|. 99 // |InitURLRequestContext|.
96 void SetDiscardUploads(bool discard_uploads); 100 void SetDiscardUploads(bool discard_uploads);
97 101
98 // Should be called when |request| is about to follow a redirect. Will 102 // Should be called when |request| is about to follow a redirect. Will
99 // examine and possibly log the redirect request. Must be called after 103 // examine and possibly log the redirect request. Must be called after
100 // |SetDiscardUploads|. 104 // |SetDiscardUploads|.
(...skipping 22 matching lines...) Expand all
123 // debugging purposes. 127 // debugging purposes.
124 std::unique_ptr<base::Value> GetWebUIData() const; 128 std::unique_ptr<base::Value> GetWebUIData() const;
125 129
126 DomainReliabilityContext* AddContextForTesting( 130 DomainReliabilityContext* AddContextForTesting(
127 std::unique_ptr<const DomainReliabilityConfig> config); 131 std::unique_ptr<const DomainReliabilityConfig> config);
128 132
129 size_t contexts_size_for_testing() const { 133 size_t contexts_size_for_testing() const {
130 return context_manager_.contexts_size_for_testing(); 134 return context_manager_.contexts_size_for_testing();
131 } 135 }
132 136
137 // Forces all pending uploads to run now, even if their minimum delay has not
138 // yet passed.
139 void ForceUploadsForTesting();
140
133 // DomainReliabilityContext::Factory implementation: 141 // DomainReliabilityContext::Factory implementation:
134 std::unique_ptr<DomainReliabilityContext> CreateContextForConfig( 142 std::unique_ptr<DomainReliabilityContext> CreateContextForConfig(
135 std::unique_ptr<const DomainReliabilityConfig> config) override; 143 std::unique_ptr<const DomainReliabilityConfig> config) override;
136 144
137 private: 145 private:
138 friend class DomainReliabilityMonitorTest; 146 friend class DomainReliabilityMonitorTest;
139 // Allow the Service to call |MakeWeakPtr|. 147 // Allow the Service to call |MakeWeakPtr|.
140 friend class DomainReliabilityServiceImpl; 148 friend class DomainReliabilityServiceImpl;
141 149
142 typedef std::map<std::string, DomainReliabilityContext*> ContextMap; 150 typedef std::map<std::string, DomainReliabilityContext*> ContextMap;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 bool discard_uploads_set_; 196 bool discard_uploads_set_;
189 197
190 base::WeakPtrFactory<DomainReliabilityMonitor> weak_factory_; 198 base::WeakPtrFactory<DomainReliabilityMonitor> weak_factory_;
191 199
192 DISALLOW_COPY_AND_ASSIGN(DomainReliabilityMonitor); 200 DISALLOW_COPY_AND_ASSIGN(DomainReliabilityMonitor);
193 }; 201 };
194 202
195 } // namespace domain_reliability 203 } // namespace domain_reliability
196 204
197 #endif // COMPONENTS_DOMAIN_RELIABILITY_MONITOR_H_ 205 #endif // COMPONENTS_DOMAIN_RELIABILITY_MONITOR_H_
OLDNEW
« no previous file with comments | « components/domain_reliability/dispatcher.cc ('k') | components/domain_reliability/monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698