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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_
6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_
10 #include "base/memory/ref_counted.h"
11 #include "content/browser/background_sync/background_sync_manager.h"
12 #include "content/common/background_sync_service.mojom.h"
13 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
17 class BackgroundSyncContextImpl
;
19 class CONTENT_EXPORT BackgroundSyncServiceImpl
20 : public NON_EXPORTED_BASE(BackgroundSyncService
) {
22 BackgroundSyncServiceImpl(
23 BackgroundSyncContextImpl
* background_sync_context
,
24 mojo::InterfaceRequest
<BackgroundSyncService
> request
);
26 ~BackgroundSyncServiceImpl() override
;
29 friend class BackgroundSyncServiceImplTest
;
32 // BackgroundSyncService methods:
33 void Register(content::SyncRegistrationPtr options
,
34 int64_t sw_registration_id
,
35 bool requested_from_service_worker
,
36 const RegisterCallback
& callback
) override
;
37 void Unregister(BackgroundSyncPeriodicity periodicity
,
39 const mojo::String
& tag
,
40 int64_t sw_registration_id
,
41 const UnregisterCallback
& callback
) override
;
42 void GetRegistration(BackgroundSyncPeriodicity periodicity
,
43 const mojo::String
& tag
,
44 int64_t sw_registration_id
,
45 const GetRegistrationCallback
& callback
) override
;
46 void GetRegistrations(BackgroundSyncPeriodicity periodicity
,
47 int64_t sw_registration_id
,
48 const GetRegistrationsCallback
& callback
) override
;
49 void GetPermissionStatus(
50 BackgroundSyncPeriodicity periodicity
,
51 int64_t sw_registration_id
,
52 const GetPermissionStatusCallback
& callback
) override
;
54 void OnRegisterResult(const RegisterCallback
& callback
,
55 BackgroundSyncStatus status
,
56 const BackgroundSyncRegistration
& result
);
57 void OnUnregisterResult(const UnregisterCallback
& callback
,
58 BackgroundSyncStatus status
);
59 void OnGetRegistrationsResult(
60 const GetRegistrationsCallback
& callback
,
61 BackgroundSyncStatus status
,
62 const std::vector
<BackgroundSyncRegistration
>& result
);
64 // Called when an error is detected on binding_.
65 void OnConnectionError();
67 // background_sync_context_ owns this.
68 BackgroundSyncContextImpl
* background_sync_context_
;
70 mojo::Binding
<BackgroundSyncService
> binding_
;
72 base::WeakPtrFactory
<BackgroundSyncServiceImpl
> weak_ptr_factory_
;
74 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncServiceImpl
);
77 } // namespace content
79 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_