OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_OFFLINE_PAGES_DOWNLOADS_DOWNLOAD_NOTIFYING_OBSERVER_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_DOWNLOADS_DOWNLOAD_NOTIFYING_OBSERVER_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "components/offline_pages/background/request_coordinator.h" |
| 12 |
| 13 namespace offline_pages { |
| 14 |
| 15 struct OfflinePageDownloadNotifier; |
| 16 class SavePageRequest; |
| 17 |
| 18 // Class observing the save page requests and issuing corresponding user |
| 19 // notifications as requests are added or updated. |
| 20 class DownloadNotifyingObserver : public RequestCoordinator::Observer, |
| 21 public base::SupportsUserData::Data { |
| 22 public: |
| 23 ~DownloadNotifyingObserver() override; |
| 24 |
| 25 static DownloadNotifyingObserver* GetFromRequestCoordinator( |
| 26 RequestCoordinator* request_coordinator); |
| 27 static void CreateAndStartObserving( |
| 28 RequestCoordinator* request_coordinator, |
| 29 std::unique_ptr<OfflinePageDownloadNotifier> notifier); |
| 30 |
| 31 // RequestCoordinator::Observer implementation: |
| 32 void OnAdded(const SavePageRequest& request) override; |
| 33 void OnChanged(const SavePageRequest& request) override; |
| 34 void OnCompleted(const SavePageRequest& request, |
| 35 RequestCoordinator::SavePageStatus status) override; |
| 36 |
| 37 private: |
| 38 friend class DownloadNotifyingObserverTest; |
| 39 |
| 40 explicit DownloadNotifyingObserver( |
| 41 std::unique_ptr<OfflinePageDownloadNotifier> notifier); |
| 42 |
| 43 // Used to issue notifications related to save page requests. |
| 44 std::unique_ptr<OfflinePageDownloadNotifier> notifier_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(DownloadNotifyingObserver); |
| 47 }; |
| 48 |
| 49 } // namespace offline_pages |
| 50 |
| 51 #endif // COMPONENTS_OFFLINE_PAGES_DOWNLOADS_DOWNLOAD_NOTIFYING_OBSERVER_H_ |
OLD | NEW |