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_SERVICE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_ |
6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_ | 6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "content/browser/background_sync/background_sync_manager.h" | 11 #include "content/browser/background_sync/background_sync_manager.h" |
12 #include "content/common/background_sync_service.mojom.h" | 12 #include "content/common/background_sync_service.mojom.h" |
13 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | 13 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 class BackgroundSyncContextImpl; | 17 class BackgroundSyncContextImpl; |
18 | 18 |
19 class CONTENT_EXPORT BackgroundSyncServiceImpl | 19 class CONTENT_EXPORT BackgroundSyncServiceImpl |
20 : public NON_EXPORTED_BASE(BackgroundSyncService) { | 20 : public NON_EXPORTED_BASE(BackgroundSyncService) { |
21 public: | 21 public: |
22 static void Create( | 22 BackgroundSyncServiceImpl( |
23 const scoped_refptr<BackgroundSyncContextImpl>& background_sync_context, | 23 BackgroundSyncContextImpl* background_sync_context, |
24 mojo::InterfaceRequest<BackgroundSyncService> request); | 24 mojo::InterfaceRequest<BackgroundSyncService> request); |
25 | 25 |
26 ~BackgroundSyncServiceImpl() override; | 26 ~BackgroundSyncServiceImpl() override; |
27 | 27 |
28 private: | 28 private: |
29 friend class BackgroundSyncServiceImplTest; | 29 friend class BackgroundSyncServiceImplTest; |
30 | 30 |
31 static void CreateOnIOThread( | |
32 const scoped_refptr<BackgroundSyncContextImpl>& background_sync_context, | |
33 mojo::InterfaceRequest<BackgroundSyncService> request); | |
34 | |
35 explicit BackgroundSyncServiceImpl( | |
36 const scoped_refptr<BackgroundSyncContextImpl>& background_sync_context, | |
37 mojo::InterfaceRequest<BackgroundSyncService> request); | |
38 | 31 |
39 // BackgroundSyncService methods: | 32 // BackgroundSyncService methods: |
40 void Register(content::SyncRegistrationPtr options, | 33 void Register(content::SyncRegistrationPtr options, |
41 int64_t sw_registration_id, | 34 int64_t sw_registration_id, |
42 const RegisterCallback& callback) override; | 35 const RegisterCallback& callback) override; |
43 void Unregister(BackgroundSyncPeriodicity periodicity, | 36 void Unregister(BackgroundSyncPeriodicity periodicity, |
44 int64_t id, | 37 int64_t id, |
45 const mojo::String& tag, | 38 const mojo::String& tag, |
46 int64_t sw_registration_id, | 39 int64_t sw_registration_id, |
47 const UnregisterCallback& callback) override; | 40 const UnregisterCallback& callback) override; |
(...skipping 12 matching lines...) Expand all Loading... |
60 void OnRegisterResult(const RegisterCallback& callback, | 53 void OnRegisterResult(const RegisterCallback& callback, |
61 BackgroundSyncStatus status, | 54 BackgroundSyncStatus status, |
62 const BackgroundSyncRegistration& result); | 55 const BackgroundSyncRegistration& result); |
63 void OnUnregisterResult(const UnregisterCallback& callback, | 56 void OnUnregisterResult(const UnregisterCallback& callback, |
64 BackgroundSyncStatus status); | 57 BackgroundSyncStatus status); |
65 void OnGetRegistrationsResult( | 58 void OnGetRegistrationsResult( |
66 const GetRegistrationsCallback& callback, | 59 const GetRegistrationsCallback& callback, |
67 BackgroundSyncStatus status, | 60 BackgroundSyncStatus status, |
68 const std::vector<BackgroundSyncRegistration>& result); | 61 const std::vector<BackgroundSyncRegistration>& result); |
69 | 62 |
70 scoped_refptr<BackgroundSyncContextImpl> background_sync_context_; | 63 // Called when an error is detected on binding_. |
71 mojo::StrongBinding<BackgroundSyncService> binding_; | 64 void OnConnectionError(); |
| 65 |
| 66 // background_sync_context_ owns this. |
| 67 BackgroundSyncContextImpl* background_sync_context_; |
| 68 |
| 69 mojo::Binding<BackgroundSyncService> binding_; |
72 | 70 |
73 base::WeakPtrFactory<BackgroundSyncServiceImpl> weak_ptr_factory_; | 71 base::WeakPtrFactory<BackgroundSyncServiceImpl> weak_ptr_factory_; |
74 | 72 |
75 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncServiceImpl); | 73 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncServiceImpl); |
76 }; | 74 }; |
77 | 75 |
78 } // namespace content | 76 } // namespace content |
79 | 77 |
80 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_ | 78 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_ |
OLD | NEW |