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

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

Issue 2978603003: [Background Fetch] Tidy up getting/activating pending requests (Closed)
Patch Set: Split up MarkRequestAsCompleteAndGetNextRequest and nuke pending_completed_file_acknowledgements_ Created 3 years, 5 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_BACKGROUND_FETCH_DATA_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_
6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_ 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 15 matching lines...) Expand all
26 class BlobHandle; 26 class BlobHandle;
27 class BrowserContext; 27 class BrowserContext;
28 class ChromeBlobStorageContext; 28 class ChromeBlobStorageContext;
29 29
30 // The BackgroundFetchDataManager keeps track of all of the outstanding requests 30 // The BackgroundFetchDataManager keeps track of all of the outstanding requests
31 // which are in process in the DownloadManager. When Chromium restarts, it is 31 // which are in process in the DownloadManager. When Chromium restarts, it is
32 // responsibile for reconnecting all the in progress downloads with an observer 32 // responsibile for reconnecting all the in progress downloads with an observer
33 // which will keep the metadata up to date. 33 // which will keep the metadata up to date.
34 class CONTENT_EXPORT BackgroundFetchDataManager { 34 class CONTENT_EXPORT BackgroundFetchDataManager {
35 public: 35 public:
36 using CreateRegistrationCallback = base::OnceCallback<void( 36 using CreateRegistrationCallback =
37 blink::mojom::BackgroundFetchError, 37 base::OnceCallback<void(blink::mojom::BackgroundFetchError)>;
38 std::vector<scoped_refptr<BackgroundFetchRequestInfo>>)>;
39 using DeleteRegistrationCallback = 38 using DeleteRegistrationCallback =
40 base::OnceCallback<void(blink::mojom::BackgroundFetchError)>; 39 base::OnceCallback<void(blink::mojom::BackgroundFetchError)>;
41 using NextRequestCallback = 40 using NextRequestCallback =
42 base::OnceCallback<void(scoped_refptr<BackgroundFetchRequestInfo>)>; 41 base::OnceCallback<void(scoped_refptr<BackgroundFetchRequestInfo>)>;
42 using MarkedCompleteCallback =
43 base::OnceCallback<void(bool /* has_pending_or_active_requests */)>;
43 using SettledFetchesCallback = 44 using SettledFetchesCallback =
44 base::OnceCallback<void(blink::mojom::BackgroundFetchError, 45 base::OnceCallback<void(blink::mojom::BackgroundFetchError,
45 bool /* background_fetch_succeeded */, 46 bool /* background_fetch_succeeded */,
46 std::vector<BackgroundFetchSettledFetch>, 47 std::vector<BackgroundFetchSettledFetch>,
47 std::vector<std::unique_ptr<BlobHandle>>)>; 48 std::vector<std::unique_ptr<BlobHandle>>)>;
48 49
49 explicit BackgroundFetchDataManager(BrowserContext* browser_context); 50 explicit BackgroundFetchDataManager(BrowserContext* browser_context);
50 ~BackgroundFetchDataManager(); 51 ~BackgroundFetchDataManager();
51 52
52 // Creates and stores a new registration with the given properties. Will 53 // Creates and stores a new registration with the given properties. Will
53 // invoke the |callback| when the registration has been created, which may 54 // invoke the |callback| when the registration has been created, which may
54 // fail due to invalid input or storage errors. 55 // fail due to invalid input or storage errors.
55 void CreateRegistration( 56 void CreateRegistration(
56 const BackgroundFetchRegistrationId& registration_id, 57 const BackgroundFetchRegistrationId& registration_id,
57 const std::vector<ServiceWorkerFetchRequest>& requests, 58 const std::vector<ServiceWorkerFetchRequest>& requests,
58 const BackgroundFetchOptions& options, 59 const BackgroundFetchOptions& options,
59 CreateRegistrationCallback callback); 60 CreateRegistrationCallback callback);
60 61
62 // Activates the next pending request, if any, such that it is ready to be
63 // started, and invokes the |callback| with that request, else a null request.
Peter Beverloo 2017/07/12 13:30:50 nit: update comment ("activate")
johnme 2017/07/12 14:13:57 Done.
64 void PopNextRequest(const BackgroundFetchRegistrationId& registration_id,
65 NextRequestCallback callback);
66
61 // Marks that the |request|, part of the Background Fetch identified by 67 // Marks that the |request|, part of the Background Fetch identified by
62 // |registration_id|, has been started as |download_guid|. 68 // |registration_id|, has been started as |download_guid|.
63 void MarkRequestAsStarted( 69 void MarkRequestAsStarted(
64 const BackgroundFetchRegistrationId& registration_id, 70 const BackgroundFetchRegistrationId& registration_id,
65 BackgroundFetchRequestInfo* request, 71 BackgroundFetchRequestInfo* request,
66 const std::string& download_guid); 72 const std::string& download_guid);
67 73
68 // Marks that the |request|, part of the Background Fetch identified by 74 // Marks that the |request|, part of the Background Fetch identified by
69 // |registration_id|, has completed. Will invoke the |callback| with the 75 // |registration_id|, has completed.
70 // next request, if any, when the operation has completed. 76 void MarkRequestAsComplete(
71 void MarkRequestAsCompleteAndGetNextRequest(
72 const BackgroundFetchRegistrationId& registration_id, 77 const BackgroundFetchRegistrationId& registration_id,
73 BackgroundFetchRequestInfo* request, 78 BackgroundFetchRequestInfo* request,
74 NextRequestCallback callback); 79 MarkedCompleteCallback callback);
75 80
76 // Reads all settled fetches for the given |registration_id|. Both the Request 81 // Reads all settled fetches for the given |registration_id|. Both the Request
77 // and Response objects will be initialised based on the stored data. Will 82 // and Response objects will be initialised based on the stored data. Will
78 // invoke the |callback| when the list of fetches has been compiled. 83 // invoke the |callback| when the list of fetches has been compiled.
79 void GetSettledFetchesForRegistration( 84 void GetSettledFetchesForRegistration(
80 const BackgroundFetchRegistrationId& registration_id, 85 const BackgroundFetchRegistrationId& registration_id,
81 SettledFetchesCallback callback); 86 SettledFetchesCallback callback);
82 87
83 // Deletes the registration identified by |registration_id|. Will invoke the 88 // Deletes the registration identified by |registration_id|. Will invoke the
84 // |callback| when the registration has been deleted from storage. 89 // |callback| when the registration has been deleted from storage.
(...skipping 15 matching lines...) Expand all
100 SEQUENCE_CHECKER(sequence_checker_); 105 SEQUENCE_CHECKER(sequence_checker_);
101 106
102 base::WeakPtrFactory<BackgroundFetchDataManager> weak_ptr_factory_; 107 base::WeakPtrFactory<BackgroundFetchDataManager> weak_ptr_factory_;
103 108
104 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchDataManager); 109 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchDataManager);
105 }; 110 };
106 111
107 } // namespace content 112 } // namespace content
108 113
109 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_ 114 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_DATA_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698