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

Side by Side Diff: content/browser/service_worker/service_worker_internals_ui.cc

Issue 1579413004: Move push event dispatching out of ServiceWorkerVersion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "content/browser/service_worker/service_worker_internals_ui.h" 5 #include "content/browser/service_worker/service_worker_internals_ui.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "content/browser/devtools/devtools_agent_host_impl.h" 16 #include "content/browser/devtools/devtools_agent_host_impl.h"
17 #include "content/browser/devtools/service_worker_devtools_manager.h" 17 #include "content/browser/devtools/service_worker_devtools_manager.h"
18 #include "content/browser/push_messaging/push_messaging_router.h"
18 #include "content/browser/service_worker/service_worker_context_observer.h" 19 #include "content/browser/service_worker/service_worker_context_observer.h"
19 #include "content/browser/service_worker/service_worker_context_wrapper.h" 20 #include "content/browser/service_worker/service_worker_context_wrapper.h"
20 #include "content/browser/service_worker/service_worker_registration.h" 21 #include "content/browser/service_worker/service_worker_registration.h"
21 #include "content/browser/service_worker/service_worker_version.h" 22 #include "content/browser/service_worker/service_worker_version.h"
22 #include "content/grit/content_resources.h" 23 #include "content/grit/content_resources.h"
23 #include "content/public/browser/browser_context.h" 24 #include "content/public/browser/browser_context.h"
24 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/storage_partition.h" 26 #include "content/public/browser/storage_partition.h"
26 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
27 #include "content/public/browser/web_ui.h" 28 #include "content/public/browser/web_ui.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 return; 105 return;
105 } 106 }
106 107
107 scoped_refptr<ServiceWorkerVersion> version = 108 scoped_refptr<ServiceWorkerVersion> version =
108 context->GetLiveVersion(version_id); 109 context->GetLiveVersion(version_id);
109 if (!version.get()) { 110 if (!version.get()) {
110 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND); 111 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND);
111 return; 112 return;
112 } 113 }
113 std::string data = "Test push message from ServiceWorkerInternals."; 114 std::string data = "Test push message from ServiceWorkerInternals.";
114 version->DispatchPushEvent(callback, data); 115 PushMessagingRouter::DeliverMessageToWorker(version, data, callback);
115 } 116 }
116 117
117 void UpdateVersionInfo(const ServiceWorkerVersionInfo& version, 118 void UpdateVersionInfo(const ServiceWorkerVersionInfo& version,
118 DictionaryValue* info) { 119 DictionaryValue* info) {
119 switch (version.running_status) { 120 switch (version.running_status) {
120 case ServiceWorkerVersion::STOPPED: 121 case ServiceWorkerVersion::STOPPED:
121 info->SetString("running_status", "STOPPED"); 122 info->SetString("running_status", "STOPPED");
122 break; 123 break;
123 case ServiceWorkerVersion::STARTING: 124 case ServiceWorkerVersion::STARTING:
124 info->SetString("running_status", "STARTING"); 125 info->SetString("running_status", "STARTING");
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 callback.Run(SERVICE_WORKER_ERROR_ABORT); 615 callback.Run(SERVICE_WORKER_ERROR_ABORT);
615 return; 616 return;
616 } 617 }
617 618
618 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here 619 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here
619 // because that reduces a status code to boolean. 620 // because that reduces a status code to boolean.
620 context->context()->UnregisterServiceWorker(scope, callback); 621 context->context()->UnregisterServiceWorker(scope, callback);
621 } 622 }
622 623
623 } // namespace content 624 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698