| 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_INSTANCE_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 virtual void OnReportException(const base::string16& error_message, | 93 virtual void OnReportException(const base::string16& error_message, |
| 94 int line_number, | 94 int line_number, |
| 95 int column_number, | 95 int column_number, |
| 96 const GURL& source_url) {} | 96 const GURL& source_url) {} |
| 97 virtual void OnReportConsoleMessage(int source_identifier, | 97 virtual void OnReportConsoleMessage(int source_identifier, |
| 98 int message_level, | 98 int message_level, |
| 99 const base::string16& message, | 99 const base::string16& message, |
| 100 int line_number, | 100 int line_number, |
| 101 const GURL& source_url) {} | 101 const GURL& source_url) {} |
| 102 // Returns false if the message is not handled by this listener. | 102 // Returns false if the message is not handled by this listener. |
| 103 CONTENT_EXPORT virtual bool OnMessageReceived(const IPC::Message& message); | 103 virtual bool OnMessageReceived(const IPC::Message& message) = 0; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 ~EmbeddedWorkerInstance(); | 106 ~EmbeddedWorkerInstance(); |
| 107 | 107 |
| 108 // Starts the worker. It is invalid to call this when the worker is not in | 108 // Starts the worker. It is invalid to call this when the worker is not in |
| 109 // STOPPED status. |callback| is invoked after the worker script has been | 109 // STOPPED status. |callback| is invoked after the worker script has been |
| 110 // started and evaluated, or when an error occurs. If |pause_after_download| | 110 // started and evaluated, or when an error occurs. |
| 111 // is true, the worker pauses after loading until ResumeAfterDownload() is | |
| 112 // called. | |
| 113 void Start(int64_t service_worker_version_id, | 111 void Start(int64_t service_worker_version_id, |
| 114 const GURL& scope, | 112 const GURL& scope, |
| 115 const GURL& script_url, | 113 const GURL& script_url, |
| 116 const StatusCallback& callback, | 114 const StatusCallback& callback); |
| 117 bool pause_after_download = false); | |
| 118 | 115 |
| 119 // Stops the worker. It is invalid to call this when the worker is | 116 // Stops the worker. It is invalid to call this when the worker is |
| 120 // not in STARTING or RUNNING status. | 117 // not in STARTING or RUNNING status. |
| 121 // This returns false if stopping a worker fails immediately, e.g. when | 118 // This returns false if stopping a worker fails immediately, e.g. when |
| 122 // IPC couldn't be sent to the worker. | 119 // IPC couldn't be sent to the worker. |
| 123 ServiceWorkerStatusCode Stop(); | 120 ServiceWorkerStatusCode Stop(); |
| 124 | 121 |
| 125 // Stops the worker if the worker is not being debugged (i.e. devtools is | 122 // Stops the worker if the worker is not being debugged (i.e. devtools is |
| 126 // not attached). This method is called by a stop-worker timer to kill | 123 // not attached). This method is called by a stop-worker timer to kill |
| 127 // idle workers. | 124 // idle workers. |
| 128 void StopIfIdle(); | 125 void StopIfIdle(); |
| 129 | 126 |
| 130 // Sends |message| to the embedded worker running in the child process. | 127 // Sends |message| to the embedded worker running in the child process. |
| 131 // It is invalid to call this while the worker is not in STARTING or RUNNING | 128 // It is invalid to call this while the worker is not in STARTING or RUNNING |
| 132 // status. | 129 // status. |
| 133 ServiceWorkerStatusCode SendMessage(const IPC::Message& message); | 130 ServiceWorkerStatusCode SendMessage(const IPC::Message& message); |
| 134 | 131 |
| 135 // Resumes the worker if it paused after download. | |
| 136 void ResumeAfterDownload(); | |
| 137 | |
| 138 // Returns the ServiceRegistry for this worker. It is invalid to call this | 132 // Returns the ServiceRegistry for this worker. It is invalid to call this |
| 139 // when the worker is not in STARTING or RUNNING status. | 133 // when the worker is not in STARTING or RUNNING status. |
| 140 ServiceRegistry* GetServiceRegistry(); | 134 ServiceRegistry* GetServiceRegistry(); |
| 141 | 135 |
| 142 int embedded_worker_id() const { return embedded_worker_id_; } | 136 int embedded_worker_id() const { return embedded_worker_id_; } |
| 143 Status status() const { return status_; } | 137 Status status() const { return status_; } |
| 144 StartingPhase starting_phase() const { | 138 StartingPhase starting_phase() const { |
| 145 DCHECK_EQ(STARTING, status()); | 139 DCHECK_EQ(STARTING, status()); |
| 146 return starting_phase_; | 140 return starting_phase_; |
| 147 } | 141 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 base::TimeTicks start_timing_; | 284 base::TimeTicks start_timing_; |
| 291 | 285 |
| 292 base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_; | 286 base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_; |
| 293 | 287 |
| 294 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance); | 288 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance); |
| 295 }; | 289 }; |
| 296 | 290 |
| 297 } // namespace content | 291 } // namespace content |
| 298 | 292 |
| 299 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ | 293 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ |
| OLD | NEW |