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