Index: ios/chrome/browser/reading_list/reading_list_model_factory.cc |
diff --git a/ios/chrome/browser/reading_list/reading_list_model_factory.cc b/ios/chrome/browser/reading_list/reading_list_model_factory.cc |
index 5b892cf3ae6647c46bda42394556496facefa054..085d4dc61b1b31c8197eef5b18809c9157cc635a 100644 |
--- a/ios/chrome/browser/reading_list/reading_list_model_factory.cc |
+++ b/ios/chrome/browser/reading_list/reading_list_model_factory.cc |
@@ -8,10 +8,16 @@ |
#include "base/memory/singleton.h" |
#include "components/keyed_service/ios/browser_state_dependency_manager.h" |
+#include "components/leveldb_proto/proto_database.h" |
+#include "components/leveldb_proto/proto_database_impl.h" |
+#include "components/pref_registry/pref_registry_syncable.h" |
#include "ios/chrome/browser/browser_state/browser_state_otr_helper.h" |
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
+#include "ios/chrome/browser/reading_list/proto/reading_list.pb.h" |
#include "ios/chrome/browser/reading_list/reading_list_model_impl.h" |
-#include "ios/chrome/browser/reading_list/reading_list_model_storage_defaults.h" |
+#include "ios/chrome/browser/reading_list/reading_list_pref_names.h" |
+#include "ios/chrome/browser/reading_list/reading_list_store.h" |
+#include "ios/web/public/web_thread.h" |
// static |
ReadingListModel* ReadingListModelFactory::GetForBrowserState( |
@@ -39,12 +45,33 @@ ReadingListModelFactory::ReadingListModelFactory() |
ReadingListModelFactory::~ReadingListModelFactory() {} |
+void ReadingListModelFactory::RegisterProfilePrefs( |
+ user_prefs::PrefRegistrySyncable* registry) { |
+ // Register a not syncable pref. |
+ registry->RegisterBooleanPref( |
+ reading_list::prefs::kReadingListHasUnseenEntries, false, 0); |
+} |
+ |
std::unique_ptr<KeyedService> ReadingListModelFactory::BuildServiceInstanceFor( |
web::BrowserState* context) const { |
- std::unique_ptr<ReadingListModelStorage> storage( |
- new ReadingListModelStorageDefaults()); |
+ scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
+ web::WebThread::GetBlockingPool()->GetSequencedTaskRunner( |
+ web::WebThread::GetBlockingPool()->GetSequenceToken()); |
+ base::FilePath database_dir( |
+ context->GetStatePath().Append(FILE_PATH_LITERAL("readinglist"))); |
+ |
+ std::unique_ptr<ReadingListDB> db = base::MakeUnique< |
+ leveldb_proto::ProtoDatabaseImpl<reading_list::ReadingListLocal>>( |
+ background_task_runner); |
+ |
+ std::unique_ptr<ReadingListStore> store = |
+ base::MakeUnique<ReadingListStore>(std::move(db), database_dir); |
+ |
+ ios::ChromeBrowserState* chrome_browser_state = |
+ ios::ChromeBrowserState::FromBrowserState(context); |
std::unique_ptr<ReadingListModelImpl> reading_list_model( |
- new ReadingListModelImpl(std::move(storage))); |
+ new ReadingListModelImpl(std::move(store), |
+ chrome_browser_state->GetPrefs())); |
return std::move(reading_list_model); |
} |