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

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: Rebase 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 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,
michaeln 2015/08/28 02:53:11 int handle_id?
jkarlin 2015/09/02 23:51:41 Done.
38 const mojo::String& tag,
39 int64_t sw_registration_id, 37 int64_t sw_registration_id,
michaeln 2015/08/28 02:53:11 is sw_registration_id needed, is handle_id not suf
jkarlin 2015/09/02 23:51:41 Acknowledged.
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 DuplicateRegistrationHandle(
51 int64_t handle_id,
michaeln 2015/08/28 02:53:11 int to match BackgroundSyncRegistrationHandle::Han
jkarlin 2015/09/02 23:51:40 Done.
52 int64_t service_worker_registration_id,
michaeln 2015/08/28 02:53:11 is service_worker_registration_id needed?
jkarlin 2015/09/02 23:51:41 Done.
53 const DuplicateRegistrationHandleCallback& callback) override;
54 void ReleaseRegistration(int64_t handle_id) override;
52 55
53 void OnRegisterResult(const RegisterCallback& callback, 56 void OnRegisterResult(const RegisterCallback& callback,
54 BackgroundSyncStatus status, 57 BackgroundSyncStatus status,
55 const BackgroundSyncRegistration& result); 58 scoped_ptr<BackgroundSyncRegistrationHandle> result);
56 void OnUnregisterResult(const UnregisterCallback& callback, 59 void OnUnregisterResult(const UnregisterCallback& callback,
57 BackgroundSyncStatus status); 60 BackgroundSyncStatus status);
58 void OnGetRegistrationsResult( 61 void OnGetRegistrationsResult(
59 const GetRegistrationsCallback& callback, 62 const GetRegistrationsCallback& callback,
60 BackgroundSyncStatus status, 63 BackgroundSyncStatus status,
61 const std::vector<BackgroundSyncRegistration>& result); 64 scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>> result);
62 65
63 // Called when an error is detected on binding_. 66 // Called when an error is detected on binding_.
64 void OnConnectionError(); 67 void OnConnectionError();
65 68
66 // background_sync_context_ owns this. 69 // background_sync_context_ owns this.
67 BackgroundSyncContextImpl* background_sync_context_; 70 BackgroundSyncContextImpl* background_sync_context_;
68 71
69 mojo::Binding<BackgroundSyncService> binding_; 72 mojo::Binding<BackgroundSyncService> binding_;
70 73
74 // The registrations that the client might reference.
75 IDMap<BackgroundSyncRegistrationHandle, IDMapOwnPointer> active_handles_;
76
71 base::WeakPtrFactory<BackgroundSyncServiceImpl> weak_ptr_factory_; 77 base::WeakPtrFactory<BackgroundSyncServiceImpl> weak_ptr_factory_;
72 78
73 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncServiceImpl); 79 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncServiceImpl);
74 }; 80 };
75 81
76 } // namespace content 82 } // namespace content
77 83
78 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_ 84 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698