| 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 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 void PopulateResponseFromDownloadItem(DownloadItem* download_item); | 41 void PopulateResponseFromDownloadItem(DownloadItem* download_item); |
| 42 | 42 |
| 43 // Returns the index of this request within a Background Fetch registration. | 43 // Returns the index of this request within a Background Fetch registration. |
| 44 int request_index() const { return request_index_; } | 44 int request_index() const { return request_index_; } |
| 45 | 45 |
| 46 // Returns the Fetch API Request object that details the developer's request. | 46 // Returns the Fetch API Request object that details the developer's request. |
| 47 const ServiceWorkerFetchRequest& fetch_request() const { | 47 const ServiceWorkerFetchRequest& fetch_request() const { |
| 48 return fetch_request_; | 48 return fetch_request_; |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Returns the response code for the download. Available for both successful |
| 52 // and failed requests. |
| 53 int GetResponseCode() const; |
| 54 |
| 55 // Returns the response text for the download. Available for all started |
| 56 // items. |
| 57 const std::string& GetResponseText() const; |
| 58 |
| 59 // Returns the response headers for the download. Available for both |
| 60 // successful and failed requests. |
| 61 const std::map<std::string, std::string>& GetResponseHeaders() const; |
| 62 |
| 51 // Returns the URL chain for the response, including redirects. | 63 // Returns the URL chain for the response, including redirects. |
| 52 const std::vector<GURL>& GetURLChain() const; | 64 const std::vector<GURL>& GetURLChain() const; |
| 53 | 65 |
| 54 // Returns the absolute path to the file in which the response is stored. | 66 // Returns the absolute path to the file in which the response is stored. |
| 55 const base::FilePath& GetFilePath() const; | 67 const base::FilePath& GetFilePath() const; |
| 56 | 68 |
| 57 // Returns the size of the file containing the response, in bytes. | 69 // Returns the size of the file containing the response, in bytes. |
| 58 int64_t GetFileSize() const; | 70 int64_t GetFileSize() const; |
| 59 | 71 |
| 60 // Returns the time at which the response was completed. | 72 // Returns the time at which the response was completed. |
| 61 const base::Time& GetResponseTime() const; | 73 const base::Time& GetResponseTime() const; |
| 62 | 74 |
| 63 // Returns the mime type describing the response, as indicated by the server. | |
| 64 const std::string& GetResponseType() const; | |
| 65 | |
| 66 private: | 75 private: |
| 67 friend class base::RefCountedThreadSafe<BackgroundFetchRequestInfo>; | 76 friend class base::RefCountedThreadSafe<BackgroundFetchRequestInfo>; |
| 68 | 77 |
| 69 ~BackgroundFetchRequestInfo(); | 78 ~BackgroundFetchRequestInfo(); |
| 70 | 79 |
| 71 // ---- Data associated with the request ------------------------------------- | 80 // ---- Data associated with the request ------------------------------------- |
| 72 | 81 |
| 73 int request_index_ = kInvalidBackgroundFetchRequestIndex; | 82 int request_index_ = kInvalidBackgroundFetchRequestIndex; |
| 74 ServiceWorkerFetchRequest fetch_request_; | 83 ServiceWorkerFetchRequest fetch_request_; |
| 75 | 84 |
| 76 // ---- Data associated with the in-progress download ------------------------ | 85 // ---- Data associated with the in-progress download ------------------------ |
| 77 | 86 |
| 78 // Indicates whether download progress data has been populated. | 87 // Indicates whether download progress data has been populated. |
| 79 bool download_state_populated_ = false; | 88 bool download_state_populated_ = false; |
| 80 | 89 |
| 81 std::string download_guid_; | 90 std::string download_guid_; |
| 82 DownloadItem::DownloadState download_state_ = DownloadItem::IN_PROGRESS; | 91 DownloadItem::DownloadState download_state_ = DownloadItem::IN_PROGRESS; |
| 83 | 92 |
| 93 int response_code_ = 0; |
| 94 std::string response_text_; |
| 95 std::map<std::string, std::string> response_headers_; |
| 96 |
| 84 // ---- Data associated with the response ------------------------------------ | 97 // ---- Data associated with the response ------------------------------------ |
| 85 | 98 |
| 86 // Indicates whether response data has been populated. | 99 // Indicates whether response data has been populated. |
| 87 bool response_data_populated_ = false; | 100 bool response_data_populated_ = false; |
| 88 | 101 |
| 89 std::vector<GURL> url_chain_; | 102 std::vector<GURL> url_chain_; |
| 90 base::FilePath file_path_; | 103 base::FilePath file_path_; |
| 91 int64_t file_size_ = 0; | 104 int64_t file_size_ = 0; |
| 92 base::Time response_time_; | 105 base::Time response_time_; |
| 93 std::string response_type_; | |
| 94 | 106 |
| 95 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchRequestInfo); | 107 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchRequestInfo); |
| 96 }; | 108 }; |
| 97 | 109 |
| 98 } // namespace content | 110 } // namespace content |
| 99 | 111 |
| 100 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_REQUEST_INFO_H_ | 112 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_REQUEST_INFO_H_ |
| OLD | NEW |