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

Side by Side Diff: chromecast/common/chromecast_config.cc

Issue 482813004: Adds CastMetricsServiceClient to Chromecast shell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address asvitkine's comments Created 6 years, 4 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 | « chromecast/chromecast.gyp ('k') | chromecast/metrics/DEPS » ('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 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 "chromecast/common/chromecast_config.h" 5 #include "chromecast/common/chromecast_config.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/prefs/json_pref_store.h" 13 #include "base/prefs/json_pref_store.h"
14 #include "base/prefs/pref_registry_simple.h" 14 #include "base/prefs/pref_registry_simple.h"
15 #include "base/prefs/pref_service_factory.h" 15 #include "base/prefs/pref_service_factory.h"
16 #include "base/prefs/pref_store.h" 16 #include "base/prefs/pref_store.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "chromecast/common/cast_paths.h" 18 #include "chromecast/common/cast_paths.h"
19 #include "chromecast/common/pref_names.h" 19 #include "chromecast/common/pref_names.h"
20 #include "chromecast/metrics/cast_metrics_prefs.h"
20 21
21 namespace chromecast { 22 namespace chromecast {
22 23
23 namespace { 24 namespace {
24 25
25 // Config file IO worker constants. 26 // Config file IO worker constants.
26 const int kNumOfConfigFileIOWorkers = 1; 27 const int kNumOfConfigFileIOWorkers = 1;
27 const char kNameOfConfigFileIOWorkers[] = "ConfigFileIO"; 28 const char kNameOfConfigFileIOWorkers[] = "ConfigFileIO";
28 29
29 void UserPrefsLoadError( 30 void UserPrefsLoadError(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // Explict writing before worker_pool shutdown. 68 // Explict writing before worker_pool shutdown.
68 pref_service_->CommitPendingWrite(); 69 pref_service_->CommitPendingWrite();
69 worker_pool_->Shutdown(); 70 worker_pool_->Shutdown();
70 } 71 }
71 72
72 bool ChromecastConfig::Load(PrefRegistrySimple* registry) { 73 bool ChromecastConfig::Load(PrefRegistrySimple* registry) {
73 DCHECK(thread_checker_.CalledOnValidThread()); 74 DCHECK(thread_checker_.CalledOnValidThread());
74 VLOG(1) << "Loading config from " << config_path_.value(); 75 VLOG(1) << "Loading config from " << config_path_.value();
75 registry->RegisterIntegerPref(prefs::kRemoteDebuggingPort, 0); 76 registry->RegisterIntegerPref(prefs::kRemoteDebuggingPort, 0);
76 77
78 metrics::RegisterPrefs(registry);
77 RegisterPlatformPrefs(registry); 79 RegisterPlatformPrefs(registry);
78 80
79 PersistentPrefStore::PrefReadError prefs_read_error = 81 PersistentPrefStore::PrefReadError prefs_read_error =
80 PersistentPrefStore::PREF_READ_ERROR_NONE; 82 PersistentPrefStore::PREF_READ_ERROR_NONE;
81 base::PrefServiceFactory prefServiceFactory; 83 base::PrefServiceFactory prefServiceFactory;
82 prefServiceFactory.SetUserPrefsFile(config_path_, 84 prefServiceFactory.SetUserPrefsFile(config_path_,
83 JsonPrefStore::GetTaskRunnerForFile(config_path_, worker_pool_)); 85 JsonPrefStore::GetTaskRunnerForFile(config_path_, worker_pool_));
84 prefServiceFactory.set_async(false); 86 prefServiceFactory.set_async(false);
85 prefServiceFactory.set_read_error_callback( 87 prefServiceFactory.set_read_error_callback(
86 base::Bind(&UserPrefsLoadError, &prefs_read_error)); 88 base::Bind(&UserPrefsLoadError, &prefs_read_error));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 if (pref_service_->IsUserModifiablePreference(key.c_str())) { 131 if (pref_service_->IsUserModifiablePreference(key.c_str())) {
130 VLOG(1) << "Set config: key=" << key << ", value=" << value; 132 VLOG(1) << "Set config: key=" << key << ", value=" << value;
131 pref_service_->SetInteger(key.c_str(), value); 133 pref_service_->SetInteger(key.c_str(), value);
132 } else { 134 } else {
133 LOG(ERROR) << "Cannot set read-only config: key=" << key 135 LOG(ERROR) << "Cannot set read-only config: key=" << key
134 << ", value=" << value; 136 << ", value=" << value;
135 } 137 }
136 } 138 }
137 139
138 } // namespace chromecast 140 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/chromecast.gyp ('k') | chromecast/metrics/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698