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

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

Issue 1029553002: [DevTools] Introduce Unregister/Start/Stop/Inspect buttons to ServiceWorkersView [1/2 chromium] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix indent Created 5 years, 9 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_context_wrapper.cc ('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 <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 BrowserThread::PostTask( 115 BrowserThread::PostTask(
116 BrowserThread::IO, 116 BrowserThread::IO,
117 FROM_HERE, 117 FROM_HERE,
118 base::Bind(UnregisterWithScope, context, scope, callback)); 118 base::Bind(UnregisterWithScope, context, scope, callback));
119 return; 119 return;
120 } 120 }
121 DCHECK_CURRENTLY_ON(BrowserThread::IO); 121 DCHECK_CURRENTLY_ON(BrowserThread::IO);
122 context->context()->UnregisterServiceWorker(scope, callback); 122 context->context()->UnregisterServiceWorker(scope, callback);
123 } 123 }
124 124
125 void WorkerStarted(const scoped_refptr<ServiceWorkerRegistration>& registration,
126 const ServiceWorkerInternalsUI::StatusCallback& callback,
127 ServiceWorkerStatusCode status) {
128 callback.Run(status);
129 }
130
131 void StartActiveWorker(
132 const ServiceWorkerInternalsUI::StatusCallback& callback,
133 ServiceWorkerStatusCode status,
134 const scoped_refptr<ServiceWorkerRegistration>& registration) {
135 DCHECK_CURRENTLY_ON(BrowserThread::IO);
136 if (status == SERVICE_WORKER_OK) {
137 // Pass the reference of |registration| to WorkerStarted callback to prevent
138 // it from being deleted while starting the worker. If the refcount of
139 // |registration| is 1, it will be deleted after WorkerStarted is called.
140 registration->active_version()->StartWorker(
141 base::Bind(WorkerStarted, registration, callback));
142 return;
143 }
144 callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND);
145 }
146
147 void FindRegistrationForPattern( 125 void FindRegistrationForPattern(
148 scoped_refptr<ServiceWorkerContextWrapper> context, 126 scoped_refptr<ServiceWorkerContextWrapper> context,
149 const GURL& scope, 127 const GURL& scope,
150 const ServiceWorkerStorage::FindRegistrationCallback callback) { 128 const ServiceWorkerStorage::FindRegistrationCallback callback) {
151 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 129 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
152 BrowserThread::PostTask( 130 BrowserThread::PostTask(
153 BrowserThread::IO, 131 BrowserThread::IO,
154 FROM_HERE, 132 FROM_HERE,
155 base::Bind(FindRegistrationForPattern, context, scope, callback)); 133 base::Bind(FindRegistrationForPattern, context, scope, callback));
156 return; 134 return;
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 std::string scope_string; 626 std::string scope_string;
649 const DictionaryValue* cmd_args = NULL; 627 const DictionaryValue* cmd_args = NULL;
650 scoped_refptr<ServiceWorkerContextWrapper> context; 628 scoped_refptr<ServiceWorkerContextWrapper> context;
651 if (!args->GetInteger(0, &callback_id) || 629 if (!args->GetInteger(0, &callback_id) ||
652 !args->GetDictionary(1, &cmd_args) || 630 !args->GetDictionary(1, &cmd_args) ||
653 !cmd_args->GetInteger("partition_id", &partition_id) || 631 !cmd_args->GetInteger("partition_id", &partition_id) ||
654 !GetServiceWorkerContext(partition_id, &context) || 632 !GetServiceWorkerContext(partition_id, &context) ||
655 !cmd_args->GetString("scope", &scope_string)) { 633 !cmd_args->GetString("scope", &scope_string)) {
656 return; 634 return;
657 } 635 }
658
659 base::Callback<void(ServiceWorkerStatusCode)> callback = 636 base::Callback<void(ServiceWorkerStatusCode)> callback =
660 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id); 637 base::Bind(OperationCompleteCallback, AsWeakPtr(), callback_id);
661 FindRegistrationForPattern( 638 context->StartServiceWorker(GURL(scope_string), callback);
662 context, GURL(scope_string), base::Bind(StartActiveWorker, callback));
663 } 639 }
664 640
665 } // namespace content 641 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_context_wrapper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698