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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_params.cc

Issue 382313003: Add data reduction functionality to all platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed bengr comments - II. Created 6 years, 5 months 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
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 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h " 9 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h "
10 #include "net/proxy/proxy_info.h" 10 #include "net/proxy/proxy_info.h"
11 #include "net/proxy/proxy_service.h" 11 #include "net/proxy/proxy_service.h"
12 #include "net/url_request/url_request.h" 12 #include "net/url_request/url_request.h"
13 #include "net/url_request/url_request_context.h" 13 #include "net/url_request/url_request_context.h"
14 14
15 using base::FieldTrialList; 15 using base::FieldTrialList;
16 16
17 namespace { 17 namespace {
18
18 const char kEnabled[] = "Enabled"; 19 const char kEnabled[] = "Enabled";
19 } 20 const char kDefaultOrigin[] = "https://proxy.googlezip.net:443/";
21 const char kDevHost[] = "http://proxy-dev.googlezip.net:80/";
22 const char kDefaultFallbackOrigin[] = "http://compress.googlezip.net:80/";
23 const char kDefaultSslOrigin[] = "http://ssl.googlezip.net:1043/";
24 const char kDefaultAltOrigin[] = "https://proxy.googlezip.net:443/";
25 const char kDefaultAltFallbackOrigin[] = "http://compress.googlezip.net:80/";
26 const char kDefaultProbeUrl[] = "http://check.googlezip.net/connect";
27 const char kDefaultWarmupUrl[] = "http://www.gstatic.com/generate_204";
Ryan Sleevi 2014/07/22 01:56:31 95% certain that these do not belong in //componen
Ryan Sleevi 2014/07/22 08:22:24 Further red-flags: The number of HTTP URLs here fo
bengr 2014/07/22 18:52:51 We put these here because ultimately we want to ma
Not at Google. Contact bengr 2014/07/22 23:03:53 Can you please clarify why the number of HTTP URLs
Ryan Sleevi 2014/07/23 00:54:44 This is more about a security-team decision, but t
Not at Google. Contact bengr 2014/08/26 17:31:08 Discussed in https://code.google.com/p/chromium/is
28
29 } // namespace anonymous
20 30
21 namespace data_reduction_proxy { 31 namespace data_reduction_proxy {
22 32
23 // static 33 // static
24 bool DataReductionProxyParams::IsIncludedInFieldTrial() { 34 bool DataReductionProxyParams::IsIncludedInFieldTrial() {
25 return base::FieldTrialList::FindFullName( 35 return base::FieldTrialList::FindFullName(
26 "DataCompressionProxyRollout") == kEnabled; 36 "DataCompressionProxyRollout") == kEnabled;
27 } 37 }
28 38
29 // static 39 // static
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 request->context()->proxy_service()->config().proxy_rules().Apply( 326 request->context()->proxy_service()->config().proxy_rules().Apply(
317 request->url(), &result); 327 request->url(), &result);
318 if (!result.proxy_server().is_valid()) 328 if (!result.proxy_server().is_valid())
319 return false; 329 return false;
320 if (result.proxy_server().is_direct()) 330 if (result.proxy_server().is_direct())
321 return false; 331 return false;
322 return IsDataReductionProxy(result.proxy_server().host_port_pair(), NULL); 332 return IsDataReductionProxy(result.proxy_server().host_port_pair(), NULL);
323 } 333 }
324 334
325 std::string DataReductionProxyParams::GetDefaultDevOrigin() const { 335 std::string DataReductionProxyParams::GetDefaultDevOrigin() const {
326 #if defined(DATA_REDUCTION_DEV_HOST)
327 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 336 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
328 if (command_line.HasSwitch(switches::kDisableDataReductionProxyDev)) 337 if (command_line.HasSwitch(switches::kDisableDataReductionProxyDev))
329 return std::string(); 338 return std::string();
330 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) || 339 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) ||
331 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == 340 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") ==
332 kEnabled)) { 341 kEnabled)) {
333 return DATA_REDUCTION_DEV_HOST; 342 return kDevHost;
334 } 343 }
335 #endif
336 return std::string(); 344 return std::string();
337 } 345 }
338 346 // TODO(kundaji): Remove tests for macro definitions.
339 std::string DataReductionProxyParams::GetDefaultOrigin() const { 347 std::string DataReductionProxyParams::GetDefaultOrigin() const {
340 #if defined(SPDY_PROXY_AUTH_ORIGIN) 348 return kDefaultOrigin;
341 return SPDY_PROXY_AUTH_ORIGIN;
342 #endif
343 return std::string();
344 } 349 }
345 350
346 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const { 351 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const {
347 #if defined(DATA_REDUCTION_FALLBACK_HOST) 352 return kDefaultFallbackOrigin;
348 return DATA_REDUCTION_FALLBACK_HOST;
349 #endif
350 return std::string();
351 } 353 }
352 354
353 std::string DataReductionProxyParams::GetDefaultSSLOrigin() const { 355 std::string DataReductionProxyParams::GetDefaultSSLOrigin() const {
354 #if defined(DATA_REDUCTION_PROXY_SSL_ORIGIN) 356 return kDefaultSslOrigin;
355 return DATA_REDUCTION_PROXY_SSL_ORIGIN;
356 #endif
357 return std::string();
358 } 357 }
359 358
360 std::string DataReductionProxyParams::GetDefaultAltOrigin() const { 359 std::string DataReductionProxyParams::GetDefaultAltOrigin() const {
361 #if defined(DATA_REDUCTION_PROXY_ALT_ORIGIN) 360 return kDefaultAltOrigin;
362 return DATA_REDUCTION_PROXY_ALT_ORIGIN;
363 #endif
364 return std::string();
365 } 361 }
366 362
367 std::string DataReductionProxyParams::GetDefaultAltFallbackOrigin() const { 363 std::string DataReductionProxyParams::GetDefaultAltFallbackOrigin() const {
368 #if defined(DATA_REDUCTION_PROXY_ALT_FALLBACK_ORIGIN) 364 return kDefaultAltFallbackOrigin;
369 return DATA_REDUCTION_PROXY_ALT_FALLBACK_ORIGIN;
370 #endif
371 return std::string();
372 } 365 }
373 366
374 std::string DataReductionProxyParams::GetDefaultProbeURL() const { 367 std::string DataReductionProxyParams::GetDefaultProbeURL() const {
375 #if defined(DATA_REDUCTION_PROXY_PROBE_URL) 368 return kDefaultProbeUrl;
376 return DATA_REDUCTION_PROXY_PROBE_URL;
377 #endif
378 return std::string();
379 } 369 }
380 370
381 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { 371 std::string DataReductionProxyParams::GetDefaultWarmupURL() const {
382 #if defined(DATA_REDUCTION_PROXY_WARMUP_URL) 372 return kDefaultWarmupUrl;
383 return DATA_REDUCTION_PROXY_WARMUP_URL;
384 #endif
385 return std::string();
386 } 373 }
387 374
388 } // namespace data_reduction_proxy 375 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698