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

Side by Side Diff: components/dom_distiller/content/dom_distiller_service_factory.cc

Issue 63553009: Initialize DomDistillerStore (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add include Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | components/dom_distiller/core/dom_distiller_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/dom_distiller/content/dom_distiller_service_factory.h" 5 #include "components/dom_distiller/content/dom_distiller_service_factory.h"
6 6
7 #include "base/threading/sequenced_worker_pool.h"
7 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 8 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
8 #include "components/dom_distiller/content/distiller_page_web_contents.h" 9 #include "components/dom_distiller/content/distiller_page_web_contents.h"
9 #include "components/dom_distiller/core/distiller.h" 10 #include "components/dom_distiller/core/distiller.h"
10 #include "components/dom_distiller/core/dom_distiller_store.h" 11 #include "components/dom_distiller/core/dom_distiller_store.h"
11 #include "content/public/browser/browser_context.h" 12 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/browser_thread.h"
12 14
13 namespace dom_distiller { 15 namespace dom_distiller {
14 16
15 DomDistillerContextKeyedService::DomDistillerContextKeyedService( 17 DomDistillerContextKeyedService::DomDistillerContextKeyedService(
16 scoped_ptr<DomDistillerStoreInterface> store, 18 scoped_ptr<DomDistillerStoreInterface> store,
17 scoped_ptr<DistillerFactory> distiller_factory) 19 scoped_ptr<DistillerFactory> distiller_factory)
18 : DomDistillerService(store.Pass(), distiller_factory.Pass()) {} 20 : DomDistillerService(store.Pass(), distiller_factory.Pass()) {}
19 21
20 // static 22 // static
21 DomDistillerServiceFactory* DomDistillerServiceFactory::GetInstance() { 23 DomDistillerServiceFactory* DomDistillerServiceFactory::GetInstance() {
(...skipping 10 matching lines...) Expand all
32 34
33 DomDistillerServiceFactory::DomDistillerServiceFactory() 35 DomDistillerServiceFactory::DomDistillerServiceFactory()
34 : BrowserContextKeyedServiceFactory( 36 : BrowserContextKeyedServiceFactory(
35 "DomDistillerService", 37 "DomDistillerService",
36 BrowserContextDependencyManager::GetInstance()) {} 38 BrowserContextDependencyManager::GetInstance()) {}
37 39
38 DomDistillerServiceFactory::~DomDistillerServiceFactory() {} 40 DomDistillerServiceFactory::~DomDistillerServiceFactory() {}
39 41
40 BrowserContextKeyedService* DomDistillerServiceFactory::BuildServiceInstanceFor( 42 BrowserContextKeyedService* DomDistillerServiceFactory::BuildServiceInstanceFor(
41 content::BrowserContext* profile) const { 43 content::BrowserContext* profile) const {
42 scoped_ptr<DomDistillerStoreInterface> dom_distiller_store; 44
45 scoped_refptr<base::SequencedTaskRunner> background_task_runner =
46 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
47 content::BrowserThread::GetBlockingPool()->GetSequenceToken());
48
49 scoped_ptr<DomDistillerDatabase> db(
50 new DomDistillerDatabase(background_task_runner));
51
52 base::FilePath database_dir(
53 profile->GetPath().Append(FILE_PATH_LITERAL("Articles")));
54
55 scoped_ptr<DomDistillerStore> dom_distiller_store(
56 new DomDistillerStore(db.PassAs<DomDistillerDatabaseInterface>(),
57 database_dir));
58
43 scoped_ptr<DistillerPageFactory> distiller_page_factory( 59 scoped_ptr<DistillerPageFactory> distiller_page_factory(
44 new DistillerPageWebContentsFactory(profile)); 60 new DistillerPageWebContentsFactory(profile));
45 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( 61 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory(
46 new DistillerURLFetcherFactory(profile->GetRequestContext())); 62 new DistillerURLFetcherFactory(profile->GetRequestContext()));
47 scoped_ptr<DistillerFactory> distiller_factory(new DistillerFactoryImpl( 63 scoped_ptr<DistillerFactory> distiller_factory(
48 distiller_page_factory.Pass(), distiller_url_fetcher_factory.Pass())); 64 new DistillerFactoryImpl(distiller_page_factory.Pass(),
49 return new DomDistillerContextKeyedService(dom_distiller_store.Pass(), 65 distiller_url_fetcher_factory.Pass()));
50 distiller_factory.Pass()); 66 return new DomDistillerContextKeyedService(
67 dom_distiller_store.PassAs<DomDistillerStoreInterface>(),
68 distiller_factory.Pass());
69
51 } 70 }
52 71
53 content::BrowserContext* DomDistillerServiceFactory::GetBrowserContextToUse( 72 content::BrowserContext* DomDistillerServiceFactory::GetBrowserContextToUse(
54 content::BrowserContext* context) const { 73 content::BrowserContext* context) const {
55 // TODO(cjhopman): Do we want this to be 74 // TODO(cjhopman): Do we want this to be
56 // GetBrowserContextRedirectedInIncognito? If so, find some way to use that in 75 // GetBrowserContextRedirectedInIncognito? If so, find some way to use that in
57 // components/. 76 // components/.
58 return context; 77 return context;
59 } 78 }
60 79
61 } // namespace apps 80 } // namespace apps
OLDNEW
« no previous file with comments | « no previous file | components/dom_distiller/core/dom_distiller_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698