Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: components/dom_distiller/core/task_tracker.cc

Issue 575883002: Fix handling of failed distillation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/dom_distiller/core/task_tracker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 distiller_->DistillPage(url, 53 distiller_->DistillPage(url,
54 distiller_page.Pass(), 54 distiller_page.Pass(),
55 base::Bind(&TaskTracker::OnDistillerFinished, 55 base::Bind(&TaskTracker::OnDistillerFinished,
56 weak_ptr_factory_.GetWeakPtr()), 56 weak_ptr_factory_.GetWeakPtr()),
57 base::Bind(&TaskTracker::OnArticleDistillationUpdated, 57 base::Bind(&TaskTracker::OnArticleDistillationUpdated,
58 weak_ptr_factory_.GetWeakPtr())); 58 weak_ptr_factory_.GetWeakPtr()));
59 } 59 }
60 60
61 void TaskTracker::StartBlobFetcher() { 61 void TaskTracker::StartBlobFetcher() {
62 if (content_store_) { 62 if (content_store_) {
63 blob_fetcher_running_ = true;
63 content_store_->LoadContent(entry_, 64 content_store_->LoadContent(entry_,
64 base::Bind(&TaskTracker::OnBlobFetched, 65 base::Bind(&TaskTracker::OnBlobFetched,
65 weak_ptr_factory_.GetWeakPtr())); 66 weak_ptr_factory_.GetWeakPtr()));
66 } 67 }
67 } 68 }
68 69
69 void TaskTracker::AddSaveCallback(const SaveCallback& callback) { 70 void TaskTracker::AddSaveCallback(const SaveCallback& callback) {
70 DCHECK(!callback.is_null()); 71 DCHECK(!callback.is_null());
71 save_callbacks_.push_back(callback); 72 save_callbacks_.push_back(callback);
72 if (content_ready_) { 73 if (content_ready_) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 scoped_ptr<DistilledArticleProto> distilled_article) { 141 scoped_ptr<DistilledArticleProto> distilled_article) {
141 if (content_ready_) { 142 if (content_ready_) {
142 return; 143 return;
143 } 144 }
144 145
145 DistilledArticleReady(distilled_article.Pass()); 146 DistilledArticleReady(distilled_article.Pass());
146 if (content_ready_) { 147 if (content_ready_) {
147 AddDistilledContentToStore(*distilled_article_); 148 AddDistilledContentToStore(*distilled_article_);
148 } 149 }
149 150
151 // 'distiller_ != null' is used as a signal that distillation is in progress,
152 // so it needs to be released so that we know distillation is done.
153 base::MessageLoop::current()->DeleteSoon(FROM_HERE, distiller_.release());
154
150 ContentSourceFinished(); 155 ContentSourceFinished();
151 } 156 }
152 157
153 void TaskTracker::CancelPendingSources() { 158 void TaskTracker::CancelPendingSources() {
154 base::MessageLoop::current()->DeleteSoon(FROM_HERE, distiller_.release()); 159 if (distiller_) {
160 base::MessageLoop::current()->DeleteSoon(FROM_HERE, distiller_.release());
161 }
155 } 162 }
156 163
157 void TaskTracker::OnBlobFetched( 164 void TaskTracker::OnBlobFetched(
158 bool success, 165 bool success,
159 scoped_ptr<DistilledArticleProto> distilled_article) { 166 scoped_ptr<DistilledArticleProto> distilled_article) {
160 blob_fetcher_running_ = false; 167 blob_fetcher_running_ = false;
161 168
162 if (content_ready_) { 169 if (content_ready_) {
163 return; 170 return;
164 } 171 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 void TaskTracker::AddDistilledContentToStore( 245 void TaskTracker::AddDistilledContentToStore(
239 const DistilledArticleProto& content) { 246 const DistilledArticleProto& content) {
240 if (content_store_) { 247 if (content_store_) {
241 content_store_->SaveContent( 248 content_store_->SaveContent(
242 entry_, content, DistilledContentStore::SaveCallback()); 249 entry_, content, DistilledContentStore::SaveCallback());
243 } 250 }
244 } 251 }
245 252
246 253
247 } // namespace dom_distiller 254 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « no previous file | components/dom_distiller/core/task_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698