| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_DOM_DISTILLER_LAZY_DOM_DISTILLER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_DOM_DISTILLER_LAZY_DOM_DISTILLER_SERVICE_H_ |
| 6 #define CHROME_BROWSER_DOM_DISTILLER_LAZY_DOM_DISTILLER_SERVICE_H_ | 6 #define CHROME_BROWSER_DOM_DISTILLER_LAZY_DOM_DISTILLER_SERVICE_H_ |
| 7 | 7 |
| 8 #include "components/dom_distiller/core/dom_distiller_service.h" | 8 #include "components/dom_distiller/core/dom_distiller_service.h" |
| 9 #include "components/dom_distiller/core/task_tracker.h" | 9 #include "components/dom_distiller/core/task_tracker.h" |
| 10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class DomDistillerServiceFactory; | 22 class DomDistillerServiceFactory; |
| 23 | 23 |
| 24 // A class which helps with lazy instantiation of the DomDistillerService, using | 24 // A class which helps with lazy instantiation of the DomDistillerService, using |
| 25 // the BrowserContextKeyedServiceFactory for it. This class will delete itself | 25 // the BrowserContextKeyedServiceFactory for it. This class will delete itself |
| 26 // when the profile is destroyed. | 26 // when the profile is destroyed. |
| 27 class LazyDomDistillerService : public DomDistillerServiceInterface, | 27 class LazyDomDistillerService : public DomDistillerServiceInterface, |
| 28 public content::NotificationObserver { | 28 public content::NotificationObserver { |
| 29 public: | 29 public: |
| 30 LazyDomDistillerService(Profile* profile, | 30 LazyDomDistillerService(Profile* profile, |
| 31 const DomDistillerServiceFactory* service_factory); | 31 const DomDistillerServiceFactory* service_factory); |
| 32 virtual ~LazyDomDistillerService(); | 32 ~LazyDomDistillerService() override; |
| 33 | 33 |
| 34 public: | 34 public: |
| 35 // DomDistillerServiceInterface implementation: | 35 // DomDistillerServiceInterface implementation: |
| 36 virtual syncer::SyncableService* GetSyncableService() const override; | 36 syncer::SyncableService* GetSyncableService() const override; |
| 37 virtual const std::string AddToList( | 37 const std::string AddToList( |
| 38 const GURL& url, | 38 const GURL& url, |
| 39 scoped_ptr<DistillerPage> distiller_page, | 39 scoped_ptr<DistillerPage> distiller_page, |
| 40 const ArticleAvailableCallback& article_cb) override; | 40 const ArticleAvailableCallback& article_cb) override; |
| 41 virtual bool HasEntry(const std::string& entry_id) override; | 41 bool HasEntry(const std::string& entry_id) override; |
| 42 virtual std::string GetUrlForEntry(const std::string& entry_id) override; | 42 std::string GetUrlForEntry(const std::string& entry_id) override; |
| 43 virtual std::vector<ArticleEntry> GetEntries() const override; | 43 std::vector<ArticleEntry> GetEntries() const override; |
| 44 virtual scoped_ptr<ArticleEntry> RemoveEntry( | 44 scoped_ptr<ArticleEntry> RemoveEntry(const std::string& entry_id) override; |
| 45 const std::string& entry_id) override; | 45 scoped_ptr<ViewerHandle> ViewEntry(ViewRequestDelegate* delegate, |
| 46 virtual scoped_ptr<ViewerHandle> ViewEntry( | 46 scoped_ptr<DistillerPage> distiller_page, |
| 47 ViewRequestDelegate* delegate, | 47 const std::string& entry_id) override; |
| 48 scoped_ptr<DistillerPage> distiller_page, | 48 scoped_ptr<ViewerHandle> ViewUrl(ViewRequestDelegate* delegate, |
| 49 const std::string& entry_id) override; | 49 scoped_ptr<DistillerPage> distiller_page, |
| 50 virtual scoped_ptr<ViewerHandle> ViewUrl( | 50 const GURL& url) override; |
| 51 ViewRequestDelegate* delegate, | 51 scoped_ptr<DistillerPage> CreateDefaultDistillerPage( |
| 52 scoped_ptr<DistillerPage> distiller_page, | |
| 53 const GURL& url) override; | |
| 54 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPage( | |
| 55 const gfx::Size& render_view_size) override; | 52 const gfx::Size& render_view_size) override; |
| 56 virtual scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( | 53 scoped_ptr<DistillerPage> CreateDefaultDistillerPageWithHandle( |
| 57 scoped_ptr<SourcePageHandle> handle) override; | 54 scoped_ptr<SourcePageHandle> handle) override; |
| 58 virtual void AddObserver(DomDistillerObserver* observer) override; | 55 void AddObserver(DomDistillerObserver* observer) override; |
| 59 virtual void RemoveObserver(DomDistillerObserver* observer) override; | 56 void RemoveObserver(DomDistillerObserver* observer) override; |
| 60 virtual DistilledPagePrefs* GetDistilledPagePrefs() override; | 57 DistilledPagePrefs* GetDistilledPagePrefs() override; |
| 61 | 58 |
| 62 private: | 59 private: |
| 63 // Accessor method for the backing service instance. | 60 // Accessor method for the backing service instance. |
| 64 DomDistillerServiceInterface* instance() const; | 61 DomDistillerServiceInterface* instance() const; |
| 65 | 62 |
| 66 // content::NotificationObserver implementation: | 63 // content::NotificationObserver implementation: |
| 67 virtual void Observe(int type, | 64 void Observe(int type, |
| 68 const content::NotificationSource& source, | 65 const content::NotificationSource& source, |
| 69 const content::NotificationDetails& details) override; | 66 const content::NotificationDetails& details) override; |
| 70 | 67 |
| 71 // The Profile to use when retrieving the DomDistillerService and also the | 68 // The Profile to use when retrieving the DomDistillerService and also the |
| 72 // profile to listen for destruction of. | 69 // profile to listen for destruction of. |
| 73 Profile* profile_; | 70 Profile* profile_; |
| 74 | 71 |
| 75 // A BrowserContextKeyedServiceFactory for the DomDistillerService. | 72 // A BrowserContextKeyedServiceFactory for the DomDistillerService. |
| 76 const DomDistillerServiceFactory* service_factory_; | 73 const DomDistillerServiceFactory* service_factory_; |
| 77 | 74 |
| 78 // Used to track when the profile is shut down. | 75 // Used to track when the profile is shut down. |
| 79 content::NotificationRegistrar registrar_; | 76 content::NotificationRegistrar registrar_; |
| 80 | 77 |
| 81 DISALLOW_COPY_AND_ASSIGN(LazyDomDistillerService); | 78 DISALLOW_COPY_AND_ASSIGN(LazyDomDistillerService); |
| 82 }; | 79 }; |
| 83 | 80 |
| 84 } // namespace dom_distiller | 81 } // namespace dom_distiller |
| 85 | 82 |
| 86 #endif // CHROME_BROWSER_DOM_DISTILLER_LAZY_DOM_DISTILLER_SERVICE_H_ | 83 #endif // CHROME_BROWSER_DOM_DISTILLER_LAZY_DOM_DISTILLER_SERVICE_H_ |
| OLD | NEW |