| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "third_party/WebKit/public/platform/modules/background_fetch/background
_fetch.mojom.h" | 15 #include "third_party/WebKit/public/platform/modules/background_fetch/background
_fetch.mojom.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 class BackgroundFetchClientProxy; |
| 19 class BackgroundFetchDataManager; | 20 class BackgroundFetchDataManager; |
| 20 class BackgroundFetchJobController; | 21 class BackgroundFetchJobController; |
| 21 struct BackgroundFetchOptions; | 22 struct BackgroundFetchOptions; |
| 22 class BackgroundFetchRegistrationId; | 23 class BackgroundFetchRegistrationId; |
| 23 class BrowserContext; | 24 class BrowserContext; |
| 24 class ServiceWorkerContextWrapper; | 25 class ServiceWorkerContextWrapper; |
| 25 struct ServiceWorkerFetchRequest; | 26 struct ServiceWorkerFetchRequest; |
| 26 class StoragePartitionImpl; | 27 class StoragePartitionImpl; |
| 27 | 28 |
| 28 // The BackgroundFetchContext is the central moderator of ongoing background | 29 // The BackgroundFetchContext is the central moderator of ongoing background |
| (...skipping 16 matching lines...) Expand all Loading... |
| 45 | 46 |
| 46 // Starts a Background Fetch for the |registration_id|. The |requests| will be | 47 // Starts a Background Fetch for the |registration_id|. The |requests| will be |
| 47 // asynchronously fetched. The |callback| will be invoked when the fetch has | 48 // asynchronously fetched. The |callback| will be invoked when the fetch has |
| 48 // been registered, or an error occurred that avoids it from doing so. | 49 // been registered, or an error occurred that avoids it from doing so. |
| 49 void StartFetch( | 50 void StartFetch( |
| 50 const BackgroundFetchRegistrationId& registration_id, | 51 const BackgroundFetchRegistrationId& registration_id, |
| 51 const std::vector<ServiceWorkerFetchRequest>& requests, | 52 const std::vector<ServiceWorkerFetchRequest>& requests, |
| 52 const BackgroundFetchOptions& options, | 53 const BackgroundFetchOptions& options, |
| 53 const blink::mojom::BackgroundFetchService::FetchCallback& callback); | 54 const blink::mojom::BackgroundFetchService::FetchCallback& callback); |
| 54 | 55 |
| 56 // Cancels the Background Fetch for the |registration_id| and triggers the |
| 57 // 'backgroundfetchabort' event to be sent to the associated service worker. |
| 58 void CancelFetch(const BackgroundFetchRegistrationId& registration_id); |
| 59 |
| 60 // Pauses the Background Fetch for the |registration_id|. If the fetch was |
| 61 // already paused, this has no effect. |
| 62 void PauseFetch(const BackgroundFetchRegistrationId& registration_id); |
| 63 |
| 64 // Resumes the previously paused Background Fetch for the |registration_id|. |
| 65 // If the fetch was not paused, this has no effect. |
| 66 void ResumeFetch(const BackgroundFetchRegistrationId& registration_id); |
| 67 |
| 55 private: | 68 private: |
| 56 friend class base::DeleteHelper<BackgroundFetchContext>; | 69 friend class base::DeleteHelper<BackgroundFetchContext>; |
| 57 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 70 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
| 58 friend class base::RefCountedThreadSafe<BackgroundFetchContext, | 71 friend class base::RefCountedThreadSafe<BackgroundFetchContext, |
| 59 BrowserThread::DeleteOnUIThread>; | 72 BrowserThread::DeleteOnUIThread>; |
| 60 | 73 |
| 61 ~BackgroundFetchContext(); | 74 ~BackgroundFetchContext(); |
| 62 | 75 |
| 63 // Shuts down the active Job Controllers on the IO thread. | 76 // Shuts down the active Job Controllers on the IO thread. |
| 64 void ShutdownOnIO(); | 77 void ShutdownOnIO(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 84 StoragePartitionImpl* storage_partition_; | 97 StoragePartitionImpl* storage_partition_; |
| 85 | 98 |
| 86 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | 99 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; |
| 87 std::unique_ptr<BackgroundFetchDataManager> background_fetch_data_manager_; | 100 std::unique_ptr<BackgroundFetchDataManager> background_fetch_data_manager_; |
| 88 | 101 |
| 89 // Map of the Background Fetch fetches that are currently in-progress. | 102 // Map of the Background Fetch fetches that are currently in-progress. |
| 90 std::map<BackgroundFetchRegistrationId, | 103 std::map<BackgroundFetchRegistrationId, |
| 91 std::unique_ptr<BackgroundFetchJobController>> | 104 std::unique_ptr<BackgroundFetchJobController>> |
| 92 active_fetches_; | 105 active_fetches_; |
| 93 | 106 |
| 107 // The proxy will dispatch BackgroundFetchClient calls to the UI thread. |
| 108 std::unique_ptr<BackgroundFetchClientProxy> client_proxy_; |
| 109 |
| 94 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext); | 110 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext); |
| 95 }; | 111 }; |
| 96 | 112 |
| 97 } // namespace content | 113 } // namespace content |
| 98 | 114 |
| 99 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ | 115 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ |
| OLD | NEW |