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

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

Issue 912753002: Stop Service Workers that execute JavaScript for too long. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix timeout value Created 5 years, 10 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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 private: 309 private:
310 class GetClientDocumentsCallback; 310 class GetClientDocumentsCallback;
311 311
312 friend class base::RefCounted<ServiceWorkerVersion>; 312 friend class base::RefCounted<ServiceWorkerVersion>;
313 friend class ServiceWorkerURLRequestJobTest; 313 friend class ServiceWorkerURLRequestJobTest;
314 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, 314 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest,
315 ActivateWaitingVersion); 315 ActivateWaitingVersion);
316 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ScheduleStopWorker); 316 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ScheduleStopWorker);
317 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, KeepAlive); 317 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, KeepAlive);
318 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ListenerAvailability); 318 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ListenerAvailability);
319 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionBrowserTest,
320 TimeoutStartingWorker);
321 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionBrowserTest,
322 TimeoutWorkerInEvent);
323 friend class ServiceWorkerVersionBrowserTest;
324
319 typedef ServiceWorkerVersion self; 325 typedef ServiceWorkerVersion self;
320 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap; 326 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap;
321 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap; 327 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap;
322 328
323 ~ServiceWorkerVersion() override; 329 ~ServiceWorkerVersion() override;
324 330
325 // EmbeddedWorkerInstance::Listener overrides: 331 // EmbeddedWorkerInstance::Listener overrides:
332 void OnScriptLoaded() override;
326 void OnStarted() override; 333 void OnStarted() override;
327 void OnStopped(EmbeddedWorkerInstance::Status old_status) override; 334 void OnStopped(EmbeddedWorkerInstance::Status old_status) override;
328 void OnReportException(const base::string16& error_message, 335 void OnReportException(const base::string16& error_message,
329 int line_number, 336 int line_number,
330 int column_number, 337 int column_number,
331 const GURL& source_url) override; 338 const GURL& source_url) override;
332 void OnReportConsoleMessage(int source_identifier, 339 void OnReportConsoleMessage(int source_identifier,
333 int message_level, 340 int message_level,
334 const base::string16& message, 341 const base::string16& message,
335 int line_number, 342 int line_number,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 void OnOpenWindowFinished(int request_id, 377 void OnOpenWindowFinished(int request_id,
371 int client_id, 378 int client_id,
372 const ServiceWorkerClientInfo& client_info); 379 const ServiceWorkerClientInfo& client_info);
373 380
374 void OnPostMessageToDocument(int client_id, 381 void OnPostMessageToDocument(int client_id,
375 const base::string16& message, 382 const base::string16& message,
376 const std::vector<int>& sent_message_port_ids); 383 const std::vector<int>& sent_message_port_ids);
377 void OnFocusClient(int request_id, int client_id); 384 void OnFocusClient(int request_id, int client_id);
378 void OnSkipWaiting(int request_id); 385 void OnSkipWaiting(int request_id);
379 void OnClaimClients(int request_id); 386 void OnClaimClients(int request_id);
387 void OnPongFromWorker();
380 388
381 void OnFocusClientFinished(int request_id, 389 void OnFocusClientFinished(int request_id,
382 int client_id, 390 int client_id,
383 const ServiceWorkerClientInfo& client); 391 const ServiceWorkerClientInfo& client);
384 392
385 void DidSkipWaiting(int request_id); 393 void DidSkipWaiting(int request_id);
386 void DidClaimClients(int request_id, ServiceWorkerStatusCode status); 394 void DidClaimClients(int request_id, ServiceWorkerStatusCode status);
387 void DidGetClientInfo(int client_id, 395 void DidGetClientInfo(int client_id,
388 scoped_refptr<GetClientDocumentsCallback> callback, 396 scoped_refptr<GetClientDocumentsCallback> callback,
389 const ServiceWorkerClientInfo& info); 397 const ServiceWorkerClientInfo& info);
390 398
399 void PingWorker();
kinuko 2015/02/18 13:06:25 Can we have a short comment about the ping protoco
falken 2015/02/23 05:00:06 Good idea. Done. I also added a short comment for
400 void StartPingWorker();
401 void SchedulePingWorker();
402 void OnPingTimeout();
403
391 void ScheduleStopWorker(); 404 void ScheduleStopWorker();
392 void StopWorkerIfIdle(); 405 void StopWorkerIfIdle();
393 bool HasInflightRequests() const; 406 bool HasInflightRequests() const;
394 407
395 void DoomInternal(); 408 void DoomInternal();
396 409
397 template <typename IDMAP> 410 template <typename IDMAP>
398 void RemoveCallbackAndStopIfDoomed(IDMAP* callbacks, int request_id); 411 void RemoveCallbackAndStopIfDoomed(IDMAP* callbacks, int request_id);
399 412
400 const int64 version_id_; 413 const int64 version_id_;
(...skipping 22 matching lines...) Expand all
423 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; 436 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_;
424 437
425 ControlleeMap controllee_map_; 438 ControlleeMap controllee_map_;
426 ControlleeByIDMap controllee_by_id_; 439 ControlleeByIDMap controllee_by_id_;
427 // Will be null while shutting down. 440 // Will be null while shutting down.
428 base::WeakPtr<ServiceWorkerContextCore> context_; 441 base::WeakPtr<ServiceWorkerContextCore> context_;
429 ObserverList<Listener> listeners_; 442 ObserverList<Listener> listeners_;
430 ServiceWorkerScriptCacheMap script_cache_map_; 443 ServiceWorkerScriptCacheMap script_cache_map_;
431 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_; 444 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_;
432 base::OneShotTimer<ServiceWorkerVersion> update_timer_; 445 base::OneShotTimer<ServiceWorkerVersion> update_timer_;
446 base::OneShotTimer<ServiceWorkerVersion> ping_worker_timer_;
447 bool ping_timed_out_;
433 bool is_doomed_; 448 bool is_doomed_;
434 std::vector<int> pending_skip_waiting_requests_; 449 std::vector<int> pending_skip_waiting_requests_;
435 bool skip_waiting_; 450 bool skip_waiting_;
436 scoped_ptr<net::HttpResponseInfo> main_script_http_info_; 451 scoped_ptr<net::HttpResponseInfo> main_script_http_info_;
437 452
438 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; 453 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_;
439 454
440 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); 455 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion);
441 }; 456 };
442 457
443 } // namespace content 458 } // namespace content
444 459
445 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 460 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698