diff options
author | yfriedman@chromium.org <yfriedman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-18 19:51:47 +0000 |
---|---|---|
committer | yfriedman@chromium.org <yfriedman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-18 19:51:47 +0000 |
commit | 7d5080bfe2ebdcd95d61aabd11fe801d733f60e4 (patch) | |
tree | b16f052744acf9396b9450559fb53b5150e3987e /components | |
parent | 93501684ffabd3dc200123a9ad84f4741414b1d9 (diff) | |
download | chromium_src-7d5080bfe2ebdcd95d61aabd11fe801d733f60e4.zip chromium_src-7d5080bfe2ebdcd95d61aabd11fe801d733f60e4.tar.gz chromium_src-7d5080bfe2ebdcd95d61aabd11fe801d733f60e4.tar.bz2 |
Initialize DomDistillerStore
Needed as part of setting up the DomDistillerBrowserContextKeyedService.
Distilled articles will be stored in an "Articles" directory in the
user's profile directory.
BUG=288015
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=235562
NOTRY=true
Review URL: https://codereview.chromium.org/63553009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235799 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r-- | components/dom_distiller/content/dom_distiller_service_factory.cc | 29 | ||||
-rw-r--r-- | components/dom_distiller/core/dom_distiller_store.h | 2 |
2 files changed, 25 insertions, 6 deletions
diff --git a/components/dom_distiller/content/dom_distiller_service_factory.cc b/components/dom_distiller/content/dom_distiller_service_factory.cc index a5d7e0d..0b88cf3 100644 --- a/components/dom_distiller/content/dom_distiller_service_factory.cc +++ b/components/dom_distiller/content/dom_distiller_service_factory.cc @@ -4,11 +4,13 @@ #include "components/dom_distiller/content/dom_distiller_service_factory.h" +#include "base/threading/sequenced_worker_pool.h" #include "components/browser_context_keyed_service/browser_context_dependency_manager.h" #include "components/dom_distiller/content/distiller_page_web_contents.h" #include "components/dom_distiller/core/distiller.h" #include "components/dom_distiller/core/dom_distiller_store.h" #include "content/public/browser/browser_context.h" +#include "content/public/browser/browser_thread.h" namespace dom_distiller { @@ -39,15 +41,32 @@ DomDistillerServiceFactory::~DomDistillerServiceFactory() {} BrowserContextKeyedService* DomDistillerServiceFactory::BuildServiceInstanceFor( content::BrowserContext* profile) const { - scoped_ptr<DomDistillerStoreInterface> dom_distiller_store; + + scoped_refptr<base::SequencedTaskRunner> background_task_runner = + content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( + content::BrowserThread::GetBlockingPool()->GetSequenceToken()); + + scoped_ptr<DomDistillerDatabase> db( + new DomDistillerDatabase(background_task_runner)); + + base::FilePath database_dir( + profile->GetPath().Append(FILE_PATH_LITERAL("Articles"))); + + scoped_ptr<DomDistillerStore> dom_distiller_store( + new DomDistillerStore(db.PassAs<DomDistillerDatabaseInterface>(), + database_dir)); + scoped_ptr<DistillerPageFactory> distiller_page_factory( new DistillerPageWebContentsFactory(profile)); scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( new DistillerURLFetcherFactory(profile->GetRequestContext())); - scoped_ptr<DistillerFactory> distiller_factory(new DistillerFactoryImpl( - distiller_page_factory.Pass(), distiller_url_fetcher_factory.Pass())); - return new DomDistillerContextKeyedService(dom_distiller_store.Pass(), - distiller_factory.Pass()); + scoped_ptr<DistillerFactory> distiller_factory( + new DistillerFactoryImpl(distiller_page_factory.Pass(), + distiller_url_fetcher_factory.Pass())); + return new DomDistillerContextKeyedService( + dom_distiller_store.PassAs<DomDistillerStoreInterface>(), + distiller_factory.Pass()); + } content::BrowserContext* DomDistillerServiceFactory::GetBrowserContextToUse( diff --git a/components/dom_distiller/core/dom_distiller_store.h b/components/dom_distiller/core/dom_distiller_store.h index 18641b7..c533fc7 100644 --- a/components/dom_distiller/core/dom_distiller_store.h +++ b/components/dom_distiller/core/dom_distiller_store.h @@ -65,7 +65,7 @@ class DomDistillerStoreInterface { // to the other (i.e. non-source) two models. // TODO(cjhopman): Support deleting entries. class DomDistillerStore : public syncer::SyncableService, - DomDistillerStoreInterface { + public DomDistillerStoreInterface { public: // Creates storage using the given database for local storage. Initializes the // database with |database_dir|. |