| OLD | NEW |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "content/common/service_worker/service_worker_utils.h" | 45 #include "content/common/service_worker/service_worker_utils.h" |
| 46 #include "content/public/browser/browser_thread.h" | 46 #include "content/public/browser/browser_thread.h" |
| 47 #include "content/public/browser/content_browser_client.h" | 47 #include "content/public/browser/content_browser_client.h" |
| 48 #include "content/public/browser/render_process_host.h" | 48 #include "content/public/browser/render_process_host.h" |
| 49 #include "content/public/common/content_client.h" | 49 #include "content/public/common/content_client.h" |
| 50 #include "content/public/common/content_features.h" | 50 #include "content/public/common/content_features.h" |
| 51 #include "content/public/common/content_switches.h" | 51 #include "content/public/common/content_switches.h" |
| 52 #include "content/public/common/result_codes.h" | 52 #include "content/public/common/result_codes.h" |
| 53 #include "net/http/http_response_headers.h" | 53 #include "net/http/http_response_headers.h" |
| 54 #include "net/http/http_response_info.h" | 54 #include "net/http/http_response_info.h" |
| 55 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
| 55 | 56 |
| 56 namespace content { | 57 namespace content { |
| 57 | 58 |
| 58 using StatusCallback = ServiceWorkerVersion::StatusCallback; | 59 using StatusCallback = ServiceWorkerVersion::StatusCallback; |
| 59 | 60 |
| 60 namespace { | 61 namespace { |
| 61 | 62 |
| 62 // Time to wait until stopping an idle worker. | 63 // Time to wait until stopping an idle worker. |
| 63 const int kIdleWorkerTimeoutSeconds = 30; | 64 const int kIdleWorkerTimeoutSeconds = 30; |
| 64 | 65 |
| (...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1719 ServiceWorkerStatusCode ServiceWorkerVersion::PingWorker() { | 1720 ServiceWorkerStatusCode ServiceWorkerVersion::PingWorker() { |
| 1720 DCHECK(running_status() == EmbeddedWorkerStatus::STARTING || | 1721 DCHECK(running_status() == EmbeddedWorkerStatus::STARTING || |
| 1721 running_status() == EmbeddedWorkerStatus::RUNNING); | 1722 running_status() == EmbeddedWorkerStatus::RUNNING); |
| 1722 return embedded_worker_->SendMessage(ServiceWorkerMsg_Ping()); | 1723 return embedded_worker_->SendMessage(ServiceWorkerMsg_Ping()); |
| 1723 } | 1724 } |
| 1724 | 1725 |
| 1725 void ServiceWorkerVersion::OnPingTimeout() { | 1726 void ServiceWorkerVersion::OnPingTimeout() { |
| 1726 DCHECK(running_status() == EmbeddedWorkerStatus::STARTING || | 1727 DCHECK(running_status() == EmbeddedWorkerStatus::STARTING || |
| 1727 running_status() == EmbeddedWorkerStatus::RUNNING); | 1728 running_status() == EmbeddedWorkerStatus::RUNNING); |
| 1728 // TODO(falken): Change the error code to SERVICE_WORKER_ERROR_TIMEOUT. | 1729 // TODO(falken): Change the error code to SERVICE_WORKER_ERROR_TIMEOUT. |
| 1729 embedded_worker_->AddMessageToConsole(CONSOLE_MESSAGE_LEVEL_DEBUG, | 1730 embedded_worker_->AddMessageToConsole(blink::WebConsoleMessage::LevelDebug, |
| 1730 kNotRespondingErrorMesage); | 1731 kNotRespondingErrorMesage); |
| 1731 StopWorkerIfIdle(); | 1732 StopWorkerIfIdle(); |
| 1732 } | 1733 } |
| 1733 | 1734 |
| 1734 void ServiceWorkerVersion::StopWorkerIfIdle() { | 1735 void ServiceWorkerVersion::StopWorkerIfIdle() { |
| 1735 if (HasWork() && !ping_controller_->IsTimedOut()) | 1736 if (HasWork() && !ping_controller_->IsTimedOut()) |
| 1736 return; | 1737 return; |
| 1737 if (running_status() == EmbeddedWorkerStatus::STOPPED || | 1738 if (running_status() == EmbeddedWorkerStatus::STOPPED || |
| 1738 running_status() == EmbeddedWorkerStatus::STOPPING || | 1739 running_status() == EmbeddedWorkerStatus::STOPPING || |
| 1739 !stop_callbacks_.empty()) { | 1740 !stop_callbacks_.empty()) { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1963 | 1964 |
| 1964 void ServiceWorkerVersion::CleanUpExternalRequest( | 1965 void ServiceWorkerVersion::CleanUpExternalRequest( |
| 1965 const std::string& request_uuid, | 1966 const std::string& request_uuid, |
| 1966 ServiceWorkerStatusCode status) { | 1967 ServiceWorkerStatusCode status) { |
| 1967 if (status == SERVICE_WORKER_OK) | 1968 if (status == SERVICE_WORKER_OK) |
| 1968 return; | 1969 return; |
| 1969 external_request_uuid_to_request_id_.erase(request_uuid); | 1970 external_request_uuid_to_request_id_.erase(request_uuid); |
| 1970 } | 1971 } |
| 1971 | 1972 |
| 1972 } // namespace content | 1973 } // namespace content |
| OLD | NEW |