background_fetch_download.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2021 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. #ifndef WEBLAYER_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DOWNLOAD_H_
  5. #define WEBLAYER_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DOWNLOAD_H_
  6. #include <string>
  7. #include "base/memory/raw_ptr.h"
  8. #include "weblayer/browser/download_impl.h"
  9. namespace background_fetch {
  10. struct JobDetails;
  11. }
  12. namespace weblayer {
  13. class BackgroundFetchDelegateImpl;
  14. // The UI object for an in-progress BackgroundFetch download job.
  15. class BackgroundFetchDownload : public DownloadImpl {
  16. public:
  17. BackgroundFetchDownload(BackgroundFetchDelegateImpl* controller,
  18. const std::string& job_id,
  19. const background_fetch::JobDetails* job);
  20. BackgroundFetchDownload(const BackgroundFetchDownload& other) = delete;
  21. BackgroundFetchDownload& operator=(const BackgroundFetchDownload& other) =
  22. delete;
  23. ~BackgroundFetchDownload() override;
  24. // Download implementation:
  25. DownloadState GetState() override;
  26. int64_t GetTotalBytes() override;
  27. int64_t GetReceivedBytes() override;
  28. void Pause() override;
  29. void Resume() override;
  30. void Cancel() override;
  31. base::FilePath GetLocation() override;
  32. std::u16string GetFileNameToReportToUser() override;
  33. std::string GetMimeType() override;
  34. DownloadError GetError() override;
  35. // DownloadImpl:
  36. int GetNotificationId() override;
  37. bool IsTransient() override;
  38. GURL GetSourceUrl() override;
  39. const SkBitmap* GetLargeIcon() override;
  40. void OnFinished(bool activated) override;
  41. private:
  42. raw_ptr<BackgroundFetchDelegateImpl> controller_;
  43. std::string job_id_;
  44. int notification_id_ = 0;
  45. raw_ptr<const background_fetch::JobDetails> job_;
  46. };
  47. } // namespace weblayer
  48. #endif // WEBLAYER_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DOWNLOAD_H_