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

Unified Diff: ios/chrome/browser/reading_list/reading_list_model_factory.cc

Issue 2369303002: Reading List create protobuf store (Closed)
Patch Set: feedback Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
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.
sdefresne 2016/10/07 09:44:30 nit: this comment has no value in my opinion (if y
+ 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<
sdefresne 2016/10/07 09:44:30 nit: auto db = base::MakeUnique<...>(...) is also
+ 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),
sdefresne 2016/10/07 09:44:30 Use base::MakeUnique<> as the constructor is publi
+ chrome_browser_state->GetPrefs()));
return std::move(reading_list_model);
sdefresne 2016/10/07 09:44:30 Do not use "return std::move(...)" with a std::uni
}

Powered by Google App Engine
This is Rietveld 408576698