Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: content/browser/background_fetch/background_fetch_request_info.h

Issue 2778793002: Start aligning BackgroundFetchRequestInfo with the passed in request object. (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 explicit BackgroundFetchRequestInfo(
25 const ServiceWorkerFetchRequest& fetch_request);
24 // TODO(harkness): Remove copy constructor once the final (non-map-based) 26 // TODO(harkness): Remove copy constructor once the final (non-map-based)
25 // state management is in place. 27 // state management is in place.
26 BackgroundFetchRequestInfo(const BackgroundFetchRequestInfo& request); 28 BackgroundFetchRequestInfo(const BackgroundFetchRequestInfo& request);
27 ~BackgroundFetchRequestInfo(); 29 ~BackgroundFetchRequestInfo();
28 30
29 const std::string& guid() const { return guid_; } 31 const std::string& guid() const { return guid_; }
30 const GURL& url() const { return url_; } 32
31 const std::string& tag() const { return tag_; } 33 const GURL& GetURL() const;
32 34
33 DownloadItem::DownloadState state() const { return state_; } 35 DownloadItem::DownloadState state() const { return state_; }
34 void set_state(DownloadItem::DownloadState state) { state_ = state; } 36 void set_state(DownloadItem::DownloadState state) { state_ = state; }
35 37
36 const std::string& download_guid() const { return download_guid_; } 38 const std::string& download_guid() const { return download_guid_; }
37 void set_download_guid(const std::string& download_guid) { 39 void set_download_guid(const std::string& download_guid) {
38 download_guid_ = download_guid; 40 download_guid_ = download_guid;
39 } 41 }
40 42
41 DownloadInterruptReason interrupt_reason() const { return interrupt_reason_; } 43 DownloadInterruptReason interrupt_reason() const { return interrupt_reason_; }
42 void set_interrupt_reason(DownloadInterruptReason reason) { 44 void set_interrupt_reason(DownloadInterruptReason reason) {
43 interrupt_reason_ = reason; 45 interrupt_reason_ = reason;
44 } 46 }
45 47
46 const base::FilePath& file_path() const { return file_path_; } 48 const base::FilePath& file_path() const { return file_path_; }
47 void set_file_path(const base::FilePath& file_path) { 49 void set_file_path(const base::FilePath& file_path) {
48 file_path_ = file_path; 50 file_path_ = file_path;
49 } 51 }
50 52
51 int64_t received_bytes() const { return received_bytes_; } 53 int64_t received_bytes() const { return received_bytes_; }
52 void set_received_bytes(int64_t received_bytes) { 54 void set_received_bytes(int64_t received_bytes) {
53 received_bytes_ = received_bytes; 55 received_bytes_ = received_bytes;
54 } 56 }
55 57
56 bool IsComplete() const; 58 bool IsComplete() const;
57 59
58 private: 60 private:
61 ServiceWorkerFetchRequest fetch_request_;
62
59 std::string guid_; 63 std::string guid_;
60 GURL url_;
61 std::string tag_;
62 std::string download_guid_; 64 std::string download_guid_;
63 65
64 // The following members do not need to be persisted, they can be reset after 66 // The following members do not need to be persisted, they can be reset after
65 // a chrome restart. 67 // a chrome restart.
66 DownloadItem::DownloadState state_ = 68 DownloadItem::DownloadState state_ =
67 DownloadItem::DownloadState::MAX_DOWNLOAD_STATE; 69 DownloadItem::DownloadState::MAX_DOWNLOAD_STATE;
68 DownloadInterruptReason interrupt_reason_ = 70 DownloadInterruptReason interrupt_reason_ =
69 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE; 71 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE;
70 base::FilePath file_path_; 72 base::FilePath file_path_;
71 int64_t received_bytes_ = 0; 73 int64_t received_bytes_ = 0;
72 }; 74 };
73 75
74 } // namespace content 76 } // namespace content
75 77
76 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_REQUEST_INFO_H_ 78 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_REQUEST_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698