OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_BACKGROUND_SYNC_BACKGROUND_SYNC_CLIENT_IMPL_H_ |
| 6 #define CONTENT_RENDERER_BACKGROUND_SYNC_BACKGROUND_SYNC_CLIENT_IMPL_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "content/common/background_sync_service.mojom.h" |
| 11 #include "content/common/content_export.h" |
| 12 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 using SyncCallback = mojo::Callback<void(BackgroundSyncEventStatus)>; |
| 17 |
| 18 class CONTENT_EXPORT BackgroundSyncClientImpl |
| 19 : public NON_EXPORTED_BASE(BackgroundSyncServiceClient) { |
| 20 public: |
| 21 static void Create( |
| 22 const scoped_refptr<base::SingleThreadTaskRunner>& |
| 23 main_thread_task_runner, |
| 24 mojo::InterfaceRequest<BackgroundSyncServiceClient> request); |
| 25 |
| 26 ~BackgroundSyncClientImpl() override; |
| 27 |
| 28 private: |
| 29 explicit BackgroundSyncClientImpl( |
| 30 const scoped_refptr<base::SingleThreadTaskRunner>& |
| 31 main_thread_task_runner, |
| 32 mojo::InterfaceRequest<BackgroundSyncServiceClient> request); |
| 33 |
| 34 // BackgroundSyncClient methods: |
| 35 void Sync(content::SyncRegistrationPtr registration, |
| 36 int thread_id, |
| 37 const SyncCallback& callback) override; |
| 38 |
| 39 void DispatchSyncForWorker(content::SyncRegistrationPtr event, |
| 40 const SyncCallback& callback); |
| 41 void OnSyncComplete(const SyncCallback& callback, |
| 42 BackgroundSyncEventStatus status); |
| 43 |
| 44 mojo::StrongBinding<BackgroundSyncServiceClient> binding_; |
| 45 |
| 46 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 47 |
| 48 base::WeakPtrFactory<BackgroundSyncClientImpl> weak_ptr_factory_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncClientImpl); |
| 51 }; |
| 52 |
| 53 } // namespace content |
| 54 |
| 55 #endif // CONTENT_RENDERER_BACKGROUND_SYNC_BACKGROUND_SYNC_CLIENT_IMPL_H_ |
OLD | NEW |