Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 DCHECK(thread_checker_.CalledOnValidThread()); | 74 DCHECK(thread_checker_.CalledOnValidThread()); |
| 75 VLOG(1) << "Loading config from " << config_path_.value(); | 75 VLOG(1) << "Loading config from " << config_path_.value(); |
| 76 registry->RegisterIntegerPref(prefs::kRemoteDebuggingPort, 0); | 76 registry->RegisterIntegerPref(prefs::kRemoteDebuggingPort, 0); |
| 77 | 77 |
| 78 metrics::RegisterPrefs(registry); | 78 metrics::RegisterPrefs(registry); |
| 79 RegisterPlatformPrefs(registry); | 79 RegisterPlatformPrefs(registry); |
| 80 | 80 |
| 81 PersistentPrefStore::PrefReadError prefs_read_error = | 81 PersistentPrefStore::PrefReadError prefs_read_error = |
| 82 PersistentPrefStore::PREF_READ_ERROR_NONE; | 82 PersistentPrefStore::PREF_READ_ERROR_NONE; |
| 83 base::PrefServiceFactory prefServiceFactory; | 83 base::PrefServiceFactory prefServiceFactory; |
| 84 prefServiceFactory.SetUserPrefsFile(config_path_, | 84 scoped_refptr<base::SequencedTaskRunner> task_runner = |
| 85 JsonPrefStore::GetTaskRunnerForFile(config_path_, worker_pool_)); | 85 JsonPrefStore::GetTaskRunnerForFile(config_path_, worker_pool_.get()); |
| 86 prefServiceFactory.SetUserPrefsFile(config_path_, task_runner.get()); | |
|
damienv1
2014/09/08 16:27:21
Is it safe ?
Ref count for task runner will be dec
lcwu1
2014/09/08 18:01:58
Yes, it is. task_runner's raw pointer gets passed
| |
| 86 prefServiceFactory.set_async(false); | 87 prefServiceFactory.set_async(false); |
| 87 prefServiceFactory.set_read_error_callback( | 88 prefServiceFactory.set_read_error_callback( |
| 88 base::Bind(&UserPrefsLoadError, &prefs_read_error)); | 89 base::Bind(&UserPrefsLoadError, &prefs_read_error)); |
| 89 pref_service_ = prefServiceFactory.Create(registry); | 90 pref_service_ = prefServiceFactory.Create(registry); |
| 90 | 91 |
| 91 if (prefs_read_error == PersistentPrefStore::PREF_READ_ERROR_NONE) { | 92 if (prefs_read_error == PersistentPrefStore::PREF_READ_ERROR_NONE) { |
| 92 return true; | 93 return true; |
| 93 } else { | 94 } else { |
| 94 LOG(ERROR) << "Cannot initialize chromecast config: " | 95 LOG(ERROR) << "Cannot initialize chromecast config: " |
| 95 << config_path_.value() | 96 << config_path_.value() |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 if (pref_service_->IsUserModifiablePreference(key.c_str())) { | 132 if (pref_service_->IsUserModifiablePreference(key.c_str())) { |
| 132 VLOG(1) << "Set config: key=" << key << ", value=" << value; | 133 VLOG(1) << "Set config: key=" << key << ", value=" << value; |
| 133 pref_service_->SetInteger(key.c_str(), value); | 134 pref_service_->SetInteger(key.c_str(), value); |
| 134 } else { | 135 } else { |
| 135 LOG(ERROR) << "Cannot set read-only config: key=" << key | 136 LOG(ERROR) << "Cannot set read-only config: key=" << key |
| 136 << ", value=" << value; | 137 << ", value=" << value; |
| 137 } | 138 } |
| 138 } | 139 } |
| 139 | 140 |
| 140 } // namespace chromecast | 141 } // namespace chromecast |
| OLD | NEW |