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

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

Issue 1617143002: Remove "push" button from service worker internals UI. (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
« no previous file with comments | « content/browser/service_worker/service_worker_internals_ui.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 scoped_refptr<ServiceWorkerVersion> version = 83 scoped_refptr<ServiceWorkerVersion> version =
84 context->GetLiveVersion(version_id); 84 context->GetLiveVersion(version_id);
85 if (!version.get()) { 85 if (!version.get()) {
86 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND); 86 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND);
87 return; 87 return;
88 } 88 }
89 (*version.get().*method)(callback); 89 (*version.get().*method)(callback);
90 } 90 }
91 91
92 void DispatchPushEventWithVersionID(
93 scoped_refptr<ServiceWorkerContextWrapper> context,
94 int64_t version_id,
95 const ServiceWorkerInternalsUI::StatusCallback& callback) {
96 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
97 BrowserThread::PostTask(
98 BrowserThread::IO,
99 FROM_HERE,
100 base::Bind(DispatchPushEventWithVersionID,
101 context,
102 version_id,
103 callback));
104 return;
105 }
106
107 scoped_refptr<ServiceWorkerVersion> version =
108 context->GetLiveVersion(version_id);
109 if (!version.get()) {
110 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND);
111 return;
112 }
113 std::string data = "Test push message from ServiceWorkerInternals.";
114 version->DispatchPushEvent(callback, data);
115 }
116
117 void UpdateVersionInfo(const ServiceWorkerVersionInfo& version, 92 void UpdateVersionInfo(const ServiceWorkerVersionInfo& version,
118 DictionaryValue* info) { 93 DictionaryValue* info) {
119 switch (version.running_status) { 94 switch (version.running_status) {
120 case ServiceWorkerVersion::STOPPED: 95 case ServiceWorkerVersion::STOPPED:
121 info->SetString("running_status", "STOPPED"); 96 info->SetString("running_status", "STOPPED");
122 break; 97 break;
123 case ServiceWorkerVersion::STARTING: 98 case ServiceWorkerVersion::STARTING:
124 info->SetString("running_status", "STARTING"); 99 info->SetString("running_status", "STARTING");
125 break; 100 break;
126 case ServiceWorkerVersion::RUNNING: 101 case ServiceWorkerVersion::RUNNING:
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 web_ui->RegisterMessageCallback( 326 web_ui->RegisterMessageCallback(
352 "getAllRegistrations", 327 "getAllRegistrations",
353 base::Bind(&ServiceWorkerInternalsUI::GetAllRegistrations, 328 base::Bind(&ServiceWorkerInternalsUI::GetAllRegistrations,
354 base::Unretained(this))); 329 base::Unretained(this)));
355 web_ui->RegisterMessageCallback( 330 web_ui->RegisterMessageCallback(
356 "stop", 331 "stop",
357 base::Bind(&ServiceWorkerInternalsUI::CallServiceWorkerVersionMethod, 332 base::Bind(&ServiceWorkerInternalsUI::CallServiceWorkerVersionMethod,
358 base::Unretained(this), 333 base::Unretained(this),
359 &ServiceWorkerVersion::StopWorker)); 334 &ServiceWorkerVersion::StopWorker));
360 web_ui->RegisterMessageCallback( 335 web_ui->RegisterMessageCallback(
361 "push",
362 base::Bind(&ServiceWorkerInternalsUI::DispatchPushEvent,
363 base::Unretained(this)));
364 web_ui->RegisterMessageCallback(
365 "inspect", 336 "inspect",
366 base::Bind(&ServiceWorkerInternalsUI::InspectWorker, 337 base::Bind(&ServiceWorkerInternalsUI::InspectWorker,
367 base::Unretained(this))); 338 base::Unretained(this)));
368 web_ui->RegisterMessageCallback( 339 web_ui->RegisterMessageCallback(
369 "unregister", 340 "unregister",
370 base::Bind(&ServiceWorkerInternalsUI::Unregister, 341 base::Bind(&ServiceWorkerInternalsUI::Unregister,
371 base::Unretained(this))); 342 base::Unretained(this)));
372 web_ui->RegisterMessageCallback( 343 web_ui->RegisterMessageCallback(
373 "start", 344 "start",
374 base::Bind(&ServiceWorkerInternalsUI::StartWorker, 345 base::Bind(&ServiceWorkerInternalsUI::StartWorker,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 !base::StringToInt64(version_id_string, &version_id)) { 474 !base::StringToInt64(version_id_string, &version_id)) {
504 return; 475 return;
505 } 476 }
506 477
507 base::Callback<void(ServiceWorkerStatusCode)> callback = 478 base::Callback<void(ServiceWorkerStatusCode)> callback =
508 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id); 479 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id);
509 CallServiceWorkerVersionMethodWithVersionID( 480 CallServiceWorkerVersionMethodWithVersionID(
510 method, context, version_id, callback); 481 method, context, version_id, callback);
511 } 482 }
512 483
513 void ServiceWorkerInternalsUI::DispatchPushEvent(
514 const ListValue* args) {
515 DCHECK_CURRENTLY_ON(BrowserThread::UI);
516 int callback_id;
517 int partition_id;
518 int64_t version_id = 0;
519 std::string version_id_string;
520 const DictionaryValue* cmd_args = NULL;
521 scoped_refptr<ServiceWorkerContextWrapper> context;
522 if (!args->GetInteger(0, &callback_id) ||
523 !args->GetDictionary(1, &cmd_args) ||
524 !cmd_args->GetInteger("partition_id", &partition_id) ||
525 !GetServiceWorkerContext(partition_id, &context) ||
526 !cmd_args->GetString("version_id", &version_id_string) ||
527 !base::StringToInt64(version_id_string, &version_id)) {
528 return;
529 }
530
531 base::Callback<void(ServiceWorkerStatusCode)> callback =
532 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id);
533 DispatchPushEventWithVersionID(context, version_id, callback);
534 }
535
536 void ServiceWorkerInternalsUI::InspectWorker(const ListValue* args) { 484 void ServiceWorkerInternalsUI::InspectWorker(const ListValue* args) {
537 DCHECK_CURRENTLY_ON(BrowserThread::UI); 485 DCHECK_CURRENTLY_ON(BrowserThread::UI);
538 int callback_id; 486 int callback_id;
539 const DictionaryValue* cmd_args = NULL; 487 const DictionaryValue* cmd_args = NULL;
540 int process_id = 0; 488 int process_id = 0;
541 int devtools_agent_route_id = 0; 489 int devtools_agent_route_id = 0;
542 if (!args->GetInteger(0, &callback_id) || 490 if (!args->GetInteger(0, &callback_id) ||
543 !args->GetDictionary(1, &cmd_args) || 491 !args->GetDictionary(1, &cmd_args) ||
544 !cmd_args->GetInteger("process_id", &process_id) || 492 !cmd_args->GetInteger("process_id", &process_id) ||
545 !cmd_args->GetInteger("devtools_agent_route_id", 493 !cmd_args->GetInteger("devtools_agent_route_id",
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 callback.Run(SERVICE_WORKER_ERROR_ABORT); 562 callback.Run(SERVICE_WORKER_ERROR_ABORT);
615 return; 563 return;
616 } 564 }
617 565
618 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here 566 // ServiceWorkerContextWrapper::UnregisterServiceWorker doesn't work here
619 // because that reduces a status code to boolean. 567 // because that reduces a status code to boolean.
620 context->context()->UnregisterServiceWorker(scope, callback); 568 context->context()->UnregisterServiceWorker(scope, callback);
621 } 569 }
622 570
623 } // namespace content 571 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_internals_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698