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

Side by Side Diff: components/offline_pages/core/prefetch/prefetch_service_test_taco.h

Issue 2920083002: Prefetching: Introduce store commands abstractions to be used by tasks. (Closed)
Patch Set: Minor changes Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_TEST_TACO_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_TEST_TACO_H_
6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_TEST_TACO_H_ 6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_TEST_TACO_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 11
12 namespace offline_pages { 12 namespace offline_pages {
13 class OfflineMetricsCollector; 13 class OfflineMetricsCollector;
14 class PrefetchDispatcher; 14 class PrefetchDispatcher;
15 class PrefetchGCMHandler; 15 class PrefetchGCMHandler;
16 class PrefetchService; 16 class PrefetchService;
17 class PrefetchStore;
18 class SuggestedArticlesObserver; 17 class SuggestedArticlesObserver;
19 18
20 // The taco class acts as a wrapper around the prefetch service making 19 // The taco class acts as a wrapper around the prefetch service making
21 // it easy to create for tests, using test versions of the dependencies. 20 // it easy to create for tests, using test versions of the dependencies.
22 // This class is like a taco shell, and the filling is the prefetch service. 21 // This class is like a taco shell, and the filling is the prefetch service.
23 // The default dependencies may be replaced by the test author to provide 22 // The default dependencies may be replaced by the test author to provide
24 // custom versions that have test-specific hooks. 23 // custom versions that have test-specific hooks.
25 // 24 //
26 // Default types of objects held by the test service: 25 // Default types of objects held by the test service:
27 // * TestOfflineMetricsCollector 26 // * TestOfflineMetricsCollector
28 // * PrefetchDispatcherImpl 27 // * PrefetchDispatcherImpl
29 // * TestPrefetchGCMHandler 28 // * TestPrefetchGCMHandler
30 // * PrefetchInMemoryStore
31 // * |nullptr| SuggestedArticlesObserver, since this is default just a lifetime 29 // * |nullptr| SuggestedArticlesObserver, since this is default just a lifetime
32 // arrangement. 30 // arrangement.
33 class PrefetchServiceTestTaco { 31 class PrefetchServiceTestTaco {
34 public: 32 public:
35 PrefetchServiceTestTaco(); 33 PrefetchServiceTestTaco();
36 ~PrefetchServiceTestTaco(); 34 ~PrefetchServiceTestTaco();
37 35
38 // These methods must be called before CreatePrefetchService() is invoked. 36 // These methods must be called before CreatePrefetchService() is invoked.
39 // If called after they will CHECK(). 37 // If called after they will CHECK().
40 void SetOfflineMetricsCollector( 38 void SetOfflineMetricsCollector(
41 std::unique_ptr<OfflineMetricsCollector> metrics_collector); 39 std::unique_ptr<OfflineMetricsCollector> metrics_collector);
42 void SetPrefetchDispatcher(std::unique_ptr<PrefetchDispatcher> dispatcher); 40 void SetPrefetchDispatcher(std::unique_ptr<PrefetchDispatcher> dispatcher);
43 void SetPrefetchGCMHandler(std::unique_ptr<PrefetchGCMHandler> gcm_handler); 41 void SetPrefetchGCMHandler(std::unique_ptr<PrefetchGCMHandler> gcm_handler);
44 void SetPrefetchStore(std::unique_ptr<PrefetchStore> prefetch_store);
45 void SetSuggestedArticlesObserver( 42 void SetSuggestedArticlesObserver(
46 std::unique_ptr<SuggestedArticlesObserver> suggested_articles_observer); 43 std::unique_ptr<SuggestedArticlesObserver> suggested_articles_observer);
47 44
48 // Creates and caches an instance of PrefetchService, using default or 45 // Creates and caches an instance of PrefetchService, using default or
49 // overridden test dependencies. 46 // overridden test dependencies.
50 void CreatePrefetchService(); 47 void CreatePrefetchService();
51 48
52 // Once CreatePrefetchService() is called, this accessor method starts 49 // Once CreatePrefetchService() is called, this accessor method starts
53 // returning the PrefetchService. 50 // returning the PrefetchService.
54 51
55 PrefetchService* prefetch_service() { 52 PrefetchService* prefetch_service() {
56 CHECK(prefetch_service_); 53 CHECK(prefetch_service_);
57 return prefetch_service_.get(); 54 return prefetch_service_.get();
58 } 55 }
59 56
60 private: 57 private:
61 std::unique_ptr<OfflineMetricsCollector> metrics_collector_; 58 std::unique_ptr<OfflineMetricsCollector> metrics_collector_;
62 std::unique_ptr<PrefetchDispatcher> dispatcher_; 59 std::unique_ptr<PrefetchDispatcher> dispatcher_;
63 std::unique_ptr<PrefetchGCMHandler> gcm_handler_; 60 std::unique_ptr<PrefetchGCMHandler> gcm_handler_;
64 std::unique_ptr<PrefetchStore> store_;
65 std::unique_ptr<SuggestedArticlesObserver> suggested_articles_observer_; 61 std::unique_ptr<SuggestedArticlesObserver> suggested_articles_observer_;
66 62
67 std::unique_ptr<PrefetchService> prefetch_service_; 63 std::unique_ptr<PrefetchService> prefetch_service_;
68 }; 64 };
69 65
70 } // namespace offline_pages 66 } // namespace offline_pages
71 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_TEST_TACO_H_ 67 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_TEST_TACO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698