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

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

Issue 178303004: Add incremental updates for multipage distillation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile by adding a header. Created 6 years, 9 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 | Annotate | Revision Log
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/fake_distiller.h" 5 #include "components/dom_distiller/core/fake_distiller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace dom_distiller { 11 namespace dom_distiller {
12 namespace test { 12 namespace test {
13 13
14 MockDistillerFactory::MockDistillerFactory() {} 14 MockDistillerFactory::MockDistillerFactory() {}
15 MockDistillerFactory::~MockDistillerFactory() {} 15 MockDistillerFactory::~MockDistillerFactory() {}
16 16
17 FakeDistiller::FakeDistiller(bool execute_callback) 17 FakeDistiller::FakeDistiller(bool execute_callback)
18 : execute_callback_(execute_callback) { 18 : execute_callback_(execute_callback) {
19 EXPECT_CALL(*this, Die()).Times(testing::AnyNumber()); 19 EXPECT_CALL(*this, Die()).Times(testing::AnyNumber());
20 } 20 }
21 21
22 FakeDistiller::~FakeDistiller() { Die(); } 22 FakeDistiller::~FakeDistiller() { Die(); }
23 23
24 void FakeDistiller::DistillPage(const GURL& url, 24 void FakeDistiller::DistillPage(
25 const DistillerCallback& callback) { 25 const GURL& url,
26 const ArticleDistillationCallback& article_callback,
27 const PageDistillationCallback& page_callback) {
26 url_ = url; 28 url_ = url;
27 callback_ = callback; 29 article_callback_ = article_callback;
30 page_callback_ = page_callback;
28 if (execute_callback_) { 31 if (execute_callback_) {
29 scoped_ptr<DistilledArticleProto> proto(new DistilledArticleProto); 32 scoped_ptr<DistilledArticleProto> proto(new DistilledArticleProto);
30 proto->add_pages()->set_url(url_.spec()); 33 proto->add_pages()->set_url(url_.spec());
31 RunDistillerCallback(proto.Pass()); 34 RunDistillerCallback(proto.Pass());
32 } 35 }
33 } 36 }
34 37
35 void FakeDistiller::RunDistillerCallback( 38 void FakeDistiller::RunDistillerCallback(
36 scoped_ptr<DistilledArticleProto> proto) { 39 scoped_ptr<DistilledArticleProto> proto) {
37 base::MessageLoop::current()->PostTask( 40 base::MessageLoop::current()->PostTask(
38 FROM_HERE, 41 FROM_HERE,
39 base::Bind(&FakeDistiller::RunDistillerCallbackInternal, 42 base::Bind(&FakeDistiller::RunDistillerCallbackInternal,
40 base::Unretained(this), 43 base::Unretained(this),
41 base::Passed(&proto))); 44 base::Passed(&proto)));
42 } 45 }
43 46
44 void FakeDistiller::RunDistillerCallbackInternal( 47 void FakeDistiller::RunDistillerCallbackInternal(
45 scoped_ptr<DistilledArticleProto> proto) { 48 scoped_ptr<DistilledArticleProto> proto) {
46 EXPECT_FALSE(callback_.is_null()); 49 EXPECT_FALSE(article_callback_.is_null());
47 callback_.Run(proto.Pass()); 50 article_callback_.Run(proto.Pass());
48 callback_.Reset(); 51 article_callback_.Reset();
49 } 52 }
50 53
51 } // namespace test 54 } // namespace test
52 } // namespace dom_distiller 55 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698