| 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/task_tracker.h" | 5 #include "components/dom_distiller/core/task_tracker.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "components/dom_distiller/core/distilled_content_store.h" | 9 #include "components/dom_distiller/core/distilled_content_store.h" |
| 10 #include "components/dom_distiller/core/proto/distilled_article.pb.h" | 10 #include "components/dom_distiller/core/proto/distilled_article.pb.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 distilled_article_(), | 31 distilled_article_(), |
| 32 content_ready_(false), | 32 content_ready_(false), |
| 33 destruction_allowed_(true), | 33 destruction_allowed_(true), |
| 34 weak_ptr_factory_(this) {} | 34 weak_ptr_factory_(this) {} |
| 35 | 35 |
| 36 TaskTracker::~TaskTracker() { | 36 TaskTracker::~TaskTracker() { |
| 37 DCHECK(destruction_allowed_); | 37 DCHECK(destruction_allowed_); |
| 38 DCHECK(viewers_.empty()); | 38 DCHECK(viewers_.empty()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void TaskTracker::StartDistiller(DistillerFactory* factory) { | 41 void TaskTracker::StartDistiller(DistillerFactory* factory, |
| 42 scoped_ptr<DistillerPage> distiller_page) { |
| 42 if (distiller_) { | 43 if (distiller_) { |
| 43 return; | 44 return; |
| 44 } | 45 } |
| 45 if (entry_.pages_size() == 0) { | 46 if (entry_.pages_size() == 0) { |
| 46 return; | 47 return; |
| 47 } | 48 } |
| 48 GURL url(entry_.pages(0).url()); | 49 GURL url(entry_.pages(0).url()); |
| 49 DCHECK(url.is_valid()); | 50 DCHECK(url.is_valid()); |
| 50 | 51 |
| 51 distiller_ = factory->CreateDistiller(); | 52 distiller_ = factory->CreateDistiller(); |
| 52 distiller_->DistillPage(url, | 53 distiller_->DistillPage(url, |
| 54 distiller_page.Pass(), |
| 53 base::Bind(&TaskTracker::OnDistillerFinished, | 55 base::Bind(&TaskTracker::OnDistillerFinished, |
| 54 weak_ptr_factory_.GetWeakPtr()), | 56 weak_ptr_factory_.GetWeakPtr()), |
| 55 base::Bind(&TaskTracker::OnArticleDistillationUpdated, | 57 base::Bind(&TaskTracker::OnArticleDistillationUpdated, |
| 56 weak_ptr_factory_.GetWeakPtr())); | 58 weak_ptr_factory_.GetWeakPtr())); |
| 57 } | 59 } |
| 58 | 60 |
| 59 void TaskTracker::StartBlobFetcher() { | 61 void TaskTracker::StartBlobFetcher() { |
| 60 if (content_store_) { | 62 if (content_store_) { |
| 61 content_store_->LoadContent(entry_, | 63 content_store_->LoadContent(entry_, |
| 62 base::Bind(&TaskTracker::OnBlobFetched, | 64 base::Bind(&TaskTracker::OnBlobFetched, |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 void TaskTracker::AddDistilledContentToStore( | 238 void TaskTracker::AddDistilledContentToStore( |
| 237 const DistilledArticleProto& content) { | 239 const DistilledArticleProto& content) { |
| 238 if (content_store_) { | 240 if (content_store_) { |
| 239 content_store_->SaveContent( | 241 content_store_->SaveContent( |
| 240 entry_, content, DistilledContentStore::SaveCallback()); | 242 entry_, content, DistilledContentStore::SaveCallback()); |
| 241 } | 243 } |
| 242 } | 244 } |
| 243 | 245 |
| 244 | 246 |
| 245 } // namespace dom_distiller | 247 } // namespace dom_distiller |
| OLD | NEW |