| 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 #include "components/dom_distiller/core/dom_distiller_service.h" | 5 #include "components/dom_distiller/core/dom_distiller_service.h" |
| 6 | 6 |
| 7 #include "base/guid.h" | 7 #include "base/guid.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" |
| 9 #include "components/dom_distiller/core/distilled_content_store.h" | 11 #include "components/dom_distiller/core/distilled_content_store.h" |
| 10 #include "components/dom_distiller/core/dom_distiller_store.h" | 12 #include "components/dom_distiller/core/dom_distiller_store.h" |
| 11 #include "components/dom_distiller/core/proto/distilled_article.pb.h" | 13 #include "components/dom_distiller/core/proto/distilled_article.pb.h" |
| 12 #include "components/dom_distiller/core/task_tracker.h" | 14 #include "components/dom_distiller/core/task_tracker.h" |
| 13 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 14 | 16 |
| 15 namespace dom_distiller { | 17 namespace dom_distiller { |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 TaskTracker* task_tracker; | 79 TaskTracker* task_tracker; |
| 78 if (is_already_added) { | 80 if (is_already_added) { |
| 79 task_tracker = GetTaskTrackerForEntry(entry); | 81 task_tracker = GetTaskTrackerForEntry(entry); |
| 80 if (task_tracker == NULL) { | 82 if (task_tracker == NULL) { |
| 81 // Entry is in the store but there is no task tracker. This could | 83 // Entry is in the store but there is no task tracker. This could |
| 82 // happen when distillation has already completed. For now just return | 84 // happen when distillation has already completed. For now just return |
| 83 // true. | 85 // true. |
| 84 // TODO(shashishekhar): Change this to check if article is available, | 86 // TODO(shashishekhar): Change this to check if article is available, |
| 85 // An article may not be available for a variety of reasons, e.g. | 87 // An article may not be available for a variety of reasons, e.g. |
| 86 // distillation failure or blobs not available locally. | 88 // distillation failure or blobs not available locally. |
| 87 base::MessageLoop::current()->PostTask(FROM_HERE, | 89 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 88 base::Bind(article_cb, true)); | 90 FROM_HERE, base::Bind(article_cb, true)); |
| 89 return entry.entry_id(); | 91 return entry.entry_id(); |
| 90 } | 92 } |
| 91 } else { | 93 } else { |
| 92 task_tracker = GetOrCreateTaskTrackerForUrl(url); | 94 task_tracker = GetOrCreateTaskTrackerForUrl(url); |
| 93 } | 95 } |
| 94 | 96 |
| 95 if (!article_cb.is_null()) { | 97 if (!article_cb.is_null()) { |
| 96 task_tracker->AddSaveCallback( | 98 task_tracker->AddSaveCallback( |
| 97 base::Bind(&RunArticleAvailableCallback, article_cb)); | 99 base::Bind(&RunArticleAvailableCallback, article_cb)); |
| 98 } | 100 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 void DomDistillerService::RemoveObserver(DomDistillerObserver* observer) { | 254 void DomDistillerService::RemoveObserver(DomDistillerObserver* observer) { |
| 253 DCHECK(observer); | 255 DCHECK(observer); |
| 254 store_->RemoveObserver(observer); | 256 store_->RemoveObserver(observer); |
| 255 } | 257 } |
| 256 | 258 |
| 257 DistilledPagePrefs* DomDistillerService::GetDistilledPagePrefs() { | 259 DistilledPagePrefs* DomDistillerService::GetDistilledPagePrefs() { |
| 258 return distilled_page_prefs_.get(); | 260 return distilled_page_prefs_.get(); |
| 259 } | 261 } |
| 260 | 262 |
| 261 } // namespace dom_distiller | 263 } // namespace dom_distiller |
| OLD | NEW |