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

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

Issue 1879613003: Convert //components/dom_distiller from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 #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 "base/callback.h" 8 #include "base/callback.h"
9 #include "components/dom_distiller/core/article_distillation_update.h" 9 #include "components/dom_distiller/core/article_distillation_update.h"
10 #include "components/dom_distiller/core/article_entry.h" 10 #include "components/dom_distiller/core/article_entry.h"
11 #include "components/dom_distiller/core/distiller.h" 11 #include "components/dom_distiller/core/distiller.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 14
15 class GURL; 15 class GURL;
16 16
17 namespace dom_distiller { 17 namespace dom_distiller {
18 namespace test { 18 namespace test {
19 19
20 class MockDistillerFactory : public DistillerFactory { 20 class MockDistillerFactory : public DistillerFactory {
21 public: 21 public:
22 MockDistillerFactory(); 22 MockDistillerFactory();
23 virtual ~MockDistillerFactory(); 23 virtual ~MockDistillerFactory();
24 MOCK_METHOD0(CreateDistillerImpl, Distiller*()); 24 MOCK_METHOD0(CreateDistillerImpl, Distiller*());
25 scoped_ptr<Distiller> CreateDistillerForUrl(const GURL& unused) override { 25 std::unique_ptr<Distiller> CreateDistillerForUrl(
26 return scoped_ptr<Distiller>(CreateDistillerImpl()); 26 const GURL& unused) override {
27 return std::unique_ptr<Distiller>(CreateDistillerImpl());
27 } 28 }
28 }; 29 };
29 30
30 class FakeDistiller : public Distiller { 31 class FakeDistiller : public Distiller {
31 public: 32 public:
32 // If execute_callback is true, when DistillPage is called, a task will 33 // If execute_callback is true, when DistillPage is called, a task will
33 // immediately be posted to execute the callback with a simple 34 // immediately be posted to execute the callback with a simple
34 // DistilledArticleProto. 35 // DistilledArticleProto.
35 explicit FakeDistiller(bool execute_callback); 36 explicit FakeDistiller(bool execute_callback);
36 // TODO(yfriedman): Drop execute_callback from this and give the option of 37 // TODO(yfriedman): Drop execute_callback from this and give the option of
37 // "auto-distilling" or calling the provided closure. 38 // "auto-distilling" or calling the provided closure.
38 explicit FakeDistiller(bool execute_callback, 39 explicit FakeDistiller(bool execute_callback,
39 const base::Closure& distillation_initiated_callback); 40 const base::Closure& distillation_initiated_callback);
40 ~FakeDistiller() override; 41 ~FakeDistiller() override;
41 MOCK_METHOD0(Die, void()); 42 MOCK_METHOD0(Die, void());
42 43
43 void DistillPage(const GURL& url, 44 void DistillPage(const GURL& url,
44 scoped_ptr<DistillerPage> distiller_page, 45 std::unique_ptr<DistillerPage> distiller_page,
45 const DistillationFinishedCallback& article_callback, 46 const DistillationFinishedCallback& article_callback,
46 const DistillationUpdateCallback& page_callback) override; 47 const DistillationUpdateCallback& page_callback) override;
47 48
48 void RunDistillerCallback(scoped_ptr<DistilledArticleProto> proto); 49 void RunDistillerCallback(std::unique_ptr<DistilledArticleProto> proto);
49 void RunDistillerUpdateCallback(const ArticleDistillationUpdate& update); 50 void RunDistillerUpdateCallback(const ArticleDistillationUpdate& update);
50 51
51 GURL GetUrl() { return url_; } 52 GURL GetUrl() { return url_; }
52 53
53 DistillationFinishedCallback GetArticleCallback() { 54 DistillationFinishedCallback GetArticleCallback() {
54 return article_callback_; 55 return article_callback_;
55 } 56 }
56 57
57 private: 58 private:
58 void PostDistillerCallback(scoped_ptr<DistilledArticleProto> proto); 59 void PostDistillerCallback(std::unique_ptr<DistilledArticleProto> proto);
59 void RunDistillerCallbackInternal(scoped_ptr<DistilledArticleProto> proto); 60 void RunDistillerCallbackInternal(
61 std::unique_ptr<DistilledArticleProto> proto);
60 62
61 bool execute_callback_; 63 bool execute_callback_;
62 GURL url_; 64 GURL url_;
63 DistillationFinishedCallback article_callback_; 65 DistillationFinishedCallback article_callback_;
64 DistillationUpdateCallback page_callback_; 66 DistillationUpdateCallback page_callback_;
65 bool destruction_allowed_; 67 bool destruction_allowed_;
66 // Used to notify when distillation is complete. 68 // Used to notify when distillation is complete.
67 base::Closure distillation_initiated_callback_; 69 base::Closure distillation_initiated_callback_;
68 }; 70 };
69 71
70 } // namespace test 72 } // namespace test
71 } // namespace dom_distiller 73 } // namespace dom_distiller
72 74
73 #endif // COMPONENTS_DOM_DISTILLER_CORE_FAKE_DISTILLER_H_ 75 #endif // COMPONENTS_DOM_DISTILLER_CORE_FAKE_DISTILLER_H_
OLDNEW
« no previous file with comments | « components/dom_distiller/core/dom_distiller_test_util.cc ('k') | components/dom_distiller/core/fake_distiller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698