| OLD | NEW |
| 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> |
| 8 |
| 7 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 12 #include "base/threading/sequenced_worker_pool.h" |
| 11 #include "components/dom_distiller/core/article_entry.h" | 13 #include "components/dom_distiller/core/article_entry.h" |
| 12 #include "components/dom_distiller/core/distiller.h" | 14 #include "components/dom_distiller/core/distiller.h" |
| 13 #include "components/dom_distiller/core/dom_distiller_service.h" | 15 #include "components/dom_distiller/core/dom_distiller_service.h" |
| 14 #include "components/dom_distiller/core/dom_distiller_store.h" | 16 #include "components/dom_distiller/core/dom_distiller_store.h" |
| 15 #include "components/dom_distiller/ios/distiller_page_factory_ios.h" | 17 #include "components/dom_distiller/ios/distiller_page_factory_ios.h" |
| 16 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 27 // KeyedService. | 29 // KeyedService. |
| 28 class DomDistillerKeyedService | 30 class DomDistillerKeyedService |
| 29 : public KeyedService, | 31 : public KeyedService, |
| 30 public dom_distiller::DomDistillerService { | 32 public dom_distiller::DomDistillerService { |
| 31 public: | 33 public: |
| 32 DomDistillerKeyedService( | 34 DomDistillerKeyedService( |
| 33 scoped_ptr<dom_distiller::DomDistillerStoreInterface> store, | 35 scoped_ptr<dom_distiller::DomDistillerStoreInterface> store, |
| 34 scoped_ptr<dom_distiller::DistillerFactory> distiller_factory, | 36 scoped_ptr<dom_distiller::DistillerFactory> distiller_factory, |
| 35 scoped_ptr<dom_distiller::DistillerPageFactory> distiller_page_factory, | 37 scoped_ptr<dom_distiller::DistillerPageFactory> distiller_page_factory, |
| 36 scoped_ptr<dom_distiller::DistilledPagePrefs> distilled_page_prefs) | 38 scoped_ptr<dom_distiller::DistilledPagePrefs> distilled_page_prefs) |
| 37 : DomDistillerService(store.Pass(), | 39 : DomDistillerService(std::move(store), |
| 38 distiller_factory.Pass(), | 40 std::move(distiller_factory), |
| 39 distiller_page_factory.Pass(), | 41 std::move(distiller_page_factory), |
| 40 distilled_page_prefs.Pass()) {} | 42 std::move(distilled_page_prefs)) {} |
| 41 | 43 |
| 42 ~DomDistillerKeyedService() override {} | 44 ~DomDistillerKeyedService() override {} |
| 43 | 45 |
| 44 private: | 46 private: |
| 45 DISALLOW_COPY_AND_ASSIGN(DomDistillerKeyedService); | 47 DISALLOW_COPY_AND_ASSIGN(DomDistillerKeyedService); |
| 46 }; | 48 }; |
| 47 } // namespace | 49 } // namespace |
| 48 | 50 |
| 49 namespace dom_distiller { | 51 namespace dom_distiller { |
| 50 | 52 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 76 web::WebThread::GetBlockingPool()->GetSequenceToken()); | 78 web::WebThread::GetBlockingPool()->GetSequenceToken()); |
| 77 | 79 |
| 78 scoped_ptr<leveldb_proto::ProtoDatabaseImpl<ArticleEntry>> db( | 80 scoped_ptr<leveldb_proto::ProtoDatabaseImpl<ArticleEntry>> db( |
| 79 new leveldb_proto::ProtoDatabaseImpl<ArticleEntry>( | 81 new leveldb_proto::ProtoDatabaseImpl<ArticleEntry>( |
| 80 background_task_runner)); | 82 background_task_runner)); |
| 81 | 83 |
| 82 base::FilePath database_dir( | 84 base::FilePath database_dir( |
| 83 context->GetStatePath().Append(FILE_PATH_LITERAL("Articles"))); | 85 context->GetStatePath().Append(FILE_PATH_LITERAL("Articles"))); |
| 84 | 86 |
| 85 scoped_ptr<DomDistillerStore> dom_distiller_store( | 87 scoped_ptr<DomDistillerStore> dom_distiller_store( |
| 86 new DomDistillerStore(db.Pass(), database_dir)); | 88 new DomDistillerStore(std::move(db), database_dir)); |
| 87 | 89 |
| 88 scoped_ptr<DistillerPageFactory> distiller_page_factory( | 90 scoped_ptr<DistillerPageFactory> distiller_page_factory( |
| 89 new DistillerPageFactoryIOS(context)); | 91 new DistillerPageFactoryIOS(context)); |
| 90 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( | 92 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory( |
| 91 new DistillerURLFetcherFactory(context->GetRequestContext())); | 93 new DistillerURLFetcherFactory(context->GetRequestContext())); |
| 92 | 94 |
| 93 dom_distiller::proto::DomDistillerOptions options; | 95 dom_distiller::proto::DomDistillerOptions options; |
| 94 scoped_ptr<DistillerFactory> distiller_factory( | 96 scoped_ptr<DistillerFactory> distiller_factory(new DistillerFactoryImpl( |
| 95 new DistillerFactoryImpl(distiller_url_fetcher_factory.Pass(), options)); | 97 std::move(distiller_url_fetcher_factory), options)); |
| 96 scoped_ptr<DistilledPagePrefs> distilled_page_prefs(new DistilledPagePrefs( | 98 scoped_ptr<DistilledPagePrefs> distilled_page_prefs(new DistilledPagePrefs( |
| 97 ios::ChromeBrowserState::FromBrowserState(context)->GetPrefs())); | 99 ios::ChromeBrowserState::FromBrowserState(context)->GetPrefs())); |
| 98 | 100 |
| 99 return make_scoped_ptr(new DomDistillerKeyedService( | 101 return make_scoped_ptr(new DomDistillerKeyedService( |
| 100 dom_distiller_store.Pass(), distiller_factory.Pass(), | 102 std::move(dom_distiller_store), std::move(distiller_factory), |
| 101 distiller_page_factory.Pass(), distilled_page_prefs.Pass())); | 103 std::move(distiller_page_factory), std::move(distilled_page_prefs))); |
| 102 } | 104 } |
| 103 | 105 |
| 104 web::BrowserState* DomDistillerServiceFactory::GetBrowserStateToUse( | 106 web::BrowserState* DomDistillerServiceFactory::GetBrowserStateToUse( |
| 105 web::BrowserState* context) const { | 107 web::BrowserState* context) const { |
| 106 // Makes normal profile and off-the-record profile use same service instance. | 108 // Makes normal profile and off-the-record profile use same service instance. |
| 107 return GetBrowserStateRedirectedInIncognito(context); | 109 return GetBrowserStateRedirectedInIncognito(context); |
| 108 } | 110 } |
| 109 | 111 |
| 110 } // namespace dom_distiller | 112 } // namespace dom_distiller |
| OLD | NEW |