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

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

Issue 260073009: [dom_distiller] Add support for incremental viewer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: is_in_page Created 6 years, 7 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 #ifndef COMPONENTS_DOM_DISTILLER_CORE_FAKE_DISTILLER_H_ 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_FAKE_DISTILLER_H_
6 #define COMPONENTS_DOM_DISTILLER_CORE_FAKE_DISTILLER_H_ 6 #define COMPONENTS_DOM_DISTILLER_CORE_FAKE_DISTILLER_H_
7 7
8 #include "components/dom_distiller/core/article_distillation_update.h" 8 #include "components/dom_distiller/core/article_distillation_update.h"
9 #include "components/dom_distiller/core/article_entry.h" 9 #include "components/dom_distiller/core/article_entry.h"
10 #include "components/dom_distiller/core/distiller.h" 10 #include "components/dom_distiller/core/distiller.h"
11 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 class GURL; 14 class GURL;
15 15
16 namespace content {
17 class MessageLoopRunner;
18 }
19
16 namespace dom_distiller { 20 namespace dom_distiller {
17 namespace test { 21 namespace test {
18 22
19 class MockDistillerFactory : public DistillerFactory { 23 class MockDistillerFactory : public DistillerFactory {
20 public: 24 public:
21 MockDistillerFactory(); 25 MockDistillerFactory();
22 virtual ~MockDistillerFactory(); 26 virtual ~MockDistillerFactory();
23 MOCK_METHOD0(CreateDistillerImpl, Distiller*()); 27 MOCK_METHOD0(CreateDistillerImpl, Distiller*());
24 virtual scoped_ptr<Distiller> CreateDistiller() OVERRIDE { 28 virtual scoped_ptr<Distiller> CreateDistiller() OVERRIDE {
25 return scoped_ptr<Distiller>(CreateDistillerImpl()); 29 return scoped_ptr<Distiller>(CreateDistillerImpl());
26 } 30 }
27 }; 31 };
28 32
29 class FakeDistiller : public Distiller { 33 class FakeDistiller : public Distiller {
30 public: 34 public:
31 // If execute_callback is true, when DistillPage is called, a task will 35 // If execute_callback is true, when DistillPage is called, a task will
32 // immediately be posted to execute the callback with a simple 36 // immediately be posted to execute the callback with a simple
33 // DistilledArticleProto. 37 // DistilledArticleProto.
34 explicit FakeDistiller(bool execute_callback); 38 explicit FakeDistiller(bool execute_callback);
39 explicit FakeDistiller(bool execute_callback,
40 content::MessageLoopRunner* runner);
35 virtual ~FakeDistiller(); 41 virtual ~FakeDistiller();
36 MOCK_METHOD0(Die, void()); 42 MOCK_METHOD0(Die, void());
37 43
38 virtual void DistillPage( 44 virtual void DistillPage(
39 const GURL& url, 45 const GURL& url,
40 scoped_ptr<DistillerPage> distiller_page, 46 scoped_ptr<DistillerPage> distiller_page,
41 const DistillationFinishedCallback& article_callback, 47 const DistillationFinishedCallback& article_callback,
42 const DistillationUpdateCallback& page_callback) OVERRIDE; 48 const DistillationUpdateCallback& page_callback) OVERRIDE;
43 49
44 void RunDistillerCallback(scoped_ptr<DistilledArticleProto> proto); 50 void RunDistillerCallback(scoped_ptr<DistilledArticleProto> proto);
nyquist 2014/05/13 05:01:15 What about renaming this to RunDistillerFinishedCa
Yaron 2014/05/14 17:42:33 Follow-on?
51 void RunDistillerUpdateCallback(const ArticleDistillationUpdate& update);
45 52
46 GURL GetUrl() { return url_; } 53 GURL GetUrl() { return url_; }
47 54
48 DistillationFinishedCallback GetArticleCallback() { 55 DistillationFinishedCallback GetArticleCallback() {
49 return article_callback_; 56 return article_callback_;
50 } 57 }
51 58
52 private: 59 private:
53 void PostDistillerCallback(scoped_ptr<DistilledArticleProto> proto); 60 void PostDistillerCallback(scoped_ptr<DistilledArticleProto> proto);
54 void RunDistillerCallbackInternal(scoped_ptr<DistilledArticleProto> proto); 61 void RunDistillerCallbackInternal(scoped_ptr<DistilledArticleProto> proto);
55 62
56 bool execute_callback_; 63 bool execute_callback_;
57 GURL url_; 64 GURL url_;
58 DistillationFinishedCallback article_callback_; 65 DistillationFinishedCallback article_callback_;
59 DistillationUpdateCallback page_callback_; 66 DistillationUpdateCallback page_callback_;
60
61 bool destruction_allowed_; 67 bool destruction_allowed_;
68 // Used to notify when distillation is complete.
69 content::MessageLoopRunner* runner_;
62 }; 70 };
63 71
64 } // namespace test 72 } // namespace test
65 } // namespace dom_distiller 73 } // namespace dom_distiller
66 74
67 #endif // COMPONENTS_DOM_DISTILLER_CORE_FAKE_DISTILLER_H_ 75 #endif // COMPONENTS_DOM_DISTILLER_CORE_FAKE_DISTILLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698