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

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

Issue 1144153004: components: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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
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/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/proto/distilled_article.pb.h" 12 #include "components/dom_distiller/core/proto/distilled_article.pb.h"
11 #include "components/dom_distiller/core/proto/distilled_page.pb.h" 13 #include "components/dom_distiller/core/proto/distilled_page.pb.h"
12 14
13 namespace dom_distiller { 15 namespace dom_distiller {
14 16
15 ViewerHandle::ViewerHandle(CancelCallback callback) 17 ViewerHandle::ViewerHandle(CancelCallback callback)
16 : cancel_callback_(callback) {} 18 : cancel_callback_(callback) {}
17 19
18 ViewerHandle::~ViewerHandle() { 20 ViewerHandle::~ViewerHandle() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // immediately saved. 77 // immediately saved.
76 ScheduleSaveCallbacks(true); 78 ScheduleSaveCallbacks(true);
77 } 79 }
78 } 80 }
79 81
80 scoped_ptr<ViewerHandle> TaskTracker::AddViewer(ViewRequestDelegate* delegate) { 82 scoped_ptr<ViewerHandle> TaskTracker::AddViewer(ViewRequestDelegate* delegate) {
81 viewers_.push_back(delegate); 83 viewers_.push_back(delegate);
82 if (content_ready_) { 84 if (content_ready_) {
83 // Distillation for this task has already completed, and so the delegate can 85 // Distillation for this task has already completed, and so the delegate can
84 // be immediately told of the result. 86 // be immediately told of the result.
85 base::MessageLoop::current()->PostTask( 87 base::ThreadTaskRunnerHandle::Get()->PostTask(
86 FROM_HERE, 88 FROM_HERE, base::Bind(&TaskTracker::NotifyViewer,
87 base::Bind(&TaskTracker::NotifyViewer, 89 weak_ptr_factory_.GetWeakPtr(), delegate));
88 weak_ptr_factory_.GetWeakPtr(),
89 delegate));
90 } 90 }
91 return scoped_ptr<ViewerHandle>(new ViewerHandle(base::Bind( 91 return scoped_ptr<ViewerHandle>(new ViewerHandle(base::Bind(
92 &TaskTracker::RemoveViewer, weak_ptr_factory_.GetWeakPtr(), delegate))); 92 &TaskTracker::RemoveViewer, weak_ptr_factory_.GetWeakPtr(), delegate)));
93 } 93 }
94 94
95 const std::string& TaskTracker::GetEntryId() const { return entry_.entry_id(); } 95 const std::string& TaskTracker::GetEntryId() const { return entry_.entry_id(); }
96 96
97 bool TaskTracker::HasEntryId(const std::string& entry_id) const { 97 bool TaskTracker::HasEntryId(const std::string& entry_id) const {
98 return entry_.entry_id() == entry_id; 98 return entry_.entry_id() == entry_id;
99 } 99 }
(...skipping 23 matching lines...) Expand all
123 CancelPendingSources(); 123 CancelPendingSources();
124 124
125 base::AutoReset<bool> dont_delete_this_in_callback(&destruction_allowed_, 125 base::AutoReset<bool> dont_delete_this_in_callback(&destruction_allowed_,
126 false); 126 false);
127 cancel_callback_.Run(this); 127 cancel_callback_.Run(this);
128 } 128 }
129 129
130 void TaskTracker::CancelSaveCallbacks() { ScheduleSaveCallbacks(false); } 130 void TaskTracker::CancelSaveCallbacks() { ScheduleSaveCallbacks(false); }
131 131
132 void TaskTracker::ScheduleSaveCallbacks(bool distillation_succeeded) { 132 void TaskTracker::ScheduleSaveCallbacks(bool distillation_succeeded) {
133 base::MessageLoop::current()->PostTask( 133 base::ThreadTaskRunnerHandle::Get()->PostTask(
134 FROM_HERE, 134 FROM_HERE,
135 base::Bind(&TaskTracker::DoSaveCallbacks, 135 base::Bind(&TaskTracker::DoSaveCallbacks, weak_ptr_factory_.GetWeakPtr(),
136 weak_ptr_factory_.GetWeakPtr(),
137 distillation_succeeded)); 136 distillation_succeeded));
138 } 137 }
139 138
140 void TaskTracker::OnDistillerFinished( 139 void TaskTracker::OnDistillerFinished(
141 scoped_ptr<DistilledArticleProto> distilled_article) { 140 scoped_ptr<DistilledArticleProto> distilled_article) {
142 if (content_ready_) { 141 if (content_ready_) {
143 return; 142 return;
144 } 143 }
145 144
146 DistilledArticleReady(distilled_article.Pass()); 145 DistilledArticleReady(distilled_article.Pass());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 void TaskTracker::AddDistilledContentToStore( 244 void TaskTracker::AddDistilledContentToStore(
246 const DistilledArticleProto& content) { 245 const DistilledArticleProto& content) {
247 if (content_store_) { 246 if (content_store_) {
248 content_store_->SaveContent( 247 content_store_->SaveContent(
249 entry_, content, DistilledContentStore::SaveCallback()); 248 entry_, content, DistilledContentStore::SaveCallback());
250 } 249 }
251 } 250 }
252 251
253 252
254 } // namespace dom_distiller 253 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/core/fake_distiller.cc ('k') | components/dom_distiller/standalone/content_extractor_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698