Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 CONTENT_BROWSER_BACKGROUND_FETCH_REQUEST_INFO_H_ | 5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_REQUEST_INFO_H_ |
| 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_REQUEST_INFO_H_ | 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_REQUEST_INFO_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "content/common/service_worker/service_worker_types.h" | |
| 13 #include "content/public/browser/download_interrupt_reasons.h" | 14 #include "content/public/browser/download_interrupt_reasons.h" |
| 14 #include "content/public/browser/download_item.h" | 15 #include "content/public/browser/download_item.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 // Simple class to encapsulate the components of a fetch request. | 20 // Simple class to encapsulate the components of a fetch request. |
| 20 class CONTENT_EXPORT BackgroundFetchRequestInfo { | 21 class CONTENT_EXPORT BackgroundFetchRequestInfo { |
| 21 public: | 22 public: |
| 22 BackgroundFetchRequestInfo(); | 23 BackgroundFetchRequestInfo(); |
| 23 BackgroundFetchRequestInfo(const GURL& url, const std::string& tag); | 24 BackgroundFetchRequestInfo(const ServiceWorkerFetchRequest& fetch_request); |
| 24 // TODO(harkness): Remove copy constructor once the final (non-map-based) | 25 // TODO(harkness): Remove copy constructor once the final (non-map-based) |
| 25 // state management is in place. | 26 // state management is in place. |
| 26 BackgroundFetchRequestInfo(const BackgroundFetchRequestInfo& request); | 27 BackgroundFetchRequestInfo(const BackgroundFetchRequestInfo& request); |
| 27 ~BackgroundFetchRequestInfo(); | 28 ~BackgroundFetchRequestInfo(); |
| 28 | 29 |
| 29 const std::string& guid() const { return guid_; } | 30 const std::string& guid() const { return guid_; } |
| 30 const GURL& url() const { return url_; } | 31 |
| 31 const std::string& tag() const { return tag_; } | 32 const GURL& GetUrl() const; |
|
Peter Beverloo
2017/03/27 13:40:15
GetURL for consistency with url::Origin (which our
harkness
2017/03/27 16:44:00
Done.
| |
| 32 | 33 |
| 33 DownloadItem::DownloadState state() const { return state_; } | 34 DownloadItem::DownloadState state() const { return state_; } |
| 34 void set_state(DownloadItem::DownloadState state) { state_ = state; } | 35 void set_state(DownloadItem::DownloadState state) { state_ = state; } |
| 35 | 36 |
| 36 const std::string& download_guid() const { return download_guid_; } | 37 const std::string& download_guid() const { return download_guid_; } |
| 37 void set_download_guid(const std::string& download_guid) { | 38 void set_download_guid(const std::string& download_guid) { |
| 38 download_guid_ = download_guid; | 39 download_guid_ = download_guid; |
| 39 } | 40 } |
| 40 | 41 |
| 41 DownloadInterruptReason interrupt_reason() const { return interrupt_reason_; } | 42 DownloadInterruptReason interrupt_reason() const { return interrupt_reason_; } |
| 42 void set_interrupt_reason(DownloadInterruptReason reason) { | 43 void set_interrupt_reason(DownloadInterruptReason reason) { |
| 43 interrupt_reason_ = reason; | 44 interrupt_reason_ = reason; |
| 44 } | 45 } |
| 45 | 46 |
| 46 const base::FilePath& file_path() const { return file_path_; } | 47 const base::FilePath& file_path() const { return file_path_; } |
| 47 void set_file_path(const base::FilePath& file_path) { | 48 void set_file_path(const base::FilePath& file_path) { |
| 48 file_path_ = file_path; | 49 file_path_ = file_path; |
| 49 } | 50 } |
| 50 | 51 |
| 51 int64_t received_bytes() const { return received_bytes_; } | 52 int64_t received_bytes() const { return received_bytes_; } |
| 52 void set_received_bytes(int64_t received_bytes) { | 53 void set_received_bytes(int64_t received_bytes) { |
| 53 received_bytes_ = received_bytes; | 54 received_bytes_ = received_bytes; |
| 54 } | 55 } |
| 55 | 56 |
| 56 bool IsComplete() const; | 57 bool IsComplete() const; |
| 57 | 58 |
| 58 private: | 59 private: |
| 60 ServiceWorkerFetchRequest fetch_request_; | |
| 61 | |
| 59 std::string guid_; | 62 std::string guid_; |
|
Peter Beverloo
2017/03/27 13:40:15
do we still need this?
harkness
2017/03/27 16:44:00
This should be replaced by request_index, but I th
| |
| 60 GURL url_; | |
| 61 std::string tag_; | |
| 62 std::string download_guid_; | 63 std::string download_guid_; |
| 63 | 64 |
| 64 // The following members do not need to be persisted, they can be reset after | 65 // The following members do not need to be persisted, they can be reset after |
| 65 // a chrome restart. | 66 // a chrome restart. |
| 66 DownloadItem::DownloadState state_ = | 67 DownloadItem::DownloadState state_ = |
| 67 DownloadItem::DownloadState::MAX_DOWNLOAD_STATE; | 68 DownloadItem::DownloadState::MAX_DOWNLOAD_STATE; |
| 68 DownloadInterruptReason interrupt_reason_ = | 69 DownloadInterruptReason interrupt_reason_ = |
| 69 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE; | 70 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE; |
| 70 base::FilePath file_path_; | 71 base::FilePath file_path_; |
| 71 int64_t received_bytes_ = 0; | 72 int64_t received_bytes_ = 0; |
| 72 }; | 73 }; |
| 73 | 74 |
| 74 } // namespace content | 75 } // namespace content |
| 75 | 76 |
| 76 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_REQUEST_INFO_H_ | 77 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_REQUEST_INFO_H_ |
| OLD | NEW |