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 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1713 ServiceWorkerStatusCode ServiceWorkerVersion::PingWorker() { | 1714 ServiceWorkerStatusCode ServiceWorkerVersion::PingWorker() { |
1714 DCHECK(running_status() == EmbeddedWorkerStatus::STARTING || | 1715 DCHECK(running_status() == EmbeddedWorkerStatus::STARTING || |
1715 running_status() == EmbeddedWorkerStatus::RUNNING); | 1716 running_status() == EmbeddedWorkerStatus::RUNNING); |
1716 return embedded_worker_->SendMessage(ServiceWorkerMsg_Ping()); | 1717 return embedded_worker_->SendMessage(ServiceWorkerMsg_Ping()); |
1717 } | 1718 } |
1718 | 1719 |
1719 void ServiceWorkerVersion::OnPingTimeout() { | 1720 void ServiceWorkerVersion::OnPingTimeout() { |
1720 DCHECK(running_status() == EmbeddedWorkerStatus::STARTING || | 1721 DCHECK(running_status() == EmbeddedWorkerStatus::STARTING || |
1721 running_status() == EmbeddedWorkerStatus::RUNNING); | 1722 running_status() == EmbeddedWorkerStatus::RUNNING); |
1722 // TODO(falken): Change the error code to SERVICE_WORKER_ERROR_TIMEOUT. | 1723 // TODO(falken): Change the error code to SERVICE_WORKER_ERROR_TIMEOUT. |
1723 embedded_worker_->AddMessageToConsole(CONSOLE_MESSAGE_LEVEL_DEBUG, | 1724 embedded_worker_->AddMessageToConsole(blink::WebConsoleMessage::LevelDebug, |
1724 kNotRespondingErrorMesage); | 1725 kNotRespondingErrorMesage); |
1725 StopWorkerIfIdle(); | 1726 StopWorkerIfIdle(); |
1726 } | 1727 } |
1727 | 1728 |
1728 void ServiceWorkerVersion::StopWorkerIfIdle() { | 1729 void ServiceWorkerVersion::StopWorkerIfIdle() { |
1729 if (HasWork() && !ping_controller_->IsTimedOut()) | 1730 if (HasWork() && !ping_controller_->IsTimedOut()) |
1730 return; | 1731 return; |
1731 if (running_status() == EmbeddedWorkerStatus::STOPPED || | 1732 if (running_status() == EmbeddedWorkerStatus::STOPPED || |
1732 running_status() == EmbeddedWorkerStatus::STOPPING || | 1733 running_status() == EmbeddedWorkerStatus::STOPPING || |
1733 !stop_callbacks_.empty()) { | 1734 !stop_callbacks_.empty()) { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 | 1953 |
1953 void ServiceWorkerVersion::CleanUpExternalRequest( | 1954 void ServiceWorkerVersion::CleanUpExternalRequest( |
1954 const std::string& request_uuid, | 1955 const std::string& request_uuid, |
1955 ServiceWorkerStatusCode status) { | 1956 ServiceWorkerStatusCode status) { |
1956 if (status == SERVICE_WORKER_OK) | 1957 if (status == SERVICE_WORKER_OK) |
1957 return; | 1958 return; |
1958 external_request_uuid_to_request_id_.erase(request_uuid); | 1959 external_request_uuid_to_request_id_.erase(request_uuid); |
1959 } | 1960 } |
1960 | 1961 |
1961 } // namespace content | 1962 } // namespace content |
OLD | NEW |