Chromium Code Reviews| 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 "base/id_map.h" |
| 9 | |
| 10 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_vector.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/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 BackgroundSyncServiceImpl( | 22 BackgroundSyncServiceImpl( |
| 23 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 | |
| 32 // BackgroundSyncService methods: | 31 // BackgroundSyncService methods: |
| 33 void Register(content::SyncRegistrationPtr options, | 32 void Register(content::SyncRegistrationPtr options, |
| 34 int64_t sw_registration_id, | 33 int64_t sw_registration_id, |
| 35 const RegisterCallback& callback) override; | 34 const RegisterCallback& callback) override; |
| 36 void Unregister(BackgroundSyncPeriodicity periodicity, | 35 void Unregister(BackgroundSyncPeriodicity periodicity, |
| 37 int64_t id, | 36 int64_t id, |
| 38 const mojo::String& tag, | |
| 39 int64_t sw_registration_id, | 37 int64_t sw_registration_id, |
| 40 const UnregisterCallback& callback) override; | 38 const UnregisterCallback& callback) override; |
| 41 void GetRegistration(BackgroundSyncPeriodicity periodicity, | 39 void GetRegistration(BackgroundSyncPeriodicity periodicity, |
| 42 const mojo::String& tag, | 40 const mojo::String& tag, |
| 43 int64_t sw_registration_id, | 41 int64_t sw_registration_id, |
| 44 const GetRegistrationCallback& callback) override; | 42 const GetRegistrationCallback& callback) override; |
| 45 void GetRegistrations(BackgroundSyncPeriodicity periodicity, | 43 void GetRegistrations(BackgroundSyncPeriodicity periodicity, |
| 46 int64_t sw_registration_id, | 44 int64_t sw_registration_id, |
| 47 const GetRegistrationsCallback& callback) override; | 45 const GetRegistrationsCallback& callback) override; |
| 48 void GetPermissionStatus( | 46 void GetPermissionStatus( |
| 49 BackgroundSyncPeriodicity periodicity, | 47 BackgroundSyncPeriodicity periodicity, |
| 50 int64_t sw_registration_id, | 48 int64_t sw_registration_id, |
| 51 const GetPermissionStatusCallback& callback) override; | 49 const GetPermissionStatusCallback& callback) override; |
| 50 void TrackRegistration(SyncRegistrationPtr sync_registration) override; | |
| 51 void ReleaseRegistration(int64_t sync_id) override; | |
| 52 | 52 |
| 53 void OnRegisterResult(const RegisterCallback& callback, | 53 void OnRegisterResult(const RegisterCallback& callback, |
| 54 BackgroundSyncStatus status, | 54 BackgroundSyncStatus status, |
| 55 const BackgroundSyncRegistration& result); | 55 scoped_ptr<BackgroundSyncRegistrationHandle> result); |
| 56 void OnUnregisterResult(const UnregisterCallback& callback, | 56 void OnUnregisterResult(const UnregisterCallback& callback, |
| 57 BackgroundSyncStatus status); | 57 BackgroundSyncStatus status); |
| 58 void OnGetRegistrationsResult( | 58 void OnGetRegistrationsResult( |
| 59 const GetRegistrationsCallback& callback, | 59 const GetRegistrationsCallback& callback, |
| 60 BackgroundSyncStatus status, | 60 BackgroundSyncStatus status, |
| 61 const std::vector<BackgroundSyncRegistration>& result); | 61 scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>> result); |
| 62 | 62 |
| 63 // Called when an error is detected on binding_. | 63 // Called when an error is detected on binding_. |
| 64 void OnConnectionError(); | 64 void OnConnectionError(); |
|
michaeln
2015/08/21 02:39:24
I had a quick chat with rockot about how to manage
jkarlin
2015/08/25 17:32:58
Right. If the renderer dies this gets called (whic
| |
| 65 | 65 |
| 66 // background_sync_context_ owns this. | 66 // background_sync_context_ owns this. |
| 67 BackgroundSyncContextImpl* background_sync_context_; | 67 BackgroundSyncContextImpl* background_sync_context_; |
| 68 | 68 |
| 69 mojo::Binding<BackgroundSyncService> binding_; | 69 mojo::Binding<BackgroundSyncService> binding_; |
| 70 | 70 |
| 71 // The registrations that the client might reference. | |
| 72 IDMap<BackgroundSyncRegistrationHandle, IDMapOwnPointer> | |
| 73 hosted_registrations_; | |
|
michaeln
2015/08/21 02:39:24
The terms 'host' and 'registration' are both somew
jkarlin
2015/08/25 17:32:58
Refactored to active_handles_.
Not sure I want to
| |
| 74 | |
| 71 base::WeakPtrFactory<BackgroundSyncServiceImpl> weak_ptr_factory_; | 75 base::WeakPtrFactory<BackgroundSyncServiceImpl> weak_ptr_factory_; |
| 72 | 76 |
| 73 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncServiceImpl); | 77 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncServiceImpl); |
| 74 }; | 78 }; |
| 75 | 79 |
| 76 } // namespace content | 80 } // namespace content |
| 77 | 81 |
| 78 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_ | 82 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_ |
| OLD | NEW |