OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_SYNC_BACKGROUND_SYNC_CONTEXT_H_ | 5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_H_ |
6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_H_ | 6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
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 "third_party/WebKit/public/platform/modules/background_sync/background_
sync.mojom.h" | 14 #include "third_party/WebKit/public/platform/modules/background_sync/background_
sync.mojom.h" |
15 | 15 |
| 16 namespace service_manager { |
| 17 struct BindSourceInfo; |
| 18 } |
| 19 |
16 namespace content { | 20 namespace content { |
17 | 21 |
18 class BackgroundSyncManager; | 22 class BackgroundSyncManager; |
19 class BackgroundSyncServiceImpl; | 23 class BackgroundSyncServiceImpl; |
20 class ServiceWorkerContextWrapper; | 24 class ServiceWorkerContextWrapper; |
21 | 25 |
22 // One instance of this exists per StoragePartition, and services multiple child | 26 // One instance of this exists per StoragePartition, and services multiple child |
23 // processes/origins. Most logic is delegated to the owned BackgroundSyncManager | 27 // processes/origins. Most logic is delegated to the owned BackgroundSyncManager |
24 // instance, which is only accessed on the IO thread. | 28 // instance, which is only accessed on the IO thread. |
25 class CONTENT_EXPORT BackgroundSyncContext | 29 class CONTENT_EXPORT BackgroundSyncContext |
26 : public base::RefCountedThreadSafe<BackgroundSyncContext> { | 30 : public base::RefCountedThreadSafe<BackgroundSyncContext> { |
27 public: | 31 public: |
28 BackgroundSyncContext(); | 32 BackgroundSyncContext(); |
29 | 33 |
30 // Init and Shutdown are for use on the UI thread when the | 34 // Init and Shutdown are for use on the UI thread when the |
31 // StoragePartition is being setup and torn down. | 35 // StoragePartition is being setup and torn down. |
32 void Init(const scoped_refptr<ServiceWorkerContextWrapper>& context); | 36 void Init(const scoped_refptr<ServiceWorkerContextWrapper>& context); |
33 | 37 |
34 // Shutdown must be called before deleting this. Call on the UI thread. | 38 // Shutdown must be called before deleting this. Call on the UI thread. |
35 void Shutdown(); | 39 void Shutdown(); |
36 | 40 |
37 // Create a BackgroundSyncServiceImpl that is owned by this. Call on the UI | 41 // Create a BackgroundSyncServiceImpl that is owned by this. Call on the UI |
38 // thread. | 42 // thread. |
39 void CreateService( | 43 void CreateService(const service_manager::BindSourceInfo& source_info, |
40 mojo::InterfaceRequest<blink::mojom::BackgroundSyncService> request); | 44 blink::mojom::BackgroundSyncServiceRequest request); |
41 | 45 |
42 // Called by BackgroundSyncServiceImpl objects so that they can | 46 // Called by BackgroundSyncServiceImpl objects so that they can |
43 // be deleted. Call on the IO thread. | 47 // be deleted. Call on the IO thread. |
44 void ServiceHadConnectionError(BackgroundSyncServiceImpl* service); | 48 void ServiceHadConnectionError(BackgroundSyncServiceImpl* service); |
45 | 49 |
46 // Call on the IO thread. | 50 // Call on the IO thread. |
47 BackgroundSyncManager* background_sync_manager() const; | 51 BackgroundSyncManager* background_sync_manager() const; |
48 | 52 |
49 protected: | 53 protected: |
50 friend class base::RefCountedThreadSafe<BackgroundSyncContext>; | 54 friend class base::RefCountedThreadSafe<BackgroundSyncContext>; |
(...skipping 22 matching lines...) Expand all Loading... |
73 std::map<BackgroundSyncServiceImpl*, | 77 std::map<BackgroundSyncServiceImpl*, |
74 std::unique_ptr<BackgroundSyncServiceImpl>> | 78 std::unique_ptr<BackgroundSyncServiceImpl>> |
75 services_; | 79 services_; |
76 | 80 |
77 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncContext); | 81 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncContext); |
78 }; | 82 }; |
79 | 83 |
80 } // namespace content | 84 } // namespace content |
81 | 85 |
82 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_H_ | 86 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_CONTEXT_H_ |
OLD | NEW |