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, | |
Peter Beverloo
2017/02/14 15:05:52
nit: let's remove this parent class, as well as th
harkness
2017/02/15 13:48:44
Done.
| |
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 BackgroundFetchContext( | |
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 BackgroundFetchDataManager* GetDataManagerForTesting() { | |
46 return &background_fetch_data_manager_; | |
47 } | |
48 | |
49 private: | |
50 void CreateRequest(const FetchRequest& fetch_request); | |
51 | |
52 friend class base::RefCountedThreadSafe<BackgroundFetchContext>; | |
53 ~BackgroundFetchContext() override; | |
54 | |
55 BrowserContext* browser_context_; | |
56 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | |
57 BackgroundFetchDataManager background_fetch_data_manager_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(BackgroundFetchContext); | |
60 }; | |
61 | |
62 } // namespace content | |
63 | |
64 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CONTEXT_H_ | |
OLD | NEW |