1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_FEED_CONTENT_FEED_HOST_SERVICE_H_ 6 #define COMPONENTS_FEED_CONTENT_FEED_HOST_SERVICE_H_ 7 8 #include <memory> 9 10 #include "base/macros.h" 11 #include "components/feed/content/feed_offline_host.h" 12 #include "components/feed/core/feed_content_database.h" 13 #include "components/feed/core/feed_journal_database.h" 14 #include "components/feed/core/feed_logging_metrics.h" 15 #include "components/feed/core/feed_networking_host.h" 16 #include "components/feed/core/feed_scheduler_host.h" 17 #include "components/keyed_service/core/keyed_service.h" 18 19 namespace feed { 20 21 // KeyedService responsible for managing the lifetime of Feed Host API 22 // implementations. It instantiates and owns these API implementations, and 23 // provides access to non-owning pointers to them. While host implementations 24 // may be created on demand, it is possible they will not be fully initialized 25 // yet. 26 class FeedHostService : public KeyedService { 27 public: 28 FeedHostService(std::unique_ptr<FeedLoggingMetrics> logging_metrics, 29 std::unique_ptr<FeedNetworkingHost> networking_host, 30 std::unique_ptr<FeedSchedulerHost> scheduler_host, 31 std::unique_ptr<FeedContentDatabase> content_database, 32 std::unique_ptr<FeedJournalDatabase> journal_database, 33 std::unique_ptr<FeedOfflineHost> offline_host); 34 ~FeedHostService() override; 35 36 FeedLoggingMetrics* GetLoggingMetrics(); 37 FeedNetworkingHost* GetNetworkingHost(); 38 FeedSchedulerHost* GetSchedulerHost(); 39 FeedContentDatabase* GetContentDatabase(); 40 FeedJournalDatabase* GetJournalDatabase(); 41 FeedOfflineHost* GetOfflineHost(); 42 43 private: 44 std::unique_ptr<FeedLoggingMetrics> logging_metrics_; 45 std::unique_ptr<FeedNetworkingHost> networking_host_; 46 std::unique_ptr<FeedSchedulerHost> scheduler_host_; 47 std::unique_ptr<FeedContentDatabase> content_database_; 48 std::unique_ptr<FeedJournalDatabase> journal_database_; 49 50 // Depends on the |scheduler_host_|, so must come after in this file to be 51 // destroyed before the scheduler. 52 std::unique_ptr<FeedOfflineHost> offline_host_; 53 54 DISALLOW_COPY_AND_ASSIGN(FeedHostService); 55 }; 56 57 } // namespace feed 58 59 #endif // COMPONENTS_FEED_CONTENT_FEED_HOST_SERVICE_H_ 60