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

Side by Side Diff: chrome/browser/metrics/variations/variations_service.cc

Issue 1060743003: Cleanup chrome/browser/metrics url constants (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove (c) from copyright Created 5 years, 8 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
« no previous file with comments | « chrome/browser/metrics/variations/url_constants.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/metrics/variations/variations_service.h" 5 #include "chrome/browser/metrics/variations/variations_service.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/build_time.h" 9 #include "base/build_time.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/metrics/sparse_histogram.h" 12 #include "base/metrics/sparse_histogram.h"
13 #include "base/prefs/pref_registry_simple.h" 13 #include "base/prefs/pref_registry_simple.h"
14 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
15 #include "base/sys_info.h" 15 #include "base/sys_info.h"
16 #include "base/task_runner_util.h" 16 #include "base/task_runner_util.h"
17 #include "base/timer/elapsed_timer.h" 17 #include "base/timer/elapsed_timer.h"
18 #include "base/version.h" 18 #include "base/version.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/metrics/variations/generated_resources_map.h" 20 #include "chrome/browser/metrics/variations/generated_resources_map.h"
21 #include "chrome/browser/metrics/variations/url_constants.h"
21 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
23 #include "components/metrics/metrics_state_manager.h" 24 #include "components/metrics/metrics_state_manager.h"
24 #include "components/network_time/network_time_tracker.h" 25 #include "components/network_time/network_time_tracker.h"
25 #include "components/pref_registry/pref_registry_syncable.h" 26 #include "components/pref_registry/pref_registry_syncable.h"
26 #include "components/variations/proto/variations_seed.pb.h" 27 #include "components/variations/proto/variations_seed.pb.h"
27 #include "components/variations/variations_seed_processor.h" 28 #include "components/variations/variations_seed_processor.h"
28 #include "components/variations/variations_seed_simulator.h" 29 #include "components/variations/variations_seed_simulator.h"
29 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
30 #include "net/base/load_flags.h" 31 #include "net/base/load_flags.h"
(...skipping 14 matching lines...) Expand all
45 #endif 46 #endif
46 47
47 #if defined(OS_CHROMEOS) 48 #if defined(OS_CHROMEOS)
48 #include "chrome/browser/chromeos/settings/cros_settings.h" 49 #include "chrome/browser/chromeos/settings/cros_settings.h"
49 #endif 50 #endif
50 51
51 namespace chrome_variations { 52 namespace chrome_variations {
52 53
53 namespace { 54 namespace {
54 55
55 // Default server of Variations seed info.
56 const char kDefaultVariationsServerURL[] =
57 "https://clients4.google.com/chrome-variations/seed";
58 const int kMaxRetrySeedFetch = 5; 56 const int kMaxRetrySeedFetch = 5;
59 57
60 // TODO(mad): To be removed when we stop updating the NetworkTimeTracker. 58 // TODO(mad): To be removed when we stop updating the NetworkTimeTracker.
61 // For the HTTP date headers, the resolution of the server time is 1 second. 59 // For the HTTP date headers, the resolution of the server time is 1 second.
62 const int64 kServerTimeResolutionMs = 1000; 60 const int64 kServerTimeResolutionMs = 1000;
63 61
64 // Wrapper around channel checking, used to enable channel mocking for 62 // Wrapper around channel checking, used to enable channel mocking for
65 // testing. If the current browser channel is not UNKNOWN, this will return 63 // testing. If the current browser channel is not UNKNOWN, this will return
66 // that channel value. Otherwise, if the fake channel flag is provided, this 64 // that channel value. Otherwise, if the fake channel flag is provided, this
67 // will return the fake channel. Failing that, this will return the UNKNOWN 65 // will return the fake channel. Failing that, this will return the UNKNOWN
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } 374 }
377 375
378 // static 376 // static
379 GURL VariationsService::GetVariationsServerURL( 377 GURL VariationsService::GetVariationsServerURL(
380 PrefService* policy_pref_service, 378 PrefService* policy_pref_service,
381 const std::string& restrict_mode_override) { 379 const std::string& restrict_mode_override) {
382 std::string server_url_string( 380 std::string server_url_string(
383 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 381 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
384 switches::kVariationsServerURL)); 382 switches::kVariationsServerURL));
385 if (server_url_string.empty()) 383 if (server_url_string.empty())
386 server_url_string = kDefaultVariationsServerURL; 384 server_url_string = kDefaultServerUrl;
387 GURL server_url = GURL(server_url_string); 385 GURL server_url = GURL(server_url_string);
388 386
389 const std::string restrict_param = !restrict_mode_override.empty() ? 387 const std::string restrict_param = !restrict_mode_override.empty() ?
390 restrict_mode_override : GetRestrictParameterPref(policy_pref_service); 388 restrict_mode_override : GetRestrictParameterPref(policy_pref_service);
391 if (!restrict_param.empty()) { 389 if (!restrict_param.empty()) {
392 server_url = net::AppendOrReplaceQueryParameter(server_url, 390 server_url = net::AppendOrReplaceQueryParameter(server_url,
393 "restrict", 391 "restrict",
394 restrict_param); 392 restrict_param);
395 } 393 }
396 394
397 server_url = net::AppendOrReplaceQueryParameter(server_url, "osname", 395 server_url = net::AppendOrReplaceQueryParameter(server_url, "osname",
398 GetPlatformString()); 396 GetPlatformString());
399 397
400 DCHECK(server_url.is_valid()); 398 DCHECK(server_url.is_valid());
401 return server_url; 399 return server_url;
402 } 400 }
403 401
404 // static 402 // static
405 std::string VariationsService::GetDefaultVariationsServerURLForTesting() { 403 std::string VariationsService::GetDefaultVariationsServerURLForTesting() {
406 return kDefaultVariationsServerURL; 404 return kDefaultServerUrl;
407 } 405 }
408 406
409 // static 407 // static
410 void VariationsService::RegisterPrefs(PrefRegistrySimple* registry) { 408 void VariationsService::RegisterPrefs(PrefRegistrySimple* registry) {
411 VariationsSeedStore::RegisterPrefs(registry); 409 VariationsSeedStore::RegisterPrefs(registry);
412 registry->RegisterInt64Pref(prefs::kVariationsLastFetchTime, 0); 410 registry->RegisterInt64Pref(prefs::kVariationsLastFetchTime, 0);
413 // This preference will only be written by the policy service, which will fill 411 // This preference will only be written by the policy service, which will fill
414 // it according to a value stored in the User Policy. 412 // it according to a value stored in the User Policy.
415 registry->RegisterStringPref(prefs::kVariationsRestrictParameter, 413 registry->RegisterStringPref(prefs::kVariationsRestrictParameter,
416 std::string()); 414 std::string());
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 local_state_->SetInt64(prefs::kVariationsLastFetchTime, 642 local_state_->SetInt64(prefs::kVariationsLastFetchTime,
645 base::Time::Now().ToInternalValue()); 643 base::Time::Now().ToInternalValue());
646 } 644 }
647 } 645 }
648 646
649 std::string VariationsService::GetInvalidVariationsSeedSignature() const { 647 std::string VariationsService::GetInvalidVariationsSeedSignature() const {
650 return seed_store_.GetInvalidSignature(); 648 return seed_store_.GetInvalidSignature();
651 } 649 }
652 650
653 } // namespace chrome_variations 651 } // namespace chrome_variations
OLDNEW
« no previous file with comments | « chrome/browser/metrics/variations/url_constants.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698