| 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 BackgroundFetchClientProxy; |
| 28 class BackgroundFetchDataManager; | 29 class BackgroundFetchDataManager; |
| 29 class BackgroundFetchEventDispatcher; | 30 class BackgroundFetchEventDispatcher; |
| 30 class BackgroundFetchJobController; | 31 class BackgroundFetchJobController; |
| 31 struct BackgroundFetchOptions; | 32 struct BackgroundFetchOptions; |
| 32 class BackgroundFetchRegistrationId; | 33 class BackgroundFetchRegistrationId; |
| 33 class BackgroundFetchRequestInfo; | 34 class BackgroundFetchRequestInfo; |
| 34 class BlobHandle; | 35 class BlobHandle; |
| 35 class BrowserContext; | 36 class BrowserContext; |
| 36 class ServiceWorkerContextWrapper; | 37 class ServiceWorkerContextWrapper; |
| 37 struct ServiceWorkerFetchRequest; | 38 struct ServiceWorkerFetchRequest; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 61 | 62 |
| 62 // Starts a Background Fetch for the |registration_id|. The |requests| will be | 63 // Starts a Background Fetch for the |registration_id|. The |requests| will be |
| 63 // asynchronously fetched. The |callback| will be invoked when the fetch has | 64 // asynchronously fetched. The |callback| will be invoked when the fetch has |
| 64 // been registered, or an error occurred that avoids it from doing so. | 65 // been registered, or an error occurred that avoids it from doing so. |
| 65 void StartFetch( | 66 void StartFetch( |
| 66 const BackgroundFetchRegistrationId& registration_id, | 67 const BackgroundFetchRegistrationId& registration_id, |
| 67 const std::vector<ServiceWorkerFetchRequest>& requests, | 68 const std::vector<ServiceWorkerFetchRequest>& requests, |
| 68 const BackgroundFetchOptions& options, | 69 const BackgroundFetchOptions& options, |
| 69 const blink::mojom::BackgroundFetchService::FetchCallback& callback); | 70 const blink::mojom::BackgroundFetchService::FetchCallback& callback); |
| 70 | 71 |
| 72 // Cleans up all Background Fetch operations whether in progress or completed. |
| 73 void CleanupAllTasks(); |
| 74 |
| 75 // Cancels the Background Fetch for the |registration_id| and triggers the |
| 76 // 'backgroundfetchabort' event to be sent to the associated service worker. |
| 77 void CancelFetch(const BackgroundFetchRegistrationId& registration_id); |
| 78 |
| 79 // Pauses the Background Fetch for the |registration_id|. If the fetch was |
| 80 // already paused, this has no effect. |
| 81 void PauseFetch(const BackgroundFetchRegistrationId& registration_id); |
| 82 |
| 83 // Resumes the previously paused Background Fetch for the |registration_id|. |
| 84 // If the fetch was not paused, this has no effect. |
| 85 void ResumeFetch(const BackgroundFetchRegistrationId& registration_id); |
| 86 |
| 71 // Returns a vector with the tags of the active fetches for the given |origin| | 87 // Returns a vector with the tags of the active fetches for the given |origin| |
| 72 // and |service_worker_registration_id|. | 88 // and |service_worker_registration_id|. |
| 73 std::vector<std::string> GetActiveTagsForServiceWorkerRegistration( | 89 std::vector<std::string> GetActiveTagsForServiceWorkerRegistration( |
| 74 int64_t service_worker_registration_id, | 90 int64_t service_worker_registration_id, |
| 75 const url::Origin& origin) const; | 91 const url::Origin& origin) const; |
| 76 | 92 |
| 77 // Returns the JobController that is handling the |registration_id|, or a | 93 // 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. | 94 // nullptr if it does not exist. Must be immediately used by the caller. |
| 79 BackgroundFetchJobController* GetActiveFetch( | 95 BackgroundFetchJobController* GetActiveFetch( |
| 80 const BackgroundFetchRegistrationId& registration_id) const; | 96 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_; | 144 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 129 | 145 |
| 130 std::unique_ptr<BackgroundFetchDataManager> data_manager_; | 146 std::unique_ptr<BackgroundFetchDataManager> data_manager_; |
| 131 std::unique_ptr<BackgroundFetchEventDispatcher> event_dispatcher_; | 147 std::unique_ptr<BackgroundFetchEventDispatcher> event_dispatcher_; |
| 132 | 148 |
| 133 // Map of the Background Fetch fetches that are currently in-progress. | 149 // Map of the Background Fetch fetches that are currently in-progress. |
| 134 std::map<BackgroundFetchRegistrationId, | 150 std::map<BackgroundFetchRegistrationId, |
| 135 std::unique_ptr<BackgroundFetchJobController>> | 151 std::unique_ptr<BackgroundFetchJobController>> |
| 136 active_fetches_; | 152 active_fetches_; |
| 137 | 153 |
| 154 // The proxy will dispatch BackgroundFetchClient calls to the UI thread. |
| 155 std::unique_ptr<BackgroundFetchClientProxy> client_proxy_; |
| 156 |
| 138 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext); | 157 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext); |
| 139 }; | 158 }; |
| 140 | 159 |
| 141 } // namespace content | 160 } // namespace content |
| 142 | 161 |
| 143 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ | 162 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ |
| OLD | NEW |