OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h" | 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 void RecordProbeURLFetchResult(ProbeURLFetchResult result) { | 80 void RecordProbeURLFetchResult(ProbeURLFetchResult result) { |
81 UMA_HISTOGRAM_ENUMERATION(kUMAProxyProbeURL, result, FETCH_RESULT_COUNT); | 81 UMA_HISTOGRAM_ENUMERATION(kUMAProxyProbeURL, result, FETCH_RESULT_COUNT); |
82 } | 82 } |
83 | 83 |
84 const char kEnabled[] = "Enabled"; | 84 const char kEnabled[] = "Enabled"; |
85 | 85 |
86 // TODO(marq): Factor this string out into a constant here and in | 86 // TODO(marq): Factor this string out into a constant here and in |
87 // http_auth_handler_spdyproxy. | 87 // http_auth_handler_spdyproxy. |
88 const char kAuthenticationRealmName[] = "SpdyProxy"; | 88 const char kAuthenticationRealmName[] = "SpdyProxy"; |
89 | 89 |
90 int64 GetInt64PrefValue(const ListValue& list_value, size_t index) { | 90 int64 GetInt64PrefValue(const base::ListValue& list_value, size_t index) { |
91 int64 val = 0; | 91 int64 val = 0; |
92 std::string pref_value; | 92 std::string pref_value; |
93 bool rv = list_value.GetString(index, &pref_value); | 93 bool rv = list_value.GetString(index, &pref_value); |
94 DCHECK(rv); | 94 DCHECK(rv); |
95 if (rv) { | 95 if (rv) { |
96 rv = base::StringToInt64(pref_value, &val); | 96 rv = base::StringToInt64(pref_value, &val); |
97 DCHECK(rv); | 97 DCHECK(rv); |
98 } | 98 } |
99 return val; | 99 return val; |
100 } | 100 } |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 if (IsDataReductionProxyAllowed()) | 557 if (IsDataReductionProxyAllowed()) |
558 state = IsDataReductionProxyEnabled() ? PROXY_ENABLED : PROXY_DISABLED; | 558 state = IsDataReductionProxyEnabled() ? PROXY_ENABLED : PROXY_DISABLED; |
559 UMA_HISTOGRAM_ENUMERATION(kUMAProxyStartupStateHistogram, | 559 UMA_HISTOGRAM_ENUMERATION(kUMAProxyStartupStateHistogram, |
560 state, | 560 state, |
561 PROXY_STARTUP_STATE_COUNT); | 561 PROXY_STARTUP_STATE_COUNT); |
562 } | 562 } |
563 | 563 |
564 DataReductionProxySettings::ContentLengthList | 564 DataReductionProxySettings::ContentLengthList |
565 DataReductionProxySettings::GetDailyContentLengths(const char* pref_name) { | 565 DataReductionProxySettings::GetDailyContentLengths(const char* pref_name) { |
566 DataReductionProxySettings::ContentLengthList content_lengths; | 566 DataReductionProxySettings::ContentLengthList content_lengths; |
567 const ListValue* list_value = GetLocalStatePrefs()->GetList(pref_name); | 567 const base::ListValue* list_value = GetLocalStatePrefs()->GetList(pref_name); |
568 if (list_value->GetSize() == spdyproxy::kNumDaysInHistory) { | 568 if (list_value->GetSize() == spdyproxy::kNumDaysInHistory) { |
569 for (size_t i = 0; i < spdyproxy::kNumDaysInHistory; ++i) { | 569 for (size_t i = 0; i < spdyproxy::kNumDaysInHistory; ++i) { |
570 content_lengths.push_back(GetInt64PrefValue(*list_value, i)); | 570 content_lengths.push_back(GetInt64PrefValue(*list_value, i)); |
571 } | 571 } |
572 } | 572 } |
573 return content_lengths; | 573 return content_lengths; |
574 } | 574 } |
575 | 575 |
576 void DataReductionProxySettings::GetContentLengths( | 576 void DataReductionProxySettings::GetContentLengths( |
577 unsigned int days, | 577 unsigned int days, |
578 int64* original_content_length, | 578 int64* original_content_length, |
579 int64* received_content_length, | 579 int64* received_content_length, |
580 int64* last_update_time) { | 580 int64* last_update_time) { |
581 DCHECK_LE(days, spdyproxy::kNumDaysInHistory); | 581 DCHECK_LE(days, spdyproxy::kNumDaysInHistory); |
582 PrefService* local_state = GetLocalStatePrefs(); | 582 PrefService* local_state = GetLocalStatePrefs(); |
583 if (!local_state) { | 583 if (!local_state) { |
584 *original_content_length = 0L; | 584 *original_content_length = 0L; |
585 *received_content_length = 0L; | 585 *received_content_length = 0L; |
586 *last_update_time = 0L; | 586 *last_update_time = 0L; |
587 return; | 587 return; |
588 } | 588 } |
589 | 589 |
590 const ListValue* original_list = | 590 const base::ListValue* original_list = |
591 local_state->GetList(prefs::kDailyHttpOriginalContentLength); | 591 local_state->GetList(prefs::kDailyHttpOriginalContentLength); |
592 const ListValue* received_list = | 592 const base::ListValue* received_list = |
593 local_state->GetList(prefs::kDailyHttpReceivedContentLength); | 593 local_state->GetList(prefs::kDailyHttpReceivedContentLength); |
594 | 594 |
595 if (original_list->GetSize() != spdyproxy::kNumDaysInHistory || | 595 if (original_list->GetSize() != spdyproxy::kNumDaysInHistory || |
596 received_list->GetSize() != spdyproxy::kNumDaysInHistory) { | 596 received_list->GetSize() != spdyproxy::kNumDaysInHistory) { |
597 *original_content_length = 0L; | 597 *original_content_length = 0L; |
598 *received_content_length = 0L; | 598 *received_content_length = 0L; |
599 *last_update_time = 0L; | 599 *last_update_time = 0L; |
600 return; | 600 return; |
601 } | 601 } |
602 | 602 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 } | 679 } |
680 | 680 |
681 void | 681 void |
682 DataReductionProxySettings::ProbeWhetherDataReductionProxyIsAvailable() { | 682 DataReductionProxySettings::ProbeWhetherDataReductionProxyIsAvailable() { |
683 net::URLFetcher* fetcher = GetURLFetcher(); | 683 net::URLFetcher* fetcher = GetURLFetcher(); |
684 if (!fetcher) | 684 if (!fetcher) |
685 return; | 685 return; |
686 fetcher_.reset(fetcher); | 686 fetcher_.reset(fetcher); |
687 fetcher_->Start(); | 687 fetcher_->Start(); |
688 } | 688 } |
OLD | NEW |