| 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 5be056091b0e061fc1c64f957c0e18d4c9b75b54..24eb53a7cf79c010320e2967ddc202b64dfc1788 100644
|
| --- a/ios/chrome/browser/reading_list/reading_list_model_factory.cc
|
| +++ b/ios/chrome/browser/reading_list/reading_list_model_factory.cc
|
| @@ -6,19 +6,26 @@
|
|
|
| #include <utility>
|
|
|
| +#include "base/files/file_path.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "base/memory/singleton.h"
|
| #include "components/keyed_service/ios/browser_state_dependency_manager.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/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 +33,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 +61,23 @@ 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")));
|
| +
|
| + // TODO(crbug.com/664920): use a shared location for the store.
|
| + std::unique_ptr<ReadingListStore> store = base::MakeUnique<ReadingListStore>(
|
| + base::Bind(&syncer::ModelTypeStore::CreateStore, syncer::READING_LIST,
|
| + database_dir.AsUTF8Unsafe(), background_task_runner),
|
| + base::Bind(&syncer::ModelTypeChangeProcessor::Create));
|
| +
|
| ios::ChromeBrowserState* chrome_browser_state =
|
| ios::ChromeBrowserState::FromBrowserState(context);
|
| std::unique_ptr<KeyedService> reading_list_model =
|
| - base::MakeUnique<ReadingListModelImpl>(std::move(storage),
|
| + base::MakeUnique<ReadingListModelImpl>(std::move(store),
|
| chrome_browser_state->GetPrefs());
|
| return reading_list_model;
|
| }
|
|
|