OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/feature_engagement_tracker/internal/feature_engagement_trac
ker_impl.h" | 5 #include "components/feature_engagement_tracker/internal/feature_engagement_trac
ker_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
11 #include "components/feature_engagement_tracker/internal/editable_configuration.
h" | 11 #include "components/feature_engagement_tracker/internal/editable_configuration.
h" |
12 #include "components/feature_engagement_tracker/internal/in_memory_store.h" | 12 #include "components/feature_engagement_tracker/internal/in_memory_store.h" |
13 #include "components/feature_engagement_tracker/internal/model_impl.h" | 13 #include "components/feature_engagement_tracker/internal/model_impl.h" |
14 #include "components/feature_engagement_tracker/internal/never_condition_validat
or.h" | 14 #include "components/feature_engagement_tracker/internal/never_condition_validat
or.h" |
15 #include "components/feature_engagement_tracker/internal/never_storage_validator
.h" | 15 #include "components/feature_engagement_tracker/internal/never_storage_validator
.h" |
16 #include "components/feature_engagement_tracker/internal/once_condition_validato
r.h" | 16 #include "components/feature_engagement_tracker/internal/once_condition_validato
r.h" |
| 17 #include "components/feature_engagement_tracker/internal/persistent_store.h" |
17 #include "components/feature_engagement_tracker/internal/single_invalid_configur
ation.h" | 18 #include "components/feature_engagement_tracker/internal/single_invalid_configur
ation.h" |
18 #include "components/feature_engagement_tracker/public/feature_constants.h" | 19 #include "components/feature_engagement_tracker/public/feature_constants.h" |
19 #include "components/feature_engagement_tracker/public/feature_list.h" | 20 #include "components/feature_engagement_tracker/public/feature_list.h" |
| 21 #include "components/leveldb_proto/proto_database_impl.h" |
20 | 22 |
21 namespace feature_engagement_tracker { | 23 namespace feature_engagement_tracker { |
22 | 24 |
23 namespace { | 25 namespace { |
24 | 26 |
25 // Creates a FeatureEngagementTrackerImpl that is usable for a demo mode. | 27 // Creates a FeatureEngagementTrackerImpl that is usable for a demo mode. |
26 std::unique_ptr<FeatureEngagementTracker> | 28 std::unique_ptr<FeatureEngagementTracker> |
27 CreateDemoModeFeatureEngagementTracker() { | 29 CreateDemoModeFeatureEngagementTracker() { |
28 std::unique_ptr<EditableConfiguration> configuration = | 30 std::unique_ptr<EditableConfiguration> configuration = |
29 base::MakeUnique<EditableConfiguration>(); | 31 base::MakeUnique<EditableConfiguration>(); |
(...skipping 14 matching lines...) Expand all Loading... |
44 } | 46 } |
45 | 47 |
46 } // namespace | 48 } // namespace |
47 | 49 |
48 // This method is declared in //components/feature_engagement_tracker/public/ | 50 // This method is declared in //components/feature_engagement_tracker/public/ |
49 // feature_engagement_tracker.h | 51 // feature_engagement_tracker.h |
50 // and should be linked in to any binary using FeatureEngagementTracker::Create. | 52 // and should be linked in to any binary using FeatureEngagementTracker::Create. |
51 // static | 53 // static |
52 FeatureEngagementTracker* FeatureEngagementTracker::Create( | 54 FeatureEngagementTracker* FeatureEngagementTracker::Create( |
53 const base::FilePath& storage_dir, | 55 const base::FilePath& storage_dir, |
54 const scoped_refptr<base::SequencedTaskRunner>& background__task_runner) { | 56 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner) { |
55 if (base::FeatureList::IsEnabled(kIPHDemoMode)) | 57 if (base::FeatureList::IsEnabled(kIPHDemoMode)) |
56 return CreateDemoModeFeatureEngagementTracker().release(); | 58 return CreateDemoModeFeatureEngagementTracker().release(); |
57 | 59 |
58 std::unique_ptr<Store> store = base::MakeUnique<InMemoryStore>(); | 60 std::unique_ptr<leveldb_proto::ProtoDatabase<Event>> db = |
| 61 base::MakeUnique<leveldb_proto::ProtoDatabaseImpl<Event>>( |
| 62 background_task_runner); |
| 63 |
| 64 std::unique_ptr<Store> store = |
| 65 base::MakeUnique<PersistentStore>(storage_dir, std::move(db)); |
59 std::unique_ptr<Configuration> configuration = | 66 std::unique_ptr<Configuration> configuration = |
60 base::MakeUnique<SingleInvalidConfiguration>(); | 67 base::MakeUnique<SingleInvalidConfiguration>(); |
61 std::unique_ptr<ConditionValidator> condition_validator = | 68 std::unique_ptr<ConditionValidator> condition_validator = |
62 base::MakeUnique<NeverConditionValidator>(); | 69 base::MakeUnique<NeverConditionValidator>(); |
63 std::unique_ptr<StorageValidator> storage_validator = | 70 std::unique_ptr<StorageValidator> storage_validator = |
64 base::MakeUnique<NeverStorageValidator>(); | 71 base::MakeUnique<NeverStorageValidator>(); |
65 | 72 |
66 return new FeatureEngagementTrackerImpl( | 73 return new FeatureEngagementTrackerImpl( |
67 std::move(store), std::move(configuration), | 74 std::move(store), std::move(configuration), |
68 std::move(condition_validator), std::move(storage_validator)); | 75 std::move(condition_validator), std::move(storage_validator)); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 131 |
125 for (auto& callback : on_initialized_callbacks_) { | 132 for (auto& callback : on_initialized_callbacks_) { |
126 base::ThreadTaskRunnerHandle::Get()->PostTask( | 133 base::ThreadTaskRunnerHandle::Get()->PostTask( |
127 FROM_HERE, base::Bind(callback, success)); | 134 FROM_HERE, base::Bind(callback, success)); |
128 } | 135 } |
129 | 136 |
130 on_initialized_callbacks_.clear(); | 137 on_initialized_callbacks_.clear(); |
131 } | 138 } |
132 | 139 |
133 } // namespace feature_engagement_tracker | 140 } // namespace feature_engagement_tracker |
OLD | NEW |