Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/autofill/address_storage_factory.h" | |
| 6 | |
| 7 #include "base/files/file_path.h" | |
| 8 #include "base/path_service.h" | |
| 9 #include "base/prefs/json_pref_store.h" | |
| 10 #include "base/prefs/pref_filter.h" | |
| 11 #include "base/threading/sequenced_worker_pool.h" | |
| 12 #include "chrome/common/chrome_paths.h" | |
| 13 #include "content/public/browser/browser_thread.h" | |
| 14 #include "third_party/libaddressinput/chromium/chrome_storage_impl.h" | |
| 15 | |
| 16 namespace autofill { | |
| 17 | |
| 18 using ::i18n::addressinput::Storage; | |
| 19 | |
| 20 // static | |
| 21 Storage* AddressStorageFactory::CreateStorage() { | |
|
Evan Stade
2014/01/27 23:11:15
make this return a scoped ptr
Dan Beam
2014/01/28 02:22:36
Done.
| |
| 22 static base::LazyInstance<AddressStorageFactory> instance = | |
| 23 LAZY_INSTANCE_INITIALIZER; | |
| 24 return new ChromeStorageImpl(instance.Get().json_pref_store_.get()); | |
| 25 } | |
| 26 | |
| 27 AddressStorageFactory::AddressStorageFactory() { | |
| 28 base::FilePath path; | |
| 29 PathService::Get(chrome::FILE_LIBADDRESSINPUT_CACHE, &path); | |
| 30 | |
| 31 scoped_refptr<base::SequencedTaskRunner> task_runner = | |
| 32 JsonPrefStore::GetTaskRunnerForFile( | |
| 33 path, content::BrowserThread::GetBlockingPool()); | |
| 34 | |
| 35 json_pref_store_ = | |
| 36 new JsonPrefStore(path, task_runner.get(), scoped_ptr<PrefFilter>()); | |
| 37 json_pref_store_->ReadPrefsAsync(NULL); | |
| 38 } | |
| 39 | |
| 40 AddressStorageFactory::~AddressStorageFactory() {} | |
| 41 | |
| 42 } // namespace autofill | |
| OLD | NEW |