OLD | NEW |
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 #include "components/domain_reliability/monitor.h" | 5 #include "components/domain_reliability/monitor.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 return; | 121 return; |
122 RequestInfo request_info(*request); | 122 RequestInfo request_info(*request); |
123 if (request_info.DefinitelyReachedNetwork()) { | 123 if (request_info.DefinitelyReachedNetwork()) { |
124 OnRequestLegComplete(request_info); | 124 OnRequestLegComplete(request_info); |
125 // A request was just using the network, so now is a good time to run any | 125 // A request was just using the network, so now is a good time to run any |
126 // pending and eligible uploads. | 126 // pending and eligible uploads. |
127 dispatcher_.RunEligibleTasks(); | 127 dispatcher_.RunEligibleTasks(); |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
| 131 void DomainReliabilityMonitor::ClearContexts() { |
| 132 DCHECK(OnIOThread()); |
| 133 STLDeleteContainerPairSecondPointers( |
| 134 contexts_.begin(), contexts_.end()); |
| 135 } |
| 136 |
| 137 void DomainReliabilityMonitor::ClearBeacons() { |
| 138 DCHECK(OnIOThread()); |
| 139 ContextMap::const_iterator it; |
| 140 for (it = contexts_.begin(); it != contexts_.end(); ++it) |
| 141 it->second->ClearBeacons(); |
| 142 } |
| 143 |
131 DomainReliabilityContext* DomainReliabilityMonitor::AddContextForTesting( | 144 DomainReliabilityContext* DomainReliabilityMonitor::AddContextForTesting( |
132 scoped_ptr<const DomainReliabilityConfig> config) { | 145 scoped_ptr<const DomainReliabilityConfig> config) { |
133 return AddContext(config.Pass()); | 146 return AddContext(config.Pass()); |
134 } | 147 } |
135 | 148 |
136 DomainReliabilityMonitor::RequestInfo::RequestInfo() {} | 149 DomainReliabilityMonitor::RequestInfo::RequestInfo() {} |
137 | 150 |
138 DomainReliabilityMonitor::RequestInfo::RequestInfo( | 151 DomainReliabilityMonitor::RequestInfo::RequestInfo( |
139 const net::URLRequest& request) | 152 const net::URLRequest& request) |
140 : url(request.url()), | 153 : url(request.url()), |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 beacon.status = beacon_status; | 219 beacon.status = beacon_status; |
207 beacon.chrome_error = request.status.error(); | 220 beacon.chrome_error = request.status.error(); |
208 beacon.server_ip = request.socket_address.host(); | 221 beacon.server_ip = request.socket_address.host(); |
209 beacon.http_response_code = request.response_code; | 222 beacon.http_response_code = request.response_code; |
210 beacon.start_time = request.load_timing_info.request_start; | 223 beacon.start_time = request.load_timing_info.request_start; |
211 beacon.elapsed = time_->NowTicks() - beacon.start_time; | 224 beacon.elapsed = time_->NowTicks() - beacon.start_time; |
212 context->AddBeacon(beacon, request.url); | 225 context->AddBeacon(beacon, request.url); |
213 } | 226 } |
214 | 227 |
215 } // namespace domain_reliability | 228 } // namespace domain_reliability |
OLD | NEW |