| 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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 18 #include "content/browser/service_worker/service_worker_lifetime_tracker.h" |
| 18 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 19 #include "content/common/service_worker/service_worker_status_code.h" | 20 #include "content/common/service_worker/service_worker_status_code.h" |
| 20 | 21 |
| 21 class GURL; | 22 class GURL; |
| 22 | 23 |
| 23 namespace IPC { | 24 namespace IPC { |
| 24 class Message; | 25 class Message; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace content { | 28 namespace content { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 const base::string16& error_message, | 77 const base::string16& error_message, |
| 77 int line_number, | 78 int line_number, |
| 78 int column_number, | 79 int column_number, |
| 79 const GURL& source_url); | 80 const GURL& source_url); |
| 80 void OnReportConsoleMessage(int embedded_worker_id, | 81 void OnReportConsoleMessage(int embedded_worker_id, |
| 81 int source_identifier, | 82 int source_identifier, |
| 82 int message_level, | 83 int message_level, |
| 83 const base::string16& message, | 84 const base::string16& message, |
| 84 int line_number, | 85 int line_number, |
| 85 const GURL& source_url); | 86 const GURL& source_url); |
| 87 // Called by EmbeddedWorkerInstance when it learns DevTools has attached to |
| 88 // it. |
| 89 void OnDevToolsAttached(int embedded_worker_id); |
| 86 | 90 |
| 87 // Removes information about the service workers running on the process and | 91 // Removes information about the service workers running on the process and |
| 88 // calls ServiceWorkerVersion::OnDetached() on each. Called when the process | 92 // calls ServiceWorkerVersion::OnDetached() on each. Called when the process |
| 89 // is terminated. Under normal operation, the workers should already have | 93 // is terminated. Under normal operation, the workers should already have |
| 90 // been stopped before the process is terminated, in which case this function | 94 // been stopped before the process is terminated, in which case this function |
| 91 // does nothing. But in some cases the process can be terminated unexpectedly | 95 // does nothing. But in some cases the process can be terminated unexpectedly |
| 92 // or the workers can fail to stop cleanly. | 96 // or the workers can fail to stop cleanly. |
| 93 void RemoveProcess(int process_id); | 97 void RemoveProcess(int process_id); |
| 94 | 98 |
| 95 // Returns an embedded worker instance for given |embedded_worker_id|. | 99 // Returns an embedded worker instance for given |embedded_worker_id|. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 base::WeakPtr<ServiceWorkerContextCore> context_; | 139 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 136 | 140 |
| 137 WorkerInstanceMap worker_map_; | 141 WorkerInstanceMap worker_map_; |
| 138 | 142 |
| 139 // Map from process_id to embedded_worker_id. | 143 // Map from process_id to embedded_worker_id. |
| 140 // This map only contains starting and running workers. | 144 // This map only contains starting and running workers. |
| 141 std::map<int, std::set<int> > worker_process_map_; | 145 std::map<int, std::set<int> > worker_process_map_; |
| 142 | 146 |
| 143 int next_embedded_worker_id_; | 147 int next_embedded_worker_id_; |
| 144 const int initial_embedded_worker_id_; | 148 const int initial_embedded_worker_id_; |
| 149 ServiceWorkerLifetimeTracker lifetime_tracker_; |
| 145 | 150 |
| 146 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerRegistry); | 151 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerRegistry); |
| 147 }; | 152 }; |
| 148 | 153 |
| 149 } // namespace content | 154 } // namespace content |
| 150 | 155 |
| 151 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ | 156 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ |
| OLD | NEW |