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

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

Issue 2578023002: ServiceWorker: Stop don't send a message before connection established (Closed)
Patch Set: comment from falken@ Created 3 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
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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 weak_factory_.GetWeakPtr(), purpose, status_, 484 weak_factory_.GetWeakPtr(), purpose, status_,
485 is_browser_startup_complete, callback)); 485 is_browser_startup_complete, callback));
486 } 486 }
487 487
488 void ServiceWorkerVersion::StopWorker(const StatusCallback& callback) { 488 void ServiceWorkerVersion::StopWorker(const StatusCallback& callback) {
489 TRACE_EVENT_INSTANT2("ServiceWorker", 489 TRACE_EVENT_INSTANT2("ServiceWorker",
490 "ServiceWorkerVersion::StopWorker (instant)", 490 "ServiceWorkerVersion::StopWorker (instant)",
491 TRACE_EVENT_SCOPE_THREAD, "Script", script_url_.spec(), 491 TRACE_EVENT_SCOPE_THREAD, "Script", script_url_.spec(),
492 "Status", VersionStatusToString(status_)); 492 "Status", VersionStatusToString(status_));
493 493
494 if (running_status() == EmbeddedWorkerStatus::STOPPED) { 494 switch (running_status()) {
495 RunSoon(base::Bind(callback, SERVICE_WORKER_OK)); 495 case EmbeddedWorkerStatus::STARTING:
496 return; 496 case EmbeddedWorkerStatus::RUNNING:
497 if (!embedded_worker_->Stop()) {
falken 2017/01/05 06:40:17 can you add a TODO here about how the return value
shimazu 2017/01/05 07:42:56 Done.
498 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_IPC_FAILED));
499 return;
500 }
501 stop_callbacks_.push_back(callback);
502 return;
503 case EmbeddedWorkerStatus::STOPPING:
504 stop_callbacks_.push_back(callback);
505 return;
506 case EmbeddedWorkerStatus::STOPPED:
507 RunSoon(base::Bind(callback, SERVICE_WORKER_OK));
508 return;
497 } 509 }
498
499 if (stop_callbacks_.empty()) {
500 ServiceWorkerStatusCode status = embedded_worker_->Stop();
501 if (status != SERVICE_WORKER_OK) {
502 RunSoon(base::Bind(callback, status));
503 return;
504 }
505 }
506 stop_callbacks_.push_back(callback);
507 } 510 }
508 511
509 void ServiceWorkerVersion::ScheduleUpdate() { 512 void ServiceWorkerVersion::ScheduleUpdate() {
510 if (!context_) 513 if (!context_)
511 return; 514 return;
512 if (update_timer_.IsRunning()) { 515 if (update_timer_.IsRunning()) {
513 update_timer_.Reset(); 516 update_timer_.Reset();
514 return; 517 return;
515 } 518 }
516 if (is_update_scheduled_) 519 if (is_update_scheduled_)
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1864 1867
1865 void ServiceWorkerVersion::CleanUpExternalRequest( 1868 void ServiceWorkerVersion::CleanUpExternalRequest(
1866 const std::string& request_uuid, 1869 const std::string& request_uuid,
1867 ServiceWorkerStatusCode status) { 1870 ServiceWorkerStatusCode status) {
1868 if (status == SERVICE_WORKER_OK) 1871 if (status == SERVICE_WORKER_OK)
1869 return; 1872 return;
1870 external_request_uuid_to_request_id_.erase(request_uuid); 1873 external_request_uuid_to_request_id_.erase(request_uuid);
1871 } 1874 }
1872 1875
1873 } // namespace content 1876 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698