diff options
author | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-05 12:44:23 +0000 |
---|---|---|
committer | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-05 12:44:23 +0000 |
commit | fb158e61a07dc6bbc6ce44a5d672ccd17f317591 (patch) | |
tree | abd5c99993ee0806ea4be00dc1fe84fe825b77ca /components | |
parent | 594458abf9aa343f8a7d3d43a5e576188307844b (diff) | |
download | chromium_src-fb158e61a07dc6bbc6ce44a5d672ccd17f317591.zip chromium_src-fb158e61a07dc6bbc6ce44a5d672ccd17f317591.tar.gz chromium_src-fb158e61a07dc6bbc6ce44a5d672ccd17f317591.tar.bz2 |
Move dom_distiller_service_factory to //chrome.
Treat the concept of "how to get the DomDistillerService to use for the given
browsing context" as an embedder-level concept rather than a concept within the
dom_distiller component.
Review URL: https://codereview.chromium.org/100623006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238958 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r-- | components/dom_distiller.gypi | 2 | ||||
-rw-r--r-- | components/dom_distiller/content/dom_distiller_service_factory.cc | 80 | ||||
-rw-r--r-- | components/dom_distiller/content/dom_distiller_service_factory.h | 53 |
3 files changed, 0 insertions, 135 deletions
diff --git a/components/dom_distiller.gypi b/components/dom_distiller.gypi index c60f063..f3c695a 100644 --- a/components/dom_distiller.gypi +++ b/components/dom_distiller.gypi @@ -112,8 +112,6 @@ 'sources': [ 'dom_distiller/content/distiller_page_web_contents.cc', 'dom_distiller/content/distiller_page_web_contents.h', - 'dom_distiller/content/dom_distiller_service_factory.cc', - 'dom_distiller/content/dom_distiller_service_factory.h', ], }, ], diff --git a/components/dom_distiller/content/dom_distiller_service_factory.cc b/components/dom_distiller/content/dom_distiller_service_factory.cc deleted file mode 100644 index 0b88cf3..0000000 --- a/components/dom_distiller/content/dom_distiller_service_factory.cc +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#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 { - -DomDistillerContextKeyedService::DomDistillerContextKeyedService( - scoped_ptr<DomDistillerStoreInterface> store, - scoped_ptr<DistillerFactory> distiller_factory) - : DomDistillerService(store.Pass(), distiller_factory.Pass()) {} - -// static -DomDistillerServiceFactory* DomDistillerServiceFactory::GetInstance() { - return Singleton<DomDistillerServiceFactory>::get(); -} - -// static -DomDistillerContextKeyedService* -DomDistillerServiceFactory::GetForBrowserContext( - content::BrowserContext* context) { - return static_cast<DomDistillerContextKeyedService*>( - GetInstance()->GetServiceForBrowserContext(context, true)); -} - -DomDistillerServiceFactory::DomDistillerServiceFactory() - : BrowserContextKeyedServiceFactory( - "DomDistillerService", - BrowserContextDependencyManager::GetInstance()) {} - -DomDistillerServiceFactory::~DomDistillerServiceFactory() {} - -BrowserContextKeyedService* DomDistillerServiceFactory::BuildServiceInstanceFor( - content::BrowserContext* profile) const { - - 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.PassAs<DomDistillerStoreInterface>(), - distiller_factory.Pass()); - -} - -content::BrowserContext* DomDistillerServiceFactory::GetBrowserContextToUse( - content::BrowserContext* context) const { - // TODO(cjhopman): Do we want this to be - // GetBrowserContextRedirectedInIncognito? If so, find some way to use that in - // components/. - return context; -} - -} // namespace apps diff --git a/components/dom_distiller/content/dom_distiller_service_factory.h b/components/dom_distiller/content/dom_distiller_service_factory.h deleted file mode 100644 index 33d1931..0000000 --- a/components/dom_distiller/content/dom_distiller_service_factory.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_DOM_DISTILLER_CONTENT_DOM_DISTILLER_SERVICE_FACTORY_H_ -#define COMPONENTS_DOM_DISTILLER_CONTENT_DOM_DISTILLER_SERVICE_FACTORY_H_ - -#include "base/memory/singleton.h" -#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h" -#include "components/dom_distiller/core/dom_distiller_service.h" - -namespace content { -class BrowserContext; -} // namespace content - -namespace dom_distiller { - -// A simple wrapper for DomDistillerService to expose it as a -// BrowserContextKeyedService. -class DomDistillerContextKeyedService : public BrowserContextKeyedService, - public DomDistillerService { - public: - DomDistillerContextKeyedService( - scoped_ptr<DomDistillerStoreInterface> store, - scoped_ptr<DistillerFactory> distiller_factory); - virtual ~DomDistillerContextKeyedService() {} - - private: - DISALLOW_COPY_AND_ASSIGN(DomDistillerContextKeyedService); -}; - -class DomDistillerServiceFactory : public BrowserContextKeyedServiceFactory { - public: - static DomDistillerServiceFactory* GetInstance(); - static DomDistillerContextKeyedService* GetForBrowserContext( - content::BrowserContext* context); - - private: - friend struct DefaultSingletonTraits<DomDistillerServiceFactory>; - - DomDistillerServiceFactory(); - virtual ~DomDistillerServiceFactory(); - - virtual BrowserContextKeyedService* BuildServiceInstanceFor( - content::BrowserContext* context) const OVERRIDE; - - virtual content::BrowserContext* GetBrowserContextToUse( - content::BrowserContext* context) const OVERRIDE; -}; - -} // namespace dom_distiller - -#endif |