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

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

Issue 2451843002: Add Store+Sync to reading list. (Closed)
Patch Set: rebase Created 4 years, 1 month 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 ec56e688e3910a299eb45c8f76f68586aea07230..daa989a3f5387435d3bafa7502de1ecdb3a530d5 100644
--- a/ios/chrome/browser/reading_list/reading_list_model_factory.cc
+++ b/ios/chrome/browser/reading_list/reading_list_model_factory.cc
@@ -9,16 +9,24 @@
#include "base/memory/ptr_util.h"
#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"
pavely 2016/11/14 07:45:33 You shouldn't need these two headers.
Olivier 2016/11/14 11:36:49 Done.
#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/experimental_flags.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(
ios::ChromeBrowserState* browser_state) {
+ if (!experimental_flags::IsReadingListEnabled()) {
+ return nullptr;
+ }
return static_cast<ReadingListModelImpl*>(
GetInstance()->GetServiceForBrowserState(browser_state, true));
}
@@ -26,6 +34,9 @@ ReadingListModel* ReadingListModelFactory::GetForBrowserState(
// static
ReadingListModel* ReadingListModelFactory::GetForBrowserStateIfExists(
ios::ChromeBrowserState* browser_state) {
+ if (!experimental_flags::IsReadingListEnabled()) {
+ return nullptr;
+ }
return static_cast<ReadingListModelImpl*>(
GetInstance()->GetServiceForBrowserState(browser_state, false));
}
@@ -51,11 +62,22 @@ void ReadingListModelFactory::RegisterBrowserStatePrefs(
std::unique_ptr<KeyedService> ReadingListModelFactory::BuildServiceInstanceFor(
web::BrowserState* context) const {
- auto storage = base::MakeUnique<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<ReadingListStore> store = base::MakeUnique<ReadingListStore>(
+ base::Bind(&syncer::ModelTypeStore::CreateStore, syncer::READING_LIST,
+ database_dir.AsUTF8Unsafe(), background_task_runner),
pavely 2016/11/14 07:45:33 This code creates store in a location separate fro
Olivier 2016/11/14 11:36:49 Done. Will there be a loss of data when the path i
+ base::Bind(&syncer::ModelTypeChangeProcessor::Create));
+
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 reading_list_model;
}

Powered by Google App Engine
This is Rietveld 408576698