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

Unified Diff: content/child/push_messaging/push_provider.h

Issue 2690203003: Convert push_messaging IPC msgs into mojo interfaces (Closed)
Patch Set: remove DCHECK(ChildThreadImpl::Current()) Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/child/push_messaging/push_provider.h
diff --git a/content/child/push_messaging/push_provider.h b/content/child/push_messaging/push_provider.h
index 9d554fe8ed61251204077ffa083030dd0ec1a00d..607f7c6fe75bceb9fb69aaa5a17841353066c48e 100644
--- a/content/child/push_messaging/push_provider.h
+++ b/content/child/push_messaging/push_provider.h
@@ -11,10 +11,9 @@
#include <string>
#include <vector>
-#include "base/id_map.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "content/child/push_messaging/push_dispatcher.h"
+#include "content/common/push_messaging.mojom.h"
#include "content/public/child/worker_thread.h"
#include "content/public/common/push_messaging_status.h"
#include "third_party/WebKit/public/platform/modules/push_messaging/WebPushError.h"
@@ -28,7 +27,6 @@ struct WebPushSubscriptionOptions;
namespace content {
-class ThreadSafeSender;
struct PushSubscriptionOptions;
blink::WebPushError PushRegistrationStatusToWebPushError(
@@ -39,11 +37,10 @@ class PushProvider : public blink::WebPushProvider,
public:
~PushProvider() override;
- // The |thread_safe_sender| and |push_dispatcher| are used if calling this
- // leads to construction.
static PushProvider* ThreadSpecificInstance(
- ThreadSafeSender* thread_safe_sender,
- PushDispatcher* push_dispatcher);
+ scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner);
Peter Beverloo 2017/02/16 16:08:33 nit: const&
ke.he 2017/02/17 08:22:33 Done.
+
+ static void BindRequest(mojom::PushMessagingRequest request);
Peter Beverloo 2017/02/16 16:08:32 nit: this can be private
ke.he 2017/02/17 08:22:38 Done.
// WorkerThread::Observer implementation.
void WillStopCurrentWorkerThread() override;
@@ -65,53 +62,40 @@ class PushProvider : public blink::WebPushProvider,
std::unique_ptr<blink::WebPushPermissionStatusCallbacks> callbacks)
override;
- // Called by the PushDispatcher.
- bool OnMessageReceived(const IPC::Message& message);
-
private:
- PushProvider(ThreadSafeSender* thread_safe_sender,
- PushDispatcher* push_dispatcher);
-
- // IPC message handlers.
- void OnSubscribeFromWorkerSuccess(int request_id,
- const GURL& endpoint,
- const PushSubscriptionOptions& options,
- const std::vector<uint8_t>& p256dh,
- const std::vector<uint8_t>& auth);
- void OnSubscribeFromWorkerError(int request_id,
- PushRegistrationStatus status);
- void OnUnsubscribeSuccess(int request_id, bool did_unsubscribe);
- void OnUnsubscribeError(int request_id,
- blink::WebPushError::ErrorType error_type,
- const std::string& error_message);
- void OnGetSubscriptionSuccess(int request_id,
- const GURL& endpoint,
- const PushSubscriptionOptions& options,
- const std::vector<uint8_t>& p256dh,
- const std::vector<uint8_t>& auth);
- void OnGetSubscriptionError(int request_id, PushGetRegistrationStatus status);
- void OnGetPermissionStatusSuccess(int request_id,
- blink::WebPushPermissionStatus status);
- void OnGetPermissionStatusError(int request_id,
- blink::WebPushError::ErrorType error);
-
- scoped_refptr<ThreadSafeSender> thread_safe_sender_;
- scoped_refptr<PushDispatcher> push_dispatcher_;
-
- // Stores the subscription callbacks with their request ids. This class owns
- // the callbacks.
- IDMap<std::unique_ptr<blink::WebPushSubscriptionCallbacks>>
- subscription_callbacks_;
-
- // Stores the permission status callbacks with their request ids. This class
- // owns the callbacks.
- IDMap<std::unique_ptr<blink::WebPushPermissionStatusCallbacks>>
- permission_status_callbacks_;
-
- // Stores the unsubscription callbacks with their request ids. This class owns
- // the callbacks.
- IDMap<std::unique_ptr<blink::WebPushUnsubscribeCallbacks>>
- unsubscribe_callbacks_;
+ explicit PushProvider(
+ scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner);
Peter Beverloo 2017/02/16 16:08:33 nit: const&
ke.he 2017/02/17 08:22:34 Done.
+
+ void SubscribeCallback(
Peter Beverloo 2017/02/16 16:08:33 nit: I have a mild preference of naming these DidF
ke.he 2017/02/17 08:22:37 Yeah, I'll rename it in later. Record this in 6933
+ std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks,
+ content::PushRegistrationStatus status,
+ const base::Optional<GURL>& endpoint,
+ const base::Optional<content::PushSubscriptionOptions>& options,
+ const base::Optional<std::vector<uint8_t>>& p256dh,
+ const base::Optional<std::vector<uint8_t>>& auth);
+
+ void UnsubscribeCallback(
+ std::unique_ptr<blink::WebPushUnsubscribeCallbacks> callbacks,
+ bool is_success,
+ bool did_unsubscribe,
+ blink::WebPushError::ErrorType error_type,
+ const base::Optional<std::string>& error_message);
+
+ void GetSubscriptionCallback(
+ std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks,
+ content::PushGetRegistrationStatus status,
+ const base::Optional<GURL>& endpoint,
+ const base::Optional<content::PushSubscriptionOptions>& options,
+ const base::Optional<std::vector<uint8_t>>& p256dh,
+ const base::Optional<std::vector<uint8_t>>& auth);
Peter Beverloo 2017/02/16 16:08:33 Also as a potential follow-up, we can extract {end
ke.he 2017/02/17 08:22:34 tracked by 693366.
+
+ void GetPermissionStatusCallback(
+ std::unique_ptr<blink::WebPushPermissionStatusCallbacks> callbacks,
+ bool is_success,
+ blink::WebPushPermissionStatus status,
+ blink::WebPushError::ErrorType error);
+
+ mojom::PushMessagingPtr push_messaging_;
Peter Beverloo 2017/02/16 16:08:33 nit: push_messaging_manager_
ke.he 2017/02/17 08:22:35 Done.
DISALLOW_COPY_AND_ASSIGN(PushProvider);
};

Powered by Google App Engine
This is Rietveld 408576698