Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: content/browser/background_sync/background_sync_service_impl.h

Issue 1282013004: BackgroundSyncManager tracks client registrations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed test Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 bool requested_from_service_worker, 34 bool requested_from_service_worker,
36 const RegisterCallback& callback) override; 35 const RegisterCallback& callback) override;
37 void Unregister(BackgroundSyncPeriodicity periodicity, 36 void Unregister(BackgroundSyncPeriodicity periodicity,
38 int64_t id, 37 BackgroundSyncRegistrationHandle::HandleId handle_id,
39 const mojo::String& tag,
40 int64_t sw_registration_id, 38 int64_t sw_registration_id,
41 const UnregisterCallback& callback) override; 39 const UnregisterCallback& callback) override;
42 void GetRegistration(BackgroundSyncPeriodicity periodicity, 40 void GetRegistration(BackgroundSyncPeriodicity periodicity,
43 const mojo::String& tag, 41 const mojo::String& tag,
44 int64_t sw_registration_id, 42 int64_t sw_registration_id,
45 const GetRegistrationCallback& callback) override; 43 const GetRegistrationCallback& callback) override;
46 void GetRegistrations(BackgroundSyncPeriodicity periodicity, 44 void GetRegistrations(BackgroundSyncPeriodicity periodicity,
47 int64_t sw_registration_id, 45 int64_t sw_registration_id,
48 const GetRegistrationsCallback& callback) override; 46 const GetRegistrationsCallback& callback) override;
49 void GetPermissionStatus( 47 void GetPermissionStatus(
50 BackgroundSyncPeriodicity periodicity, 48 BackgroundSyncPeriodicity periodicity,
51 int64_t sw_registration_id, 49 int64_t sw_registration_id,
52 const GetPermissionStatusCallback& callback) override; 50 const GetPermissionStatusCallback& callback) override;
51 void DuplicateRegistrationHandle(
52 BackgroundSyncRegistrationHandle::HandleId handle_id,
53 const DuplicateRegistrationHandleCallback& callback) override;
54 void ReleaseRegistration(
55 BackgroundSyncRegistrationHandle::HandleId handle_id) override;
53 56
54 void OnRegisterResult(const RegisterCallback& callback, 57 void OnRegisterResult(const RegisterCallback& callback,
55 BackgroundSyncStatus status, 58 BackgroundSyncStatus status,
56 const BackgroundSyncRegistration& result); 59 scoped_ptr<BackgroundSyncRegistrationHandle> result);
57 void OnUnregisterResult(const UnregisterCallback& callback, 60 void OnUnregisterResult(const UnregisterCallback& callback,
58 BackgroundSyncStatus status); 61 BackgroundSyncStatus status);
59 void OnGetRegistrationsResult( 62 void OnGetRegistrationsResult(
60 const GetRegistrationsCallback& callback, 63 const GetRegistrationsCallback& callback,
61 BackgroundSyncStatus status, 64 BackgroundSyncStatus status,
62 const std::vector<BackgroundSyncRegistration>& result); 65 scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>> result);
63 66
64 // Called when an error is detected on binding_. 67 // Called when an error is detected on binding_.
65 void OnConnectionError(); 68 void OnConnectionError();
66 69
67 // background_sync_context_ owns this. 70 // background_sync_context_ owns this.
68 BackgroundSyncContextImpl* background_sync_context_; 71 BackgroundSyncContextImpl* background_sync_context_;
69 72
70 mojo::Binding<BackgroundSyncService> binding_; 73 mojo::Binding<BackgroundSyncService> binding_;
71 74
75 // The registrations that the client might reference.
76 IDMap<BackgroundSyncRegistrationHandle, IDMapOwnPointer> active_handles_;
77
72 base::WeakPtrFactory<BackgroundSyncServiceImpl> weak_ptr_factory_; 78 base::WeakPtrFactory<BackgroundSyncServiceImpl> weak_ptr_factory_;
73 79
74 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncServiceImpl); 80 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncServiceImpl);
75 }; 81 };
76 82
77 } // namespace content 83 } // namespace content
78 84
79 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_ 85 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698