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

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

Issue 2506263005: Prevent a service worker from keeping itself alive by self postMessage. (Closed)
Patch Set: rebase Created 4 years 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 565
566 int request_id = pending_requests_.Add(base::MakeUnique<PendingRequest>( 566 int request_id = pending_requests_.Add(base::MakeUnique<PendingRequest>(
567 error_callback, base::Time::Now(), tick_clock_->NowTicks(), event_type)); 567 error_callback, base::Time::Now(), tick_clock_->NowTicks(), event_type));
568 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", "ServiceWorkerVersion::Request", 568 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", "ServiceWorkerVersion::Request",
569 pending_requests_.Lookup(request_id), "Request id", 569 pending_requests_.Lookup(request_id), "Request id",
570 request_id, "Event type", 570 request_id, "Event type",
571 ServiceWorkerMetrics::EventTypeToString(event_type)); 571 ServiceWorkerMetrics::EventTypeToString(event_type));
572 base::TimeTicks expiration_time = tick_clock_->NowTicks() + timeout; 572 base::TimeTicks expiration_time = tick_clock_->NowTicks() + timeout;
573 timeout_queue_.push( 573 timeout_queue_.push(
574 RequestInfo(request_id, event_type, expiration_time, timeout_behavior)); 574 RequestInfo(request_id, event_type, expiration_time, timeout_behavior));
575 if (expiration_time > max_request_expiration_time_)
576 max_request_expiration_time_ = expiration_time;
575 return request_id; 577 return request_id;
576 } 578 }
577 579
578 bool ServiceWorkerVersion::StartExternalRequest( 580 bool ServiceWorkerVersion::StartExternalRequest(
579 const std::string& request_uuid) { 581 const std::string& request_uuid) {
580 // It's possible that the renderer is lying or the version started stopping 582 // It's possible that the renderer is lying or the version started stopping
581 // right around the time of the IPC. 583 // right around the time of the IPC.
582 if (running_status() != EmbeddedWorkerStatus::RUNNING) 584 if (running_status() != EmbeddedWorkerStatus::RUNNING)
583 return false; 585 return false;
584 586
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 1879
1878 void ServiceWorkerVersion::CleanUpExternalRequest( 1880 void ServiceWorkerVersion::CleanUpExternalRequest(
1879 const std::string& request_uuid, 1881 const std::string& request_uuid,
1880 ServiceWorkerStatusCode status) { 1882 ServiceWorkerStatusCode status) {
1881 if (status == SERVICE_WORKER_OK) 1883 if (status == SERVICE_WORKER_OK)
1882 return; 1884 return;
1883 external_request_uuid_to_request_id_.erase(request_uuid); 1885 external_request_uuid_to_request_id_.erase(request_uuid);
1884 } 1886 }
1885 1887
1886 } // namespace content 1888 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698