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

Side by Side Diff: components/feature_engagement_tracker/internal/feature_engagement_tracker_impl.cc

Issue 2876633002: Add a PersistentStore to FeatureEngagementTracker (Closed)
Patch Set: Fix deps Created 3 years, 7 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
OLDNEW
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/internal/system_time_provider.h" 19 #include "components/feature_engagement_tracker/internal/system_time_provider.h"
19 #include "components/feature_engagement_tracker/public/feature_constants.h" 20 #include "components/feature_engagement_tracker/public/feature_constants.h"
20 #include "components/feature_engagement_tracker/public/feature_list.h" 21 #include "components/feature_engagement_tracker/public/feature_list.h"
22 #include "components/leveldb_proto/proto_database_impl.h"
21 23
22 namespace feature_engagement_tracker { 24 namespace feature_engagement_tracker {
23 25
24 namespace { 26 namespace {
25 27
26 // Creates a FeatureEngagementTrackerImpl that is usable for a demo mode. 28 // Creates a FeatureEngagementTrackerImpl that is usable for a demo mode.
27 std::unique_ptr<FeatureEngagementTracker> 29 std::unique_ptr<FeatureEngagementTracker>
28 CreateDemoModeFeatureEngagementTracker() { 30 CreateDemoModeFeatureEngagementTracker() {
29 std::unique_ptr<EditableConfiguration> configuration = 31 std::unique_ptr<EditableConfiguration> configuration =
30 base::MakeUnique<EditableConfiguration>(); 32 base::MakeUnique<EditableConfiguration>();
(...skipping 15 matching lines...) Expand all
46 } 48 }
47 49
48 } // namespace 50 } // namespace
49 51
50 // This method is declared in //components/feature_engagement_tracker/public/ 52 // This method is declared in //components/feature_engagement_tracker/public/
51 // feature_engagement_tracker.h 53 // feature_engagement_tracker.h
52 // and should be linked in to any binary using FeatureEngagementTracker::Create. 54 // and should be linked in to any binary using FeatureEngagementTracker::Create.
53 // static 55 // static
54 FeatureEngagementTracker* FeatureEngagementTracker::Create( 56 FeatureEngagementTracker* FeatureEngagementTracker::Create(
55 const base::FilePath& storage_dir, 57 const base::FilePath& storage_dir,
56 const scoped_refptr<base::SequencedTaskRunner>& background__task_runner) { 58 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner) {
57 if (base::FeatureList::IsEnabled(kIPHDemoMode)) 59 if (base::FeatureList::IsEnabled(kIPHDemoMode))
58 return CreateDemoModeFeatureEngagementTracker().release(); 60 return CreateDemoModeFeatureEngagementTracker().release();
59 61
60 std::unique_ptr<Store> store = base::MakeUnique<InMemoryStore>(); 62 std::unique_ptr<leveldb_proto::ProtoDatabase<Event>> db =
63 base::MakeUnique<leveldb_proto::ProtoDatabaseImpl<Event>>(
64 background_task_runner);
65
66 std::unique_ptr<Store> store =
67 base::MakeUnique<PersistentStore>(storage_dir, std::move(db));
61 std::unique_ptr<Configuration> configuration = 68 std::unique_ptr<Configuration> configuration =
62 base::MakeUnique<SingleInvalidConfiguration>(); 69 base::MakeUnique<SingleInvalidConfiguration>();
63 std::unique_ptr<ConditionValidator> condition_validator = 70 std::unique_ptr<ConditionValidator> condition_validator =
64 base::MakeUnique<NeverConditionValidator>(); 71 base::MakeUnique<NeverConditionValidator>();
65 std::unique_ptr<StorageValidator> storage_validator = 72 std::unique_ptr<StorageValidator> storage_validator =
66 base::MakeUnique<NeverStorageValidator>(); 73 base::MakeUnique<NeverStorageValidator>();
67 std::unique_ptr<TimeProvider> time_provider = 74 std::unique_ptr<TimeProvider> time_provider =
68 base::MakeUnique<SystemTimeProvider>(); 75 base::MakeUnique<SystemTimeProvider>();
69 76
70 return new FeatureEngagementTrackerImpl( 77 return new FeatureEngagementTrackerImpl(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 139
133 for (auto& callback : on_initialized_callbacks_) { 140 for (auto& callback : on_initialized_callbacks_) {
134 base::ThreadTaskRunnerHandle::Get()->PostTask( 141 base::ThreadTaskRunnerHandle::Get()->PostTask(
135 FROM_HERE, base::Bind(callback, success)); 142 FROM_HERE, base::Bind(callback, success));
136 } 143 }
137 144
138 on_initialized_callbacks_.clear(); 145 on_initialized_callbacks_.clear();
139 } 146 }
140 147
141 } // namespace feature_engagement_tracker 148 } // namespace feature_engagement_tracker
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698