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

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: Added TODO for NWake 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; 17 class PrefetchStoreCommandFactory;
18 class SuggestedArticlesObserver; 18 class SuggestedArticlesObserver;
19 19
20 // The taco class acts as a wrapper around the prefetch service making 20 // 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. 21 // 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. 22 // 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 23 // The default dependencies may be replaced by the test author to provide
24 // custom versions that have test-specific hooks. 24 // custom versions that have test-specific hooks.
25 // 25 //
26 // Default types of objects held by the test service: 26 // Default types of objects held by the test service:
27 // * TestOfflineMetricsCollector 27 // * TestOfflineMetricsCollector
28 // * PrefetchDispatcherImpl 28 // * PrefetchDispatcherImpl
29 // * TestPrefetchGCMHandler 29 // * TestPrefetchGCMHandler
30 // * PrefetchInMemoryStore 30 // * PrefetchStoreCommandFactory (implementation TBD)
31 // * |nullptr| SuggestedArticlesObserver, since this is default just a lifetime 31 // * |nullptr| SuggestedArticlesObserver, since this is default just a lifetime
32 // arrangement. 32 // arrangement.
33 class PrefetchServiceTestTaco { 33 class PrefetchServiceTestTaco {
34 public: 34 public:
35 PrefetchServiceTestTaco(); 35 PrefetchServiceTestTaco();
36 ~PrefetchServiceTestTaco(); 36 ~PrefetchServiceTestTaco();
37 37
38 // These methods must be called before CreatePrefetchService() is invoked. 38 // These methods must be called before CreatePrefetchService() is invoked.
39 // If called after they will CHECK(). 39 // If called after they will CHECK().
40 void SetOfflineMetricsCollector( 40 void SetOfflineMetricsCollector(
41 std::unique_ptr<OfflineMetricsCollector> metrics_collector); 41 std::unique_ptr<OfflineMetricsCollector> metrics_collector);
42 void SetPrefetchDispatcher(std::unique_ptr<PrefetchDispatcher> dispatcher); 42 void SetPrefetchDispatcher(std::unique_ptr<PrefetchDispatcher> dispatcher);
43 void SetPrefetchGCMHandler(std::unique_ptr<PrefetchGCMHandler> gcm_handler); 43 void SetPrefetchGCMHandler(std::unique_ptr<PrefetchGCMHandler> gcm_handler);
44 void SetPrefetchStore(std::unique_ptr<PrefetchStore> prefetch_store); 44 void SetPrefetchStoreCommandFactory(
45 std::unique_ptr<PrefetchStoreCommandFactory> store_command_factory);
45 void SetSuggestedArticlesObserver( 46 void SetSuggestedArticlesObserver(
46 std::unique_ptr<SuggestedArticlesObserver> suggested_articles_observer); 47 std::unique_ptr<SuggestedArticlesObserver> suggested_articles_observer);
47 48
48 // Creates and caches an instance of PrefetchService, using default or 49 // Creates and caches an instance of PrefetchService, using default or
49 // overridden test dependencies. 50 // overridden test dependencies.
50 void CreatePrefetchService(); 51 void CreatePrefetchService();
51 52
52 // Once CreatePrefetchService() is called, this accessor method starts 53 // Once CreatePrefetchService() is called, this accessor method starts
53 // returning the PrefetchService. 54 // returning the PrefetchService.
54 55
55 PrefetchService* prefetch_service() { 56 PrefetchService* prefetch_service() {
56 CHECK(prefetch_service_); 57 CHECK(prefetch_service_);
57 return prefetch_service_.get(); 58 return prefetch_service_.get();
58 } 59 }
59 60
60 private: 61 private:
61 std::unique_ptr<OfflineMetricsCollector> metrics_collector_; 62 std::unique_ptr<OfflineMetricsCollector> metrics_collector_;
62 std::unique_ptr<PrefetchDispatcher> dispatcher_; 63 std::unique_ptr<PrefetchDispatcher> dispatcher_;
63 std::unique_ptr<PrefetchGCMHandler> gcm_handler_; 64 std::unique_ptr<PrefetchGCMHandler> gcm_handler_;
64 std::unique_ptr<PrefetchStore> store_; 65 std::unique_ptr<PrefetchStoreCommandFactory> store_command_factory_;
65 std::unique_ptr<SuggestedArticlesObserver> suggested_articles_observer_; 66 std::unique_ptr<SuggestedArticlesObserver> suggested_articles_observer_;
66 67
67 std::unique_ptr<PrefetchService> prefetch_service_; 68 std::unique_ptr<PrefetchService> prefetch_service_;
68 }; 69 };
69 70
70 } // namespace offline_pages 71 } // namespace offline_pages
71 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_TEST_TACO_H_ 72 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_TEST_TACO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698