OLD | NEW |
(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_CONTEXT_H_ |
| 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "content/browser/background_fetch/background_fetch_data_manager.h" |
| 11 #include "content/common/content_export.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 class BrowserContext; |
| 16 class FetchRequest; |
| 17 class ServiceWorkerContextWrapper; |
| 18 |
| 19 // The BackgroundFetchContext is the central moderator of ongoing background |
| 20 // fetch requests from the Mojo service and from other callers. |
| 21 // Background Fetch requests function similar to normal fetches except that |
| 22 // they are persistent across Chromium or service worker shutdown. |
| 23 class CONTENT_EXPORT BackgroundFetchContext |
| 24 : public base::RefCountedThreadSafe<BackgroundFetchContext> { |
| 25 public: |
| 26 // The BackgroundFetchContext will watch the ServiceWorkerContextWrapper so |
| 27 // that it can respond to service worker events such as unregister. |
| 28 BackgroundFetchContext( |
| 29 BrowserContext* browser_context, |
| 30 const scoped_refptr<ServiceWorkerContextWrapper>& context); |
| 31 |
| 32 // Init and Shutdown are for use on the UI thread when the StoragePartition is |
| 33 // being setup and torn down. |
| 34 void Init(); |
| 35 |
| 36 // Shutdown must be called before deleting this. Call on the UI thread. |
| 37 void Shutdown(); |
| 38 |
| 39 BackgroundFetchDataManager* GetDataManagerForTesting() { |
| 40 return &background_fetch_data_manager_; |
| 41 } |
| 42 |
| 43 private: |
| 44 void CreateRequest(const FetchRequest& fetch_request); |
| 45 |
| 46 friend class base::RefCountedThreadSafe<BackgroundFetchContext>; |
| 47 ~BackgroundFetchContext(); |
| 48 |
| 49 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; |
| 50 BackgroundFetchDataManager background_fetch_data_manager_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext); |
| 53 }; |
| 54 |
| 55 } // namespace content |
| 56 |
| 57 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ |
OLD | NEW |