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

Side by Side Diff: ios/chrome/browser/dom_distiller/dom_distiller_service_factory.cc

Issue 2673603002: Allow DomDistillerService to have no store. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « components/dom_distiller/core/dom_distiller_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/chrome/browser/dom_distiller/dom_distiller_service_factory.h" 5 #include "ios/chrome/browser/dom_distiller/dom_distiller_service_factory.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 : BrowserStateKeyedServiceFactory( 67 : BrowserStateKeyedServiceFactory(
68 "DomDistillerService", 68 "DomDistillerService",
69 BrowserStateDependencyManager::GetInstance()) { 69 BrowserStateDependencyManager::GetInstance()) {
70 } 70 }
71 71
72 DomDistillerServiceFactory::~DomDistillerServiceFactory() {} 72 DomDistillerServiceFactory::~DomDistillerServiceFactory() {}
73 73
74 std::unique_ptr<KeyedService> 74 std::unique_ptr<KeyedService>
75 DomDistillerServiceFactory::BuildServiceInstanceFor( 75 DomDistillerServiceFactory::BuildServiceInstanceFor(
76 web::BrowserState* context) const { 76 web::BrowserState* context) const {
77 scoped_refptr<base::SequencedTaskRunner> background_task_runner =
78 web::WebThread::GetBlockingPool()->GetSequencedTaskRunner(
79 web::WebThread::GetBlockingPool()->GetSequenceToken());
80
81 std::unique_ptr<leveldb_proto::ProtoDatabaseImpl<ArticleEntry>> db =
82 base::MakeUnique<leveldb_proto::ProtoDatabaseImpl<ArticleEntry>>(
83 background_task_runner);
84
85 base::FilePath database_dir(
86 context->GetStatePath().Append(FILE_PATH_LITERAL("Articles")));
87
88 std::unique_ptr<DomDistillerStore> dom_distiller_store =
89 base::MakeUnique<DomDistillerStore>(std::move(db), database_dir);
90 77
91 std::unique_ptr<DistillerPageFactory> distiller_page_factory = 78 std::unique_ptr<DistillerPageFactory> distiller_page_factory =
92 base::MakeUnique<DistillerPageFactoryIOS>(context); 79 base::MakeUnique<DistillerPageFactoryIOS>(context);
93 80
94 std::unique_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory = 81 std::unique_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory =
95 base::MakeUnique<DistillerURLFetcherFactory>( 82 base::MakeUnique<DistillerURLFetcherFactory>(
96 context->GetRequestContext()); 83 context->GetRequestContext());
97 84
98 dom_distiller::proto::DomDistillerOptions options; 85 dom_distiller::proto::DomDistillerOptions options;
99 std::unique_ptr<DistillerFactory> distiller_factory = 86 std::unique_ptr<DistillerFactory> distiller_factory =
100 base::MakeUnique<DistillerFactoryImpl>( 87 base::MakeUnique<DistillerFactoryImpl>(
101 std::move(distiller_url_fetcher_factory), options); 88 std::move(distiller_url_fetcher_factory), options);
102 std::unique_ptr<DistilledPagePrefs> distilled_page_prefs = 89 std::unique_ptr<DistilledPagePrefs> distilled_page_prefs =
103 base::MakeUnique<DistilledPagePrefs>( 90 base::MakeUnique<DistilledPagePrefs>(
104 ios::ChromeBrowserState::FromBrowserState(context)->GetPrefs()); 91 ios::ChromeBrowserState::FromBrowserState(context)->GetPrefs());
105 92
106 return base::MakeUnique<DomDistillerKeyedService>( 93 return base::MakeUnique<DomDistillerKeyedService>(
107 std::move(dom_distiller_store), std::move(distiller_factory), 94 nullptr, std::move(distiller_factory), std::move(distiller_page_factory),
108 std::move(distiller_page_factory), std::move(distilled_page_prefs)); 95 std::move(distilled_page_prefs));
109 } 96 }
110 97
111 web::BrowserState* DomDistillerServiceFactory::GetBrowserStateToUse( 98 web::BrowserState* DomDistillerServiceFactory::GetBrowserStateToUse(
112 web::BrowserState* context) const { 99 web::BrowserState* context) const {
113 // Makes normal profile and off-the-record profile use same service instance. 100 // Makes normal profile and off-the-record profile use same service instance.
114 return GetBrowserStateRedirectedInIncognito(context); 101 return GetBrowserStateRedirectedInIncognito(context);
115 } 102 }
116 103
117 } // namespace dom_distiller 104 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/core/dom_distiller_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698