| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_AGENT_HOST_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_AGENT_HOST_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_AGENT_HOST_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_AGENT_HOST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/time/time.h" |
| 13 #include "content/browser/devtools/protocol/network_handler.h" | 14 #include "content/browser/devtools/protocol/network_handler.h" |
| 14 #include "content/browser/devtools/service_worker_devtools_manager.h" | 15 #include "content/browser/devtools/service_worker_devtools_manager.h" |
| 15 #include "content/browser/devtools/worker_devtools_agent_host.h" | 16 #include "content/browser/devtools/worker_devtools_agent_host.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 class ServiceWorkerDevToolsAgentHost : public WorkerDevToolsAgentHost { | 20 class ServiceWorkerDevToolsAgentHost : public WorkerDevToolsAgentHost { |
| 20 public: | 21 public: |
| 21 using List = std::vector<scoped_refptr<ServiceWorkerDevToolsAgentHost>>; | 22 using List = std::vector<scoped_refptr<ServiceWorkerDevToolsAgentHost>>; |
| 22 using Map = std::map<std::string, | 23 using Map = std::map<std::string, |
| 23 scoped_refptr<ServiceWorkerDevToolsAgentHost>>; | 24 scoped_refptr<ServiceWorkerDevToolsAgentHost>>; |
| 24 using ServiceWorkerIdentifier = | 25 using ServiceWorkerIdentifier = |
| 25 ServiceWorkerDevToolsManager::ServiceWorkerIdentifier; | 26 ServiceWorkerDevToolsManager::ServiceWorkerIdentifier; |
| 26 | 27 |
| 27 ServiceWorkerDevToolsAgentHost(WorkerId worker_id, | 28 ServiceWorkerDevToolsAgentHost(WorkerId worker_id, |
| 28 const ServiceWorkerIdentifier& service_worker); | 29 const ServiceWorkerIdentifier& service_worker, |
| 30 bool is_installed_version); |
| 29 | 31 |
| 30 void UnregisterWorker(); | 32 void UnregisterWorker(); |
| 31 | 33 |
| 32 // DevToolsAgentHost overrides. | 34 // DevToolsAgentHost overrides. |
| 33 Type GetType() override; | 35 Type GetType() override; |
| 34 std::string GetTitle() override; | 36 std::string GetTitle() override; |
| 35 GURL GetURL() override; | 37 GURL GetURL() override; |
| 36 bool Activate() override; | 38 bool Activate() override; |
| 37 bool Close() override; | 39 bool Close() override; |
| 38 | 40 |
| 39 // WorkerDevToolsAgentHost overrides. | 41 // WorkerDevToolsAgentHost overrides. |
| 40 void OnAttachedStateChanged(bool attached) override; | 42 void OnAttachedStateChanged(bool attached) override; |
| 41 | 43 |
| 44 void WorkerVersionInstalled(); |
| 45 void WorkerVersionDoomed(); |
| 46 |
| 42 int64_t service_worker_version_id() const; | 47 int64_t service_worker_version_id() const; |
| 43 GURL scope() const; | 48 GURL scope() const; |
| 44 | 49 |
| 50 // If the ServiceWorker has been installed before the worker instance started, |
| 51 // it returns the time when the instance started. Otherwise returns the time |
| 52 // when the ServiceWorker was installed. |
| 53 base::Time version_installed_time() const { return version_installed_time_; } |
| 54 |
| 55 // Returns the time when the ServiceWorker was doomed. |
| 56 base::Time version_doomed_time() const { return version_doomed_time_; } |
| 57 |
| 45 bool Matches(const ServiceWorkerIdentifier& other); | 58 bool Matches(const ServiceWorkerIdentifier& other); |
| 46 | 59 |
| 47 private: | 60 private: |
| 48 ~ServiceWorkerDevToolsAgentHost() override; | 61 ~ServiceWorkerDevToolsAgentHost() override; |
| 49 std::unique_ptr<ServiceWorkerIdentifier> service_worker_; | 62 std::unique_ptr<ServiceWorkerIdentifier> service_worker_; |
| 50 std::unique_ptr<devtools::network::NetworkHandler> network_handler_; | 63 std::unique_ptr<devtools::network::NetworkHandler> network_handler_; |
| 64 base::Time version_installed_time_; |
| 65 base::Time version_doomed_time_; |
| 51 | 66 |
| 52 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDevToolsAgentHost); | 67 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDevToolsAgentHost); |
| 53 }; | 68 }; |
| 54 | 69 |
| 55 } // namespace content | 70 } // namespace content |
| 56 | 71 |
| 57 #endif // CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_AGENT_HOST_H_ | 72 #endif // CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_AGENT_HOST_H_ |
| OLD | NEW |