• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2015 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #include "shill/store_factory.h"
18 
19 #if defined(ENABLE_JSON_STORE)
20 #include "shill/json_store.h"
21 #else
22 #include "shill/key_file_store.h"
23 #endif  // ENABLE_JSON_STORE
24 
25 namespace shill {
26 
27 namespace {
28 
29 base::LazyInstance<StoreFactory> g_persistent_store_factory
30     = LAZY_INSTANCE_INITIALIZER;
31 
32 }  // namespace
33 
StoreFactory()34 StoreFactory::StoreFactory() {}
35 
36 // static
GetInstance()37 StoreFactory* StoreFactory::GetInstance() {
38   return g_persistent_store_factory.Pointer();
39 }
40 
CreateStore(const base::FilePath & path)41 StoreInterface* StoreFactory::CreateStore(const base::FilePath& path) {
42 #if defined(ENABLE_JSON_STORE)
43   return new JsonStore(path);
44 #else
45   return new KeyFileStore(path);
46 #endif
47 }
48 
49 }  // namespace shill
50