| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/devtools/protocol/service_worker_handler.h" | 5 #include "content/browser/devtools/protocol/service_worker_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/containers/scoped_ptr_hash_map.h" | 8 #include "base/containers/scoped_ptr_hash_map.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 419 |
| 420 Response ServiceWorkerHandler::StartWorker(const std::string& scope_url) { | 420 Response ServiceWorkerHandler::StartWorker(const std::string& scope_url) { |
| 421 if (!enabled_) | 421 if (!enabled_) |
| 422 return Response::OK(); | 422 return Response::OK(); |
| 423 if (!context_) | 423 if (!context_) |
| 424 return CreateContextErrorResponse(); | 424 return CreateContextErrorResponse(); |
| 425 context_->StartServiceWorker(GURL(scope_url), base::Bind(&StatusNoOp)); | 425 context_->StartServiceWorker(GURL(scope_url), base::Bind(&StatusNoOp)); |
| 426 return Response::OK(); | 426 return Response::OK(); |
| 427 } | 427 } |
| 428 | 428 |
| 429 Response ServiceWorkerHandler::SkipWaiting(const std::string& scope_url) { |
| 430 if (!enabled_) |
| 431 return Response::OK(); |
| 432 if (!context_) |
| 433 return CreateContextErrorResponse(); |
| 434 context_->SkipWaitingWorker(GURL(scope_url)); |
| 435 return Response::OK(); |
| 436 } |
| 437 |
| 429 Response ServiceWorkerHandler::StopWorker(const std::string& version_id) { | 438 Response ServiceWorkerHandler::StopWorker(const std::string& version_id) { |
| 430 if (!enabled_) | 439 if (!enabled_) |
| 431 return Response::OK(); | 440 return Response::OK(); |
| 432 if (!context_) | 441 if (!context_) |
| 433 return CreateContextErrorResponse(); | 442 return CreateContextErrorResponse(); |
| 434 int64_t id = 0; | 443 int64_t id = 0; |
| 435 if (!base::StringToInt64(version_id, &id)) | 444 if (!base::StringToInt64(version_id, &id)) |
| 436 return CreateInvalidVersionIdErrorResponse(); | 445 return CreateInvalidVersionIdErrorResponse(); |
| 437 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 446 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 438 base::Bind(&StopServiceWorkerOnIO, context_, id)); | 447 base::Bind(&StopServiceWorkerOnIO, context_, id)); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 } | 659 } |
| 651 | 660 |
| 652 void ServiceWorkerHandler::ClearForceUpdate() { | 661 void ServiceWorkerHandler::ClearForceUpdate() { |
| 653 if (context_) | 662 if (context_) |
| 654 context_->SetForceUpdateOnPageLoad(false); | 663 context_->SetForceUpdateOnPageLoad(false); |
| 655 } | 664 } |
| 656 | 665 |
| 657 } // namespace service_worker | 666 } // namespace service_worker |
| 658 } // namespace devtools | 667 } // namespace devtools |
| 659 } // namespace content | 668 } // namespace content |
| OLD | NEW |