| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 // Make sure the URLRequestContext actually lives on what was declared to be | 149 // Make sure the URLRequestContext actually lives on what was declared to be |
| 150 // the network thread. | 150 // the network thread. |
| 151 DCHECK(url_request_context_getter->GetNetworkTaskRunner()-> | 151 DCHECK(url_request_context_getter->GetNetworkTaskRunner()-> |
| 152 RunsTasksOnCurrentThread()); | 152 RunsTasksOnCurrentThread()); |
| 153 | 153 |
| 154 uploader_ = DomainReliabilityUploader::Create(time_.get(), | 154 uploader_ = DomainReliabilityUploader::Create(time_.get(), |
| 155 url_request_context_getter); | 155 url_request_context_getter); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void DomainReliabilityMonitor::Shutdown() { |
| 159 uploader_->Shutdown(); |
| 160 } |
| 161 |
| 158 void DomainReliabilityMonitor::AddBakedInConfigs() { | 162 void DomainReliabilityMonitor::AddBakedInConfigs() { |
| 159 DCHECK(OnNetworkThread()); | 163 DCHECK(OnNetworkThread()); |
| 160 DCHECK(moved_to_network_thread_); | 164 DCHECK(moved_to_network_thread_); |
| 161 | 165 |
| 162 for (size_t i = 0; kBakedInJsonConfigs[i]; ++i) { | 166 for (size_t i = 0; kBakedInJsonConfigs[i]; ++i) { |
| 163 base::StringPiece json(kBakedInJsonConfigs[i]); | 167 base::StringPiece json(kBakedInJsonConfigs[i]); |
| 164 std::unique_ptr<const DomainReliabilityConfig> config = | 168 std::unique_ptr<const DomainReliabilityConfig> config = |
| 165 DomainReliabilityConfig::FromJSON(json); | 169 DomainReliabilityConfig::FromJSON(json); |
| 166 if (!config) { | 170 if (!config) { |
| 167 DLOG(WARNING) << "Baked-in Domain Reliability config failed to parse: " | 171 DLOG(WARNING) << "Baked-in Domain Reliability config failed to parse: " |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 return std::move(data_value); | 246 return std::move(data_value); |
| 243 } | 247 } |
| 244 | 248 |
| 245 DomainReliabilityContext* DomainReliabilityMonitor::AddContextForTesting( | 249 DomainReliabilityContext* DomainReliabilityMonitor::AddContextForTesting( |
| 246 std::unique_ptr<const DomainReliabilityConfig> config) { | 250 std::unique_ptr<const DomainReliabilityConfig> config) { |
| 247 DCHECK(OnNetworkThread()); | 251 DCHECK(OnNetworkThread()); |
| 248 | 252 |
| 249 return context_manager_.AddContextForConfig(std::move(config)); | 253 return context_manager_.AddContextForConfig(std::move(config)); |
| 250 } | 254 } |
| 251 | 255 |
| 256 void DomainReliabilityMonitor::ForceUploadsForTesting() { |
| 257 dispatcher_.RunAllTasksForTesting(); |
| 258 } |
| 259 |
| 252 std::unique_ptr<DomainReliabilityContext> | 260 std::unique_ptr<DomainReliabilityContext> |
| 253 DomainReliabilityMonitor::CreateContextForConfig( | 261 DomainReliabilityMonitor::CreateContextForConfig( |
| 254 std::unique_ptr<const DomainReliabilityConfig> config) { | 262 std::unique_ptr<const DomainReliabilityConfig> config) { |
| 255 DCHECK(OnNetworkThread()); | 263 DCHECK(OnNetworkThread()); |
| 256 DCHECK(config); | 264 DCHECK(config); |
| 257 DCHECK(config->IsValid()); | 265 DCHECK(config->IsValid()); |
| 258 | 266 |
| 259 return base::MakeUnique<DomainReliabilityContext>( | 267 return base::MakeUnique<DomainReliabilityContext>( |
| 260 time_.get(), scheduler_params_, upload_reporter_string_, | 268 time_.get(), scheduler_params_, upload_reporter_string_, |
| 261 &last_network_change_time_, &dispatcher_, uploader_.get(), | 269 &last_network_change_time_, &dispatcher_, uploader_.get(), |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 break; | 427 break; |
| 420 } | 428 } |
| 421 } | 429 } |
| 422 | 430 |
| 423 base::WeakPtr<DomainReliabilityMonitor> | 431 base::WeakPtr<DomainReliabilityMonitor> |
| 424 DomainReliabilityMonitor::MakeWeakPtr() { | 432 DomainReliabilityMonitor::MakeWeakPtr() { |
| 425 return weak_factory_.GetWeakPtr(); | 433 return weak_factory_.GetWeakPtr(); |
| 426 } | 434 } |
| 427 | 435 |
| 428 } // namespace domain_reliability | 436 } // namespace domain_reliability |
| OLD | NEW |