| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_service_client.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig_service_client.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 17 #include "base/metrics/sparse_histogram.h" | 17 #include "base/metrics/sparse_histogram.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" | 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" |
| 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_muta
ble_config_values.h" | 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_muta
ble_config_values.h" |
| 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ
est_options.h" | 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ
est_options.h" |
| 22 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_clien
t_config_parser.h" | 22 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_clien
t_config_parser.h" |
| 23 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event
_creator.h" | 23 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event
_creator.h" |
| 24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
| 25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switc
hes.h" | 25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switc
hes.h" |
| 26 #include "components/data_reduction_proxy/proto/client_config.pb.h" | 26 #include "components/data_reduction_proxy/proto/client_config.pb.h" |
| 27 #include "net/base/host_port_pair.h" | 27 #include "net/base/host_port_pair.h" |
| 28 #include "net/base/load_flags.h" | 28 #include "net/base/load_flags.h" |
| 29 #include "net/base/net_errors.h" |
| 29 #include "net/base/url_util.h" | 30 #include "net/base/url_util.h" |
| 30 #include "net/http/http_response_headers.h" | 31 #include "net/http/http_response_headers.h" |
| 31 #include "net/http/http_status_code.h" | 32 #include "net/http/http_status_code.h" |
| 32 #include "net/proxy/proxy_server.h" | 33 #include "net/proxy/proxy_server.h" |
| 33 #include "net/url_request/url_fetcher.h" | 34 #include "net/url_request/url_fetcher.h" |
| 34 #include "net/url_request/url_request_status.h" | 35 #include "net/url_request/url_request_status.h" |
| 35 | 36 |
| 36 #if defined(USE_GOOGLE_API_KEYS) | 37 #if defined(USE_GOOGLE_API_KEYS) |
| 37 #include "google_apis/google_api_keys.h" | 38 #include "google_apis/google_api_keys.h" |
| 38 #endif | 39 #endif |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 CreateClientConfigRequest request; | 295 CreateClientConfigRequest request; |
| 295 std::string serialized_request; | 296 std::string serialized_request; |
| 296 const std::string& session_key = request_options_->GetSecureSession(); | 297 const std::string& session_key = request_options_->GetSecureSession(); |
| 297 if (!session_key.empty()) | 298 if (!session_key.empty()) |
| 298 request.set_session_key(request_options_->GetSecureSession()); | 299 request.set_session_key(request_options_->GetSecureSession()); |
| 299 request.SerializeToString(&serialized_request); | 300 request.SerializeToString(&serialized_request); |
| 300 scoped_ptr<net::URLFetcher> fetcher = | 301 scoped_ptr<net::URLFetcher> fetcher = |
| 301 GetURLFetcherForConfig(config_service_url_, serialized_request); | 302 GetURLFetcherForConfig(config_service_url_, serialized_request); |
| 302 if (!fetcher.get()) { | 303 if (!fetcher.get()) { |
| 303 HandleResponse(std::string(), | 304 HandleResponse(std::string(), |
| 304 net::URLRequestStatus(net::URLRequestStatus::CANCELED, 0), | 305 net::URLRequestStatus::FromError(net::ERR_ABORTED), |
| 305 net::URLFetcher::RESPONSE_CODE_INVALID); | 306 net::URLFetcher::RESPONSE_CODE_INVALID); |
| 306 return; | 307 return; |
| 307 } | 308 } |
| 308 | 309 |
| 309 fetcher_ = fetcher.Pass(); | 310 fetcher_ = fetcher.Pass(); |
| 310 fetcher_->Start(); | 311 fetcher_->Start(); |
| 311 } | 312 } |
| 312 | 313 |
| 313 void DataReductionProxyConfigServiceClient::InvalidateConfig() { | 314 void DataReductionProxyConfigServiceClient::InvalidateConfig() { |
| 314 GetBackoffEntry()->InformOfRequest(false); | 315 GetBackoffEntry()->InformOfRequest(false); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 return false; | 409 return false; |
| 409 } | 410 } |
| 410 | 411 |
| 411 request_options_->SetCredentials(session, credentials); | 412 request_options_->SetCredentials(session, credentials); |
| 412 config_values_->UpdateValues(proxies); | 413 config_values_->UpdateValues(proxies); |
| 413 config_->ReloadConfig(); | 414 config_->ReloadConfig(); |
| 414 return true; | 415 return true; |
| 415 } | 416 } |
| 416 | 417 |
| 417 } // namespace data_reduction_proxy | 418 } // namespace data_reduction_proxy |
| OLD | NEW |