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

Side by Side Diff: content/renderer/background_sync/background_sync_client_impl.h

Issue 1171173002: [Background Sync] Use Mojo IPC to fire background sync events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add OWNERS and PRESUBMIT.py Created 5 years, 6 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
(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 // This class implements the mojo service for firing background sync events in a
17 // service worker thread. It is constructed and lives on the renderer main
18 // thread, but can dispatch to any worker thread to fire events.
19 // Return messages from the workers are rerouted to the main thread in order to
michaeln 2015/06/24 02:02:05 Routing everything, coming and going, thru the mai
iclelland 2015/06/24 14:29:30 It is, and I'd like to get rid of it
jkarlin 2015/06/24 14:38:09 Not sure I'm entirely following this. I think you
iclelland 2015/06/24 14:42:05 Right -- so in this case, we're moving *both* endp
20 // be sent back over the mojo message channel.
21 class CONTENT_EXPORT BackgroundSyncClientImpl
22 : public NON_EXPORTED_BASE(BackgroundSyncServiceClient) {
23 public:
24 static void Create(
25 const scoped_refptr<base::SingleThreadTaskRunner>&
26 main_thread_task_runner,
27 mojo::InterfaceRequest<BackgroundSyncServiceClient> request);
28
29 ~BackgroundSyncClientImpl() override;
30
31 private:
32 using SyncCallback = mojo::Callback<void(ServiceWorkerEventStatus)>;
33 explicit BackgroundSyncClientImpl(
34 const scoped_refptr<base::SingleThreadTaskRunner>&
35 main_thread_task_runner,
36 mojo::InterfaceRequest<BackgroundSyncServiceClient> request);
37
38 // BackgroundSyncClient methods:
39 void Sync(content::SyncRegistrationPtr registration,
40 int thread_id,
41 const SyncCallback& callback) override;
42
43 static void DispatchSyncOnWorkerThread(
44 const scoped_refptr<base::SingleThreadTaskRunner>&
45 main_thread_task_runner,
46 content::SyncRegistrationPtr event,
47 const SyncCallback& callback);
48 static void OnSyncCompleteOnWorkerThread(
49 const scoped_refptr<base::SingleThreadTaskRunner>&
50 main_thread_task_runner,
51 const SyncCallback& callback,
52 ServiceWorkerEventStatus status);
53 static void OnSyncCompleteOnMainThread(const SyncCallback& callback,
54 ServiceWorkerEventStatus status);
55
56 mojo::StrongBinding<BackgroundSyncServiceClient> binding_;
57
58 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
59
60 base::WeakPtrFactory<BackgroundSyncClientImpl> weak_ptr_factory_;
61
62 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncClientImpl);
63 };
64
65 } // namespace content
66
67 #endif // CONTENT_RENDERER_BACKGROUND_SYNC_BACKGROUND_SYNC_CLIENT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698