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

Side by Side Diff: chromecast/browser/pref_service_helper.cc

Issue 1662523004: Delete base/prefs and update callers to use components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/browser/pref_service_helper.h ('k') | chromeos/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/browser/pref_service_helper.h" 5 #include "chromecast/browser/pref_service_helper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/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"
14 #include "base/prefs/pref_registry_simple.h"
15 #include "base/prefs/pref_service_factory.h"
16 #include "base/prefs/pref_store.h"
17 #include "chromecast/base/cast_paths.h" 13 #include "chromecast/base/cast_paths.h"
18 #include "chromecast/base/pref_names.h" 14 #include "chromecast/base/pref_names.h"
15 #include "components/prefs/json_pref_store.h"
16 #include "components/prefs/pref_registry_simple.h"
17 #include "components/prefs/pref_service_factory.h"
18 #include "components/prefs/pref_store.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 20
21 namespace chromecast { 21 namespace chromecast {
22 namespace shell { 22 namespace shell {
23 23
24 namespace { 24 namespace {
25 25
26 void UserPrefsLoadError(PersistentPrefStore::PrefReadError* error_val, 26 void UserPrefsLoadError(PersistentPrefStore::PrefReadError* error_val,
27 PersistentPrefStore::PrefReadError error) { 27 PersistentPrefStore::PrefReadError error) {
28 DCHECK(error_val); 28 DCHECK(error_val);
(...skipping 20 matching lines...) Expand all
49 // 1) Any crashes or UMA logs are recorded prior to setup completing 49 // 1) Any crashes or UMA logs are recorded prior to setup completing
50 // successfully (even though we can't send them yet). Unless the user 50 // successfully (even though we can't send them yet). Unless the user
51 // ends up actually opting out, we don't want to lose this data once 51 // ends up actually opting out, we don't want to lose this data once
52 // we get network connectivity and are able to send it. If the user 52 // we get network connectivity and are able to send it. If the user
53 // opts out, nothing further will be sent (honoring the user's setting). 53 // opts out, nothing further will be sent (honoring the user's setting).
54 // 2) Dogfood users (see dogfood agreement). 54 // 2) Dogfood users (see dogfood agreement).
55 registry->RegisterBooleanPref(prefs::kOptInStats, true); 55 registry->RegisterBooleanPref(prefs::kOptInStats, true);
56 56
57 RegisterPlatformPrefs(registry); 57 RegisterPlatformPrefs(registry);
58 58
59 base::PrefServiceFactory prefServiceFactory; 59 PrefServiceFactory prefServiceFactory;
60 scoped_refptr<base::SequencedTaskRunner> task_runner = 60 scoped_refptr<base::SequencedTaskRunner> task_runner =
61 JsonPrefStore::GetTaskRunnerForFile( 61 JsonPrefStore::GetTaskRunnerForFile(
62 config_path, 62 config_path,
63 content::BrowserThread::GetBlockingPool()); 63 content::BrowserThread::GetBlockingPool());
64 prefServiceFactory.SetUserPrefsFile(config_path, task_runner.get()); 64 prefServiceFactory.SetUserPrefsFile(config_path, task_runner.get());
65 prefServiceFactory.set_async(false); 65 prefServiceFactory.set_async(false);
66 66
67 PersistentPrefStore::PrefReadError prefs_read_error = 67 PersistentPrefStore::PrefReadError prefs_read_error =
68 PersistentPrefStore::PREF_READ_ERROR_NONE; 68 PersistentPrefStore::PREF_READ_ERROR_NONE;
69 prefServiceFactory.set_read_error_callback( 69 prefServiceFactory.set_read_error_callback(
70 base::Bind(&UserPrefsLoadError, &prefs_read_error)); 70 base::Bind(&UserPrefsLoadError, &prefs_read_error));
71 71
72 scoped_ptr<PrefService> pref_service(prefServiceFactory.Create(registry)); 72 scoped_ptr<PrefService> pref_service(prefServiceFactory.Create(registry));
73 if (prefs_read_error != PersistentPrefStore::PREF_READ_ERROR_NONE) { 73 if (prefs_read_error != PersistentPrefStore::PREF_READ_ERROR_NONE) {
74 LOG(ERROR) << "Cannot initialize chromecast config: " 74 LOG(ERROR) << "Cannot initialize chromecast config: "
75 << config_path.value() 75 << config_path.value()
76 << ", pref_error=" << prefs_read_error; 76 << ", pref_error=" << prefs_read_error;
77 } 77 }
78 78
79 OnPrefsLoaded(pref_service.get()); 79 OnPrefsLoaded(pref_service.get());
80 return pref_service; 80 return pref_service;
81 } 81 }
82 82
83 } // namespace shell 83 } // namespace shell
84 } // namespace chromecast 84 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/pref_service_helper.h ('k') | chromeos/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698