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/strong_binding.h"
17 class BackgroundSyncContextImpl
;
19 class CONTENT_EXPORT BackgroundSyncServiceImpl
20 : public NON_EXPORTED_BASE(BackgroundSyncService
) {
23 const scoped_refptr
<BackgroundSyncContextImpl
>& background_sync_context
,
24 mojo::InterfaceRequest
<BackgroundSyncService
> request
);
26 ~BackgroundSyncServiceImpl() override
;
29 friend class BackgroundSyncServiceImplTest
;
31 static void CreateOnIOThread(
32 const scoped_refptr
<BackgroundSyncContextImpl
>& background_sync_context
,
33 mojo::InterfaceRequest
<BackgroundSyncService
> request
);
35 explicit BackgroundSyncServiceImpl(
36 const scoped_refptr
<BackgroundSyncContextImpl
>& background_sync_context
,
37 mojo::InterfaceRequest
<BackgroundSyncService
> request
);
39 // BackgroundSyncService methods:
40 void Register(content::SyncRegistrationPtr options
,
41 int64_t sw_registration_id
,
42 const RegisterCallback
& callback
) override
;
43 void Unregister(BackgroundSyncPeriodicity periodicity
,
45 const mojo::String
& tag
,
46 int64_t sw_registration_id
,
47 const UnregisterCallback
& callback
) override
;
48 void GetRegistration(BackgroundSyncPeriodicity periodicity
,
49 const mojo::String
& tag
,
50 int64_t sw_registration_id
,
51 const GetRegistrationCallback
& callback
) override
;
52 void GetRegistrations(BackgroundSyncPeriodicity periodicity
,
53 int64_t sw_registration_id
,
54 const GetRegistrationsCallback
& callback
) override
;
55 void GetPermissionStatus(
56 BackgroundSyncPeriodicity periodicity
,
57 int64_t sw_registration_id
,
58 const GetPermissionStatusCallback
& callback
) override
;
60 void OnRegisterResult(const RegisterCallback
& callback
,
61 BackgroundSyncManager::ErrorType error
,
62 const BackgroundSyncRegistration
& result
);
63 void OnUnregisterResult(const UnregisterCallback
& callback
,
64 BackgroundSyncManager::ErrorType error
);
65 void OnGetRegistrationsResult(
66 const GetRegistrationsCallback
& callback
,
67 BackgroundSyncManager::ErrorType error
,
68 const std::vector
<BackgroundSyncRegistration
>& result
);
70 scoped_refptr
<BackgroundSyncContextImpl
> background_sync_context_
;
71 mojo::StrongBinding
<BackgroundSyncService
> binding_
;
73 base::WeakPtrFactory
<BackgroundSyncServiceImpl
> weak_ptr_factory_
;
75 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncServiceImpl
);
78 } // namespace content
80 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_