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_BACKGROUND_FETCH_CONTEXT_H_ | 5 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ |
6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ | 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "third_party/WebKit/public/platform/modules/background_fetch/background _fetch.mojom.h" | 16 #include "third_party/WebKit/public/platform/modules/background_fetch/background _fetch.mojom.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 class URLRequestContextGetter; | 19 class URLRequestContextGetter; |
20 } | 20 } |
21 | 21 |
22 namespace url { | 22 namespace url { |
23 class Origin; | 23 class Origin; |
24 } | 24 } |
25 | 25 |
26 namespace content { | 26 namespace content { |
27 | 27 |
28 class BackgroundFetchClient; | |
29 class BackgroundFetchClientProxy; | |
28 class BackgroundFetchDataManager; | 30 class BackgroundFetchDataManager; |
29 class BackgroundFetchEventDispatcher; | 31 class BackgroundFetchEventDispatcher; |
30 class BackgroundFetchJobController; | 32 class BackgroundFetchJobController; |
31 struct BackgroundFetchOptions; | 33 struct BackgroundFetchOptions; |
32 class BackgroundFetchRegistrationId; | 34 class BackgroundFetchRegistrationId; |
33 class BackgroundFetchRequestInfo; | 35 class BackgroundFetchRequestInfo; |
34 class BlobHandle; | 36 class BlobHandle; |
35 class BrowserContext; | 37 class BrowserContext; |
36 class ServiceWorkerContextWrapper; | 38 class ServiceWorkerContextWrapper; |
37 struct ServiceWorkerFetchRequest; | 39 struct ServiceWorkerFetchRequest; |
(...skipping 23 matching lines...) Expand all Loading... | |
61 | 63 |
62 // Starts a Background Fetch for the |registration_id|. The |requests| will be | 64 // Starts a Background Fetch for the |registration_id|. The |requests| will be |
63 // asynchronously fetched. The |callback| will be invoked when the fetch has | 65 // asynchronously fetched. The |callback| will be invoked when the fetch has |
64 // been registered, or an error occurred that avoids it from doing so. | 66 // been registered, or an error occurred that avoids it from doing so. |
65 void StartFetch( | 67 void StartFetch( |
66 const BackgroundFetchRegistrationId& registration_id, | 68 const BackgroundFetchRegistrationId& registration_id, |
67 const std::vector<ServiceWorkerFetchRequest>& requests, | 69 const std::vector<ServiceWorkerFetchRequest>& requests, |
68 const BackgroundFetchOptions& options, | 70 const BackgroundFetchOptions& options, |
69 const blink::mojom::BackgroundFetchService::FetchCallback& callback); | 71 const blink::mojom::BackgroundFetchService::FetchCallback& callback); |
70 | 72 |
73 // Cleans up all Background Fetch operations whether in progress or completed. | |
74 void CleanupAllTasks(); | |
75 | |
76 // Cancels the Background Fetch for the |registration_id| and triggers the | |
77 // 'backgroundfetchabort' event to be sent to the associated service worker. | |
78 void CancelFetch(const BackgroundFetchRegistrationId& registration_id); | |
79 | |
80 // Pauses the Background Fetch for the |registration_id|. If the fetch was | |
81 // already paused, this has no effect. | |
82 void PauseFetch(const BackgroundFetchRegistrationId& registration_id); | |
83 | |
84 // Resumes the previously paused Background Fetch for the |registration_id|. | |
85 // If the fetch was not paused, this has no effect. | |
86 void ResumeFetch(const BackgroundFetchRegistrationId& registration_id); | |
87 | |
71 // Returns a vector with the tags of the active fetches for the given |origin| | 88 // Returns a vector with the tags of the active fetches for the given |origin| |
72 // and |service_worker_registration_id|. | 89 // and |service_worker_registration_id|. |
73 std::vector<std::string> GetActiveTagsForServiceWorkerRegistration( | 90 std::vector<std::string> GetActiveTagsForServiceWorkerRegistration( |
74 int64_t service_worker_registration_id, | 91 int64_t service_worker_registration_id, |
75 const url::Origin& origin) const; | 92 const url::Origin& origin) const; |
76 | 93 |
77 // Returns the JobController that is handling the |registration_id|, or a | 94 // Returns the JobController that is handling the |registration_id|, or a |
78 // nullptr if it does not exist. Must be immediately used by the caller. | 95 // nullptr if it does not exist. Must be immediately used by the caller. |
79 BackgroundFetchJobController* GetActiveFetch( | 96 BackgroundFetchJobController* GetActiveFetch( |
80 const BackgroundFetchRegistrationId& registration_id) const; | 97 const BackgroundFetchRegistrationId& registration_id) const; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 145 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
129 | 146 |
130 std::unique_ptr<BackgroundFetchDataManager> data_manager_; | 147 std::unique_ptr<BackgroundFetchDataManager> data_manager_; |
131 std::unique_ptr<BackgroundFetchEventDispatcher> event_dispatcher_; | 148 std::unique_ptr<BackgroundFetchEventDispatcher> event_dispatcher_; |
132 | 149 |
133 // Map of the Background Fetch fetches that are currently in-progress. | 150 // Map of the Background Fetch fetches that are currently in-progress. |
134 std::map<BackgroundFetchRegistrationId, | 151 std::map<BackgroundFetchRegistrationId, |
135 std::unique_ptr<BackgroundFetchJobController>> | 152 std::unique_ptr<BackgroundFetchJobController>> |
136 active_fetches_; | 153 active_fetches_; |
137 | 154 |
155 // The proxy will dispatch BackgroundFetchClient calls to the UI thread. | |
156 std::unique_ptr<BackgroundFetchClientProxy> client_proxy_; | |
157 | |
158 // The client is owned by the browser_context. | |
159 BackgroundFetchClient* background_fetch_client_; | |
Peter Beverloo
2017/04/18 23:12:08
We only use this in the constructor - can remove i
harkness
2017/04/19 09:03:41
Done.
| |
160 | |
138 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext); | 161 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext); |
139 }; | 162 }; |
140 | 163 |
141 } // namespace content | 164 } // namespace content |
142 | 165 |
143 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ | 166 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ |
OLD | NEW |