| 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/browser/service_worker/service_worker_lifetime_tracker.h" |
| 19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 20 #include "content/common/service_worker/service_worker_status_code.h" | 20 #include "content/common/service_worker/service_worker_status_code.h" |
| 21 | 21 |
| 22 class GURL; | |
| 23 | |
| 24 namespace IPC { | 22 namespace IPC { |
| 25 class Message; | 23 class Message; |
| 26 } | 24 } |
| 27 | 25 |
| 28 namespace content { | 26 namespace content { |
| 29 | 27 |
| 30 class EmbeddedWorkerInstance; | 28 class EmbeddedWorkerInstance; |
| 31 class ServiceWorkerContextCore; | 29 class ServiceWorkerContextCore; |
| 32 | 30 |
| 33 // Acts as a thin stub between MessageFilter and each EmbeddedWorkerInstance, | 31 // Acts as a thin stub between MessageFilter and each EmbeddedWorkerInstance, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 46 static scoped_refptr<EmbeddedWorkerRegistry> Create( | 44 static scoped_refptr<EmbeddedWorkerRegistry> Create( |
| 47 const base::WeakPtr<ServiceWorkerContextCore>& context, | 45 const base::WeakPtr<ServiceWorkerContextCore>& context, |
| 48 EmbeddedWorkerRegistry* old_registry); | 46 EmbeddedWorkerRegistry* old_registry); |
| 49 | 47 |
| 50 bool OnMessageReceived(const IPC::Message& message, int process_id); | 48 bool OnMessageReceived(const IPC::Message& message, int process_id); |
| 51 | 49 |
| 52 // Creates and removes a new worker instance entry for bookkeeping. | 50 // Creates and removes a new worker instance entry for bookkeeping. |
| 53 // This doesn't actually start or stop the worker. | 51 // This doesn't actually start or stop the worker. |
| 54 std::unique_ptr<EmbeddedWorkerInstance> CreateWorker(); | 52 std::unique_ptr<EmbeddedWorkerInstance> CreateWorker(); |
| 55 | 53 |
| 56 // Called from EmbeddedWorkerInstance, relayed to the child process. | |
| 57 ServiceWorkerStatusCode StopWorker(int process_id, | |
| 58 int embedded_worker_id); | |
| 59 | |
| 60 // Stop all active workers, even if they're handling events. | 54 // Stop all active workers, even if they're handling events. |
| 61 void Shutdown(); | 55 void Shutdown(); |
| 62 | 56 |
| 63 // Called back from EmbeddedWorker in the child process, relayed via | 57 // Called by EmbeddedWorkerInstance to do some necessary work in the registry. |
| 64 // ServiceWorkerDispatcherHost. | 58 bool OnWorkerStarted(int process_id, int embedded_worker_id); |
| 65 void OnWorkerReadyForInspection(int process_id, int embedded_worker_id); | |
| 66 void OnWorkerScriptLoaded(int process_id, int embedded_worker_id); | |
| 67 void OnWorkerThreadStarted(int process_id, | |
| 68 int thread_id, | |
| 69 int embedded_worker_id); | |
| 70 void OnWorkerScriptLoadFailed(int process_id, int embedded_worker_id); | |
| 71 void OnWorkerScriptEvaluated(int process_id, | |
| 72 int embedded_worker_id, | |
| 73 bool success); | |
| 74 void OnWorkerStarted(int process_id, int embedded_worker_id); | |
| 75 void OnWorkerStopped(int process_id, int embedded_worker_id); | 59 void OnWorkerStopped(int process_id, int embedded_worker_id); |
| 76 void OnReportException(int embedded_worker_id, | 60 |
| 77 const base::string16& error_message, | |
| 78 int line_number, | |
| 79 int column_number, | |
| 80 const GURL& source_url); | |
| 81 void OnReportConsoleMessage(int embedded_worker_id, | |
| 82 int source_identifier, | |
| 83 int message_level, | |
| 84 const base::string16& message, | |
| 85 int line_number, | |
| 86 const GURL& source_url); | |
| 87 // Called by EmbeddedWorkerInstance when it learns DevTools has attached to | 61 // Called by EmbeddedWorkerInstance when it learns DevTools has attached to |
| 88 // it. | 62 // it. |
| 89 void OnDevToolsAttached(int embedded_worker_id); | 63 void OnDevToolsAttached(int embedded_worker_id); |
| 90 | 64 |
| 91 // Removes information about the service workers running on the process and | 65 // Removes information about the service workers running on the process and |
| 92 // calls ServiceWorkerVersion::OnDetached() on each. Called when the process | 66 // calls ServiceWorkerVersion::OnDetached() on each. Called when the process |
| 93 // is terminated. Under normal operation, the workers should already have | 67 // is terminated. Under normal operation, the workers should already have |
| 94 // been stopped before the process is terminated, in which case this function | 68 // been stopped before the process is terminated, in which case this function |
| 95 // does nothing. But in some cases the process can be terminated unexpectedly | 69 // does nothing. But in some cases the process can be terminated unexpectedly |
| 96 // or the workers can fail to stop cleanly. | 70 // or the workers can fail to stop cleanly. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 int next_embedded_worker_id_; | 121 int next_embedded_worker_id_; |
| 148 const int initial_embedded_worker_id_; | 122 const int initial_embedded_worker_id_; |
| 149 ServiceWorkerLifetimeTracker lifetime_tracker_; | 123 ServiceWorkerLifetimeTracker lifetime_tracker_; |
| 150 | 124 |
| 151 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerRegistry); | 125 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerRegistry); |
| 152 }; | 126 }; |
| 153 | 127 |
| 154 } // namespace content | 128 } // namespace content |
| 155 | 129 |
| 156 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ | 130 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ |
| OLD | NEW |