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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 #include "content/public/browser/download_interrupt_reasons.h" |
| 12 #include "content/public/browser/download_item.h" |
11 #include "url/gurl.h" | 13 #include "url/gurl.h" |
12 | 14 |
13 namespace content { | 15 namespace content { |
14 | 16 |
15 // Simple class to encapsulate the components of a fetch request. | 17 // Simple class to encapsulate the components of a fetch request. |
16 class CONTENT_EXPORT BackgroundFetchRequestInfo { | 18 class CONTENT_EXPORT BackgroundFetchRequestInfo { |
17 public: | 19 public: |
18 BackgroundFetchRequestInfo(); | 20 BackgroundFetchRequestInfo(); |
19 BackgroundFetchRequestInfo(const GURL& url, const std::string& tag); | 21 BackgroundFetchRequestInfo(const GURL& url, const std::string& tag); |
20 // TODO(harkness): Remove copy constructor once the final (non-map-based) | 22 // TODO(harkness): Remove copy constructor once the final (non-map-based) |
21 // state management is in place. | 23 // state management is in place. |
22 BackgroundFetchRequestInfo(const BackgroundFetchRequestInfo& request); | 24 BackgroundFetchRequestInfo(const BackgroundFetchRequestInfo& request); |
23 ~BackgroundFetchRequestInfo(); | 25 ~BackgroundFetchRequestInfo(); |
24 | 26 |
25 const std::string& guid() const { return guid_; } | 27 const std::string& guid() const { return guid_; } |
26 const GURL& url() const { return url_; } | 28 const GURL& url() const { return url_; } |
27 const std::string& tag() const { return tag_; } | 29 const std::string& tag() const { return tag_; } |
28 | 30 |
29 bool complete() const { return complete_; } | 31 DownloadItem::DownloadState state() const { return state_; } |
30 void set_complete(bool complete) { complete_ = complete; } | 32 void set_state(DownloadItem::DownloadState state) { state_ = state; } |
31 | 33 |
32 const std::string& download_guid() const { return download_guid_; } | 34 const std::string& download_guid() const { return download_guid_; } |
33 void set_download_guid(const std::string& download_guid) { | 35 void set_download_guid(const std::string& download_guid) { |
34 download_guid_ = download_guid; | 36 download_guid_ = download_guid; |
35 } | 37 } |
36 | 38 |
| 39 DownloadInterruptReason interrupt_reason() const { return interrupt_reason_; } |
| 40 void set_interrupt_reason(DownloadInterruptReason reason) { |
| 41 interrupt_reason_ = reason; |
| 42 } |
| 43 |
37 private: | 44 private: |
38 std::string guid_; | 45 std::string guid_; |
39 GURL url_; | 46 GURL url_; |
40 std::string tag_; | 47 std::string tag_; |
41 bool complete_ = false; | |
42 std::string download_guid_; | 48 std::string download_guid_; |
| 49 DownloadItem::DownloadState state_ = |
| 50 DownloadItem::DownloadState::MAX_DOWNLOAD_STATE; |
| 51 DownloadInterruptReason interrupt_reason_ = |
| 52 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE; |
43 }; | 53 }; |
44 | 54 |
45 using BackgroundFetchRequestInfos = std::vector<BackgroundFetchRequestInfo>; | 55 using BackgroundFetchRequestInfos = std::vector<BackgroundFetchRequestInfo>; |
46 | 56 |
47 } // namespace content | 57 } // namespace content |
48 | 58 |
49 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_REQUEST_INFO_H_ | 59 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_REQUEST_INFO_H_ |
OLD | NEW |