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

Unified Diff: content/browser/devtools/protocol/service_worker_handler.cc

Issue 1064523003: Add "emulate push event" button to ServiceWorkersView in DevTools [1/2 chromium] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/dispatchPushEvent/deliverPushMessage/ Created 5 years, 8 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
« no previous file with comments | « content/browser/devtools/protocol/service_worker_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/devtools/protocol/service_worker_handler.cc
diff --git a/content/browser/devtools/protocol/service_worker_handler.cc b/content/browser/devtools/protocol/service_worker_handler.cc
index b2ac98ae250a91751e46c56ed4f7386a32ee8bde..0ca092e26d9539708f7b81d0f17a0c2262286c15 100644
--- a/content/browser/devtools/protocol/service_worker_handler.cc
+++ b/content/browser/devtools/protocol/service_worker_handler.cc
@@ -23,6 +23,7 @@
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h"
+#include "content/public/common/push_messaging_status.h"
#include "url/gurl.h"
// Windows headers will redefine SendMessage.
@@ -42,6 +43,8 @@ void ResultNoOp(bool success) {
}
void StatusNoOp(ServiceWorkerStatusCode status) {
}
+void PushDeliveryNoOp(PushDeliveryStatus status) {
+}
const std::string GetVersionRunningStatusString(
content::ServiceWorkerVersion::RunningStatus running_status) {
@@ -356,6 +359,23 @@ Response ServiceWorkerHandler::SetDebugOnStart(bool debug_on_start) {
return Response::OK();
}
+Response ServiceWorkerHandler::DeliverPushMessage(
+ const std::string& origin,
+ const std::string& registration_id,
+ const std::string& data) {
+ if (!enabled_)
+ return Response::OK();
+ if (!render_frame_host_)
+ return CreateContextErrorResoponse();
+ int64 id = 0;
+ if (!base::StringToInt64(registration_id, &id))
+ return CreateInvalidVersionIdErrorResoponse();
+ BrowserContext::DeliverPushMessage(
+ render_frame_host_->GetProcess()->GetBrowserContext(), GURL(origin), id,
+ data, base::Bind(&PushDeliveryNoOp));
+ return Response::OK();
+}
+
void ServiceWorkerHandler::OpenNewDevToolsWindow(int process_id,
int devtools_agent_route_id) {
scoped_refptr<DevToolsAgentHostImpl> agent_host(
« no previous file with comments | « content/browser/devtools/protocol/service_worker_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698