Chromium Code Reviews| 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/browser/service_worker/service_worker_context_observer.h" | |
| 12 #include "content/common/content_export.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 class BrowserContext; | |
| 17 class FetchRequest; | |
| 18 class ServiceWorkerContextWrapper; | |
| 19 | |
| 20 // The BackgroundFetchContext is the central moderator of ongoing background | |
| 21 // fetch requests from the Mojo service and from other callers. | |
| 22 // Background Fetch requests function similar to normal fetches except that | |
| 23 // they are persistent across Chromium or service worker shutdown. | |
| 24 class CONTENT_EXPORT BackgroundFetchContext | |
| 25 : public ServiceWorkerContextObserver, | |
| 26 public base::RefCountedThreadSafe<BackgroundFetchContext> { | |
| 27 public: | |
| 28 // The BackgroundFetchContext will watch the ServiceWorkerContextWrapper so | |
| 29 // that it can respond to service worker events such as unregister. | |
| 30 explicit BackgroundFetchContext( | |
|
Peter Beverloo
2017/02/13 18:35:05
nit: `explicit` is only necessary for constructors
harkness
2017/02/14 13:52:46
Done.
| |
| 31 BrowserContext* browser_context, | |
| 32 const scoped_refptr<ServiceWorkerContextWrapper>& context); | |
| 33 | |
| 34 // Init and Shutdown are for use on the UI thread when the StoragePartition is | |
| 35 // being setup and torn down. | |
| 36 void Init(); | |
| 37 | |
| 38 // Shutdown must be called before deleting this. Call on the UI thread. | |
| 39 void Shutdown(); | |
| 40 | |
| 41 // ServiceWorkerContextObserver methods. | |
| 42 void OnRegistrationDeleted(int64_t registration_id, | |
| 43 const GURL& pattern) override; | |
| 44 | |
| 45 void CreateRequest(const FetchRequest& fetch_request); | |
| 46 | |
| 47 private: | |
| 48 friend class base::RefCountedThreadSafe<BackgroundFetchContext>; | |
| 49 ~BackgroundFetchContext() override; | |
| 50 | |
| 51 BrowserContext* browser_context_; | |
| 52 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | |
| 53 BackgroundFetchDataManager background_fetch_data_manager_; | |
| 54 | |
| 55 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext); | |
| 56 }; | |
| 57 | |
| 58 } // namespace content | |
| 59 | |
| 60 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ | |
| OLD | NEW |