Chromium Code Reviews| Index: components/dom_distiller/core/dom_distiller_service.h |
| diff --git a/components/dom_distiller/core/dom_distiller_service.h b/components/dom_distiller/core/dom_distiller_service.h |
| index 630b184e5eb5e2fda8e5054fbfb5b649c4ad335b..b4df171e4452bb55bb276a4e085ef236d4227b9b 100644 |
| --- a/components/dom_distiller/core/dom_distiller_service.h |
| +++ b/components/dom_distiller/core/dom_distiller_service.h |
| @@ -30,42 +30,71 @@ class TaskTracker; |
| class ViewerHandle; |
| class ViewRequestDelegate; |
| -// Provide a view of the article list and ways of interacting with it. |
| -class DomDistillerService { |
| +// Service for interacting with the Dom Distiller. |
| +// Construction, destruction, and usage of this service must happen on the same |
| +// thread. Callbacks will be called on that same thread. |
| +class DomDistillerServiceInterface { |
| public: |
| typedef base::Callback<void(bool)> ArticleAvailableCallback; |
| + virtual ~DomDistillerServiceInterface() {} |
| - DomDistillerService(scoped_ptr<DomDistillerStoreInterface> store, |
| - scoped_ptr<DistillerFactory> distiller_factory); |
| - ~DomDistillerService(); |
| - |
| - syncer::SyncableService* GetSyncableService() const; |
| + virtual syncer::SyncableService* GetSyncableService() const = 0; |
| // Distill the article at |url| and add the resulting entry to the DOM |
| - // distiller list. |article_cb| is invoked with true if article is |
| - // available offline. |
| - const std::string AddToList(const GURL& url, |
| - const ArticleAvailableCallback& article_cb); |
| + // distiller list. |article_cb| is always invoked, and the bool argument to it |
| + // represents whether the article is available offline. |
| + virtual const std::string AddToList( |
| + const GURL& url, |
| + const ArticleAvailableCallback& article_cb) = 0; |
| // Gets the full list of entries. |
| - std::vector<ArticleEntry> GetEntries() const; |
| + virtual std::vector<ArticleEntry> GetEntries() const = 0; |
| // Removes the specified entry from the dom distiller store. |
| - scoped_ptr<ArticleEntry> RemoveEntry(const std::string& entry_id); |
| + virtual scoped_ptr<ArticleEntry> RemoveEntry(const std::string& entry_id) = 0; |
| // Request to view an article by entry id. Returns a null pointer if no entry |
| // with |entry_id| exists. The ViewerHandle should be destroyed before the |
| // ViewRequestDelegate. The request will be cancelled when the handle is |
| - // destroyed (or when this service is destroyed). |
| - scoped_ptr<ViewerHandle> ViewEntry(ViewRequestDelegate* delegate, |
| - const std::string& entry_id); |
| + // destroyed (or when this service is destroyed), which also ensures that |
| + // the |delegate| is not called after that. |
| + virtual scoped_ptr<ViewerHandle> ViewEntry(ViewRequestDelegate* delegate, |
| + const std::string& entry_id) = 0; |
| // Request to view an article by url. |
| - scoped_ptr<ViewerHandle> ViewUrl(ViewRequestDelegate* delegate, |
| - const GURL& url); |
| + virtual scoped_ptr<ViewerHandle> ViewUrl(ViewRequestDelegate* delegate, |
| + const GURL& url) = 0; |
| + |
| + virtual void AddObserver(DomDistillerObserver* observer) = 0; |
| + virtual void RemoveObserver(DomDistillerObserver* observer) = 0; |
| + protected: |
| + DomDistillerServiceInterface() {} |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DomDistillerServiceInterface); |
|
shashi
2014/02/27 04:29:08
private: before DISALLOW_COPY_AND_ASSIGN.
This no
nyquist
2014/02/27 19:50:19
Done.
|
| +}; |
| - void AddObserver(DomDistillerObserver* observer); |
| - void RemoveObserver(DomDistillerObserver* observer); |
| +// Provide a view of the article list and ways of interacting with it. |
| +class DomDistillerService : public DomDistillerServiceInterface { |
| + public: |
| + DomDistillerService(scoped_ptr<DomDistillerStoreInterface> store, |
| + scoped_ptr<DistillerFactory> distiller_factory); |
| + virtual ~DomDistillerService(); |
| + |
| + // DomDistillerServiceInterface implementation. |
| + virtual syncer::SyncableService* GetSyncableService() const OVERRIDE; |
| + virtual const std::string AddToList( |
| + const GURL& url, |
| + const ArticleAvailableCallback& article_cb) OVERRIDE; |
| + virtual std::vector<ArticleEntry> GetEntries() const OVERRIDE; |
| + virtual scoped_ptr<ArticleEntry> RemoveEntry(const std::string& entry_id) |
| + OVERRIDE; |
| + virtual scoped_ptr<ViewerHandle> ViewEntry(ViewRequestDelegate* delegate, |
| + const std::string& entry_id) |
| + OVERRIDE; |
| + virtual scoped_ptr<ViewerHandle> ViewUrl(ViewRequestDelegate* delegate, |
| + const GURL& url) OVERRIDE; |
| + virtual void AddObserver(DomDistillerObserver* observer) OVERRIDE; |
| + virtual void RemoveObserver(DomDistillerObserver* observer) OVERRIDE; |
| private: |
| void CancelTask(TaskTracker* task); |
| @@ -88,8 +117,6 @@ class DomDistillerService { |
| typedef ScopedVector<TaskTracker> TaskList; |
| TaskList tasks_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(DomDistillerService); |
| }; |
| } // namespace dom_distiller |