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

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

Issue 2034663002: ServiceWorker: Keep the worker alive until FetchEvent.waitUntil settles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Separate DispathEvent into two part Created 4 years, 6 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 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 <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 if (running_status() == RUNNING) { 559 if (running_status() == RUNNING) {
560 DCHECK(start_callbacks_.empty()); 560 DCHECK(start_callbacks_.empty());
561 task.Run(); 561 task.Run();
562 return; 562 return;
563 } 563 }
564 StartWorker(purpose, 564 StartWorker(purpose,
565 base::Bind(&RunTaskAfterStartWorker, weak_factory_.GetWeakPtr(), 565 base::Bind(&RunTaskAfterStartWorker, weak_factory_.GetWeakPtr(),
566 error_callback, task)); 566 error_callback, task));
567 } 567 }
568 568
569 ServiceWorkerStatusCode ServiceWorkerVersion::DispatchEvent(
570 const IPC::Message& message) {
571 DCHECK_EQ(RUNNING, running_status());
572 return embedded_worker_->SendMessage(message);
573 }
574
569 void ServiceWorkerVersion::AddControllee( 575 void ServiceWorkerVersion::AddControllee(
570 ServiceWorkerProviderHost* provider_host) { 576 ServiceWorkerProviderHost* provider_host) {
571 const std::string& uuid = provider_host->client_uuid(); 577 const std::string& uuid = provider_host->client_uuid();
572 CHECK(!provider_host->client_uuid().empty()); 578 CHECK(!provider_host->client_uuid().empty());
573 DCHECK(!ContainsKey(controllee_map_, uuid)); 579 DCHECK(!ContainsKey(controllee_map_, uuid));
574 controllee_map_[uuid] = provider_host; 580 controllee_map_[uuid] = provider_host;
575 // Keep the worker alive a bit longer right after a new controllee is added. 581 // Keep the worker alive a bit longer right after a new controllee is added.
576 RestartTick(&idle_time_); 582 RestartTick(&idle_time_);
577 FOR_EACH_OBSERVER(Listener, listeners_, 583 FOR_EACH_OBSERVER(Listener, listeners_,
578 OnControlleeAdded(this, provider_host)); 584 OnControlleeAdded(this, provider_host));
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 void ServiceWorkerVersion::OnBeginEvent() { 1709 void ServiceWorkerVersion::OnBeginEvent() {
1704 if (should_exclude_from_uma_ || running_status() != RUNNING || 1710 if (should_exclude_from_uma_ || running_status() != RUNNING ||
1705 idle_time_.is_null()) { 1711 idle_time_.is_null()) {
1706 return; 1712 return;
1707 } 1713 }
1708 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - 1714 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() -
1709 idle_time_); 1715 idle_time_);
1710 } 1716 }
1711 1717
1712 } // namespace content 1718 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698