| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ |
| 6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "components/dom_distiller/core/article_entry.h" | 15 #include "components/dom_distiller/core/article_entry.h" |
| 16 | 16 |
| 17 class GURL; | 17 class GURL; |
| 18 | 18 |
| 19 namespace syncer { | 19 namespace syncer { |
| 20 class SyncableService; | 20 class SyncableService; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace dom_distiller { | 23 namespace dom_distiller { |
| 24 | 24 |
| 25 class DistilledArticleProto; | 25 class DistilledArticleProto; |
| 26 class DistilledContentStore; |
| 26 class DistillerFactory; | 27 class DistillerFactory; |
| 27 class DomDistillerObserver; | 28 class DomDistillerObserver; |
| 28 class DomDistillerStoreInterface; | 29 class DomDistillerStoreInterface; |
| 29 class TaskTracker; | 30 class TaskTracker; |
| 30 class ViewerHandle; | 31 class ViewerHandle; |
| 31 class ViewRequestDelegate; | 32 class ViewRequestDelegate; |
| 32 | 33 |
| 33 // Service for interacting with the Dom Distiller. | 34 // Service for interacting with the Dom Distiller. |
| 34 // Construction, destruction, and usage of this service must happen on the same | 35 // Construction, destruction, and usage of this service must happen on the same |
| 35 // thread. Callbacks will be called on that same thread. | 36 // thread. Callbacks will be called on that same thread. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 virtual scoped_ptr<ViewerHandle> ViewUrl(ViewRequestDelegate* delegate, | 97 virtual scoped_ptr<ViewerHandle> ViewUrl(ViewRequestDelegate* delegate, |
| 97 const GURL& url) OVERRIDE; | 98 const GURL& url) OVERRIDE; |
| 98 virtual void AddObserver(DomDistillerObserver* observer) OVERRIDE; | 99 virtual void AddObserver(DomDistillerObserver* observer) OVERRIDE; |
| 99 virtual void RemoveObserver(DomDistillerObserver* observer) OVERRIDE; | 100 virtual void RemoveObserver(DomDistillerObserver* observer) OVERRIDE; |
| 100 | 101 |
| 101 private: | 102 private: |
| 102 void CancelTask(TaskTracker* task); | 103 void CancelTask(TaskTracker* task); |
| 103 void AddDistilledPageToList(const ArticleEntry& entry, | 104 void AddDistilledPageToList(const ArticleEntry& entry, |
| 104 const DistilledArticleProto* article_proto, | 105 const DistilledArticleProto* article_proto, |
| 105 bool distillation_succeeded); | 106 bool distillation_succeeded); |
| 107 void AddDistilledContentToStore(const ArticleEntry& entry, |
| 108 const DistilledArticleProto* article_proto, |
| 109 bool distillation_succeeded); |
| 106 | 110 |
| 107 TaskTracker* CreateTaskTracker(const ArticleEntry& entry); | 111 TaskTracker* CreateTaskTracker(const ArticleEntry& entry); |
| 108 | 112 |
| 109 TaskTracker* GetTaskTrackerForEntry(const ArticleEntry& entry) const; | 113 TaskTracker* GetTaskTrackerForEntry(const ArticleEntry& entry) const; |
| 110 | 114 |
| 111 // Gets the task tracker for the given |url| or |entry|. If no appropriate | 115 // Gets the task tracker for the given |url| or |entry|. If no appropriate |
| 112 // tracker exists, this will create one, initialize it, and add it to | 116 // tracker exists, this will create one, initialize it, and add it to |
| 113 // |tasks_|. | 117 // |tasks_|. |
| 114 TaskTracker* GetOrCreateTaskTrackerForUrl(const GURL& url); | 118 TaskTracker* GetOrCreateTaskTrackerForUrl(const GURL& url); |
| 115 TaskTracker* GetOrCreateTaskTrackerForEntry(const ArticleEntry& entry); | 119 TaskTracker* GetOrCreateTaskTrackerForEntry(const ArticleEntry& entry); |
| 116 | 120 |
| 117 scoped_ptr<DomDistillerStoreInterface> store_; | 121 scoped_ptr<DomDistillerStoreInterface> store_; |
| 122 scoped_ptr<DistilledContentStore> content_store_; |
| 118 scoped_ptr<DistillerFactory> distiller_factory_; | 123 scoped_ptr<DistillerFactory> distiller_factory_; |
| 119 | 124 |
| 120 typedef ScopedVector<TaskTracker> TaskList; | 125 typedef ScopedVector<TaskTracker> TaskList; |
| 121 TaskList tasks_; | 126 TaskList tasks_; |
| 122 | 127 |
| 123 DISALLOW_COPY_AND_ASSIGN(DomDistillerService); | 128 DISALLOW_COPY_AND_ASSIGN(DomDistillerService); |
| 124 }; | 129 }; |
| 125 | 130 |
| 126 } // namespace dom_distiller | 131 } // namespace dom_distiller |
| 127 | 132 |
| 128 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ | 133 #endif // COMPONENTS_DOM_DISTILLER_CORE_DOM_DISTILLER_SERVICE_H_ |
| OLD | NEW |