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

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: Updated comments 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 // Stop() returns false when it's called before StartWorker message hasn't
498 // been sent to the renderer process even though EmbeddedWorkerInstance is
499 // stopped properly.
500 // TODO(shimazu): Remove this check after Stop() hides the IPC behavior.
501 // See also a TODO on EmbeddedWorkerInstance::Stop.
502 if (!embedded_worker_->Stop()) {
503 RunSoon(base::Bind(callback, SERVICE_WORKER_ERROR_IPC_FAILED));
504 return;
505 }
506 stop_callbacks_.push_back(callback);
507 return;
508 case EmbeddedWorkerStatus::STOPPING:
509 stop_callbacks_.push_back(callback);
510 return;
511 case EmbeddedWorkerStatus::STOPPED:
512 RunSoon(base::Bind(callback, SERVICE_WORKER_OK));
513 return;
497 } 514 }
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 } 515 }
508 516
509 void ServiceWorkerVersion::ScheduleUpdate() { 517 void ServiceWorkerVersion::ScheduleUpdate() {
510 if (!context_) 518 if (!context_)
511 return; 519 return;
512 if (update_timer_.IsRunning()) { 520 if (update_timer_.IsRunning()) {
513 update_timer_.Reset(); 521 update_timer_.Reset();
514 return; 522 return;
515 } 523 }
516 if (is_update_scheduled_) 524 if (is_update_scheduled_)
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1864 1872
1865 void ServiceWorkerVersion::CleanUpExternalRequest( 1873 void ServiceWorkerVersion::CleanUpExternalRequest(
1866 const std::string& request_uuid, 1874 const std::string& request_uuid,
1867 ServiceWorkerStatusCode status) { 1875 ServiceWorkerStatusCode status) {
1868 if (status == SERVICE_WORKER_OK) 1876 if (status == SERVICE_WORKER_OK)
1869 return; 1877 return;
1870 external_request_uuid_to_request_id_.erase(request_uuid); 1878 external_request_uuid_to_request_id_.erase(request_uuid);
1871 } 1879 }
1872 1880
1873 } // namespace content 1881 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698