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

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

Issue 2767373002: Implement GetJobResponse and merge JobData into DataManager. (Closed)
Patch Set: Removed typedef and added DISALLOW_COPY_AND_ASSIGN Created 3 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_DATA_H_
6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_DATA_H_
7
8 #include <string>
9 #include <unordered_map>
10
11 #include "base/macros.h"
12 #include "content/browser/background_fetch/background_fetch_request_info.h"
13 #include "content/common/content_export.h"
14 #include "content/public/browser/download_interrupt_reasons.h"
15 #include "content/public/browser/download_item.h"
16 #include "url/origin.h"
17
18 namespace content {
19
20 // The BackgroundFetchJobData class provides the interface from the
21 // JobController to the data storage in the DataManager. It has a reference
22 // to the DataManager and invokes calls given the stored batch_guid.
23 class CONTENT_EXPORT BackgroundFetchJobData {
24 public:
25 explicit BackgroundFetchJobData(BackgroundFetchRequestInfos& request_infos);
26 ~BackgroundFetchJobData();
27
28 // Called by the JobController to inform the JobData that the given fetch
29 // has been updated. The JobData returns a boolean indicating whether there
30 // are more requests to process.
31 bool UpdateBackgroundFetchRequestState(
32 const std::string& fetch_guid,
33 DownloadItem::DownloadState state,
34 DownloadInterruptReason interrupt_reason);
35
36 // Called by the JobController to get a BackgroundFetchRequestInfo to
37 // process.
38 const BackgroundFetchRequestInfo& GetNextBackgroundFetchRequestInfo();
39
40 // Indicates whether all requests have been handed to the JobController.
41 bool HasRequestsRemaining() const;
42
43 // Indicates whether all requests have been handed out and completed.
44 bool IsComplete() const;
45
46 // Inform the JobData of the GUID the DownloadManager assigned to this
47 // request.
48 void SetRequestDownloadGuid(const std::string& request_guid,
49 const std::string& download_guid);
50
51 private:
52 BackgroundFetchRequestInfos& request_infos_;
53
54 // Map from fetch_guid to index in request_infos_. Only currently
55 // outstanding requests should be in this map.
56 std::unordered_map<std::string, int> request_info_index_;
57 size_t next_request_info_ = 0;
58
59 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchJobData);
60 };
61
62 } // namespace content
63
64 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_JOB_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698