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

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

Issue 1584653009: Change RunAfterStartWorker to not start the worker if it is already running. (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_version.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_version.h" 5 #include "content/browser/service_worker/service_worker_version.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 PendingRequest<StatusCallback>* request = custom_requests_.Lookup(request_id); 499 PendingRequest<StatusCallback>* request = custom_requests_.Lookup(request_id);
500 if (!request) 500 if (!request)
501 return false; 501 return false;
502 ServiceWorkerMetrics::RecordEventDuration( 502 ServiceWorkerMetrics::RecordEventDuration(
503 request->event_type, base::TimeTicks::Now() - request->start_time); 503 request->event_type, base::TimeTicks::Now() - request->start_time);
504 RemoveCallbackAndStopIfRedundant(&custom_requests_, request_id); 504 RemoveCallbackAndStopIfRedundant(&custom_requests_, request_id);
505 return true; 505 return true;
506 } 506 }
507 507
508 void ServiceWorkerVersion::RunAfterStartWorker( 508 void ServiceWorkerVersion::RunAfterStartWorker(
509 const StatusCallback& error_callback, 509 const base::Closure& task,
510 const base::Closure& task) { 510 const StatusCallback& error_callback) {
511 if (running_status() == RUNNING) {
512 RunSoon(task);
johnme 2016/01/18 19:06:51 Using RunSoon (and hence PostTask) introduces a ra
nhiroki 2016/01/19 01:36:39 Or, we could immediately run the callback when the
Marijn Kruisselbrink 2016/01/19 22:49:15 Normally I don't like methods that sometimes call
513 return;
514 }
511 StartWorker(base::Bind(&RunTaskAfterStartWorker, weak_factory_.GetWeakPtr(), 515 StartWorker(base::Bind(&RunTaskAfterStartWorker, weak_factory_.GetWeakPtr(),
512 error_callback, task)); 516 error_callback, task));
nhiroki 2016/01/19 01:36:39 You may also want to swap arguments of RunTaskAfte
Marijn Kruisselbrink 2016/01/19 22:49:15 I could, but I don't think it's worth it yet (give
513 } 517 }
514 518
515 void ServiceWorkerVersion::DispatchMessageEvent( 519 void ServiceWorkerVersion::DispatchMessageEvent(
516 const base::string16& message, 520 const base::string16& message,
517 const std::vector<TransferredMessagePort>& sent_message_ports, 521 const std::vector<TransferredMessagePort>& sent_message_ports,
518 const StatusCallback& callback) { 522 const StatusCallback& callback) {
519 for (const TransferredMessagePort& port : sent_message_ports) { 523 for (const TransferredMessagePort& port : sent_message_ports) {
520 MessagePortService::GetInstance()->HoldMessages(port.id); 524 MessagePortService::GetInstance()->HoldMessages(port.id);
521 } 525 }
522 526
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 void ServiceWorkerVersion::OnBeginEvent() { 1982 void ServiceWorkerVersion::OnBeginEvent() {
1979 if (should_exclude_from_uma_ || running_status() != RUNNING || 1983 if (should_exclude_from_uma_ || running_status() != RUNNING ||
1980 idle_time_.is_null()) { 1984 idle_time_.is_null()) {
1981 return; 1985 return;
1982 } 1986 }
1983 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - 1987 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() -
1984 idle_time_); 1988 idle_time_);
1985 } 1989 }
1986 1990
1987 } // namespace content 1991 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_version.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698