Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: content/browser/service_worker/embedded_worker_instance.h

Issue 912753002: Stop Service Workers that execute JavaScript for too long. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix timeout value Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 enum Status { 49 enum Status {
50 STOPPED, 50 STOPPED,
51 STARTING, 51 STARTING,
52 RUNNING, 52 RUNNING,
53 STOPPING, 53 STOPPING,
54 }; 54 };
55 55
56 class Listener { 56 class Listener {
57 public: 57 public:
58 virtual ~Listener() {} 58 virtual ~Listener() {}
59 virtual void OnScriptLoaded() {}
59 virtual void OnStarted() {} 60 virtual void OnStarted() {}
60 virtual void OnStopped(Status old_status) {} 61 virtual void OnStopped(Status old_status) {}
61 virtual void OnPausedAfterDownload() {} 62 virtual void OnPausedAfterDownload() {}
62 virtual void OnReportException(const base::string16& error_message, 63 virtual void OnReportException(const base::string16& error_message,
63 int line_number, 64 int line_number,
64 int column_number, 65 int column_number,
65 const GURL& source_url) {} 66 const GURL& source_url) {}
66 virtual void OnReportConsoleMessage(int source_identifier, 67 virtual void OnReportConsoleMessage(int source_identifier,
67 int message_level, 68 int message_level,
68 const base::string16& message, 69 const base::string16& message,
69 int line_number, 70 int line_number,
70 const GURL& source_url) {} 71 const GURL& source_url) {}
71 // These should return false if the message is not handled by this 72 // These should return false if the message is not handled by this
72 // listener. (TODO(kinuko): consider using IPC::Listener interface) 73 // listener. (TODO(kinuko): consider using IPC::Listener interface)
73 // TODO(kinuko): Deprecate OnReplyReceived. 74 // TODO(kinuko): Deprecate OnReplyReceived.
74 virtual bool OnMessageReceived(const IPC::Message& message) = 0; 75 virtual bool OnMessageReceived(const IPC::Message& message) = 0;
75 }; 76 };
76 77
77 ~EmbeddedWorkerInstance(); 78 ~EmbeddedWorkerInstance();
78 79
79 // Starts the worker. It is invalid to call this when the worker is not in 80 // Starts the worker. It is invalid to call this when the worker is not in
80 // STOPPED status. |callback| is invoked when the worker's process is created 81 // STOPPED status. |callback| is invoked after the worker script has been
81 // if necessary and the IPC to evaluate the worker's script is sent. 82 // started and evaluated, or when an error occurs.
82 // Observer::OnStarted() is run when the worker is actually started.
83 void Start(int64 service_worker_version_id, 83 void Start(int64 service_worker_version_id,
84 const GURL& scope, 84 const GURL& scope,
85 const GURL& script_url, 85 const GURL& script_url,
86 bool pause_after_download, 86 bool pause_after_download,
87 const StatusCallback& callback); 87 const StatusCallback& callback);
88 88
89 // Stops the worker. It is invalid to call this when the worker is 89 // Stops the worker. It is invalid to call this when the worker is
90 // not in STARTING or RUNNING status. 90 // not in STARTING or RUNNING status.
91 // This returns false if stopping a worker fails immediately, e.g. when 91 // This returns false if stopping a worker fails immediately, e.g. when
92 // IPC couldn't be sent to the worker. 92 // IPC couldn't be sent to the worker.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 // Called back from Registry when the worker instance has ack'ed that 156 // Called back from Registry when the worker instance has ack'ed that
157 // it finished loading the script and has started a worker thread. 157 // it finished loading the script and has started a worker thread.
158 void OnScriptLoaded(int thread_id); 158 void OnScriptLoaded(int thread_id);
159 159
160 // Called back from Registry when the worker instance has ack'ed that 160 // Called back from Registry when the worker instance has ack'ed that
161 // it failed to load the script. 161 // it failed to load the script.
162 void OnScriptLoadFailed(); 162 void OnScriptLoadFailed();
163 163
164 // Called back from Registry when the worker instance has ack'ed that 164 // Called back from Registry when the worker instance has ack'ed that
165 // it finished evaluating the script. 165 // it finished evaluating the script. This is called before OnStarted.
166 void OnScriptEvaluated(bool success); 166 void OnScriptEvaluated(bool success);
167 167
168 // Called back from Registry when the worker instance has ack'ed that 168 // Called back from Registry when the worker instance has ack'ed that its
169 // its WorkerGlobalScope is actually started and parsed. 169 // WorkerGlobalScope has actually started and evaluated the script. This is
170 // called after OnScriptEvaluated.
170 // This will change the internal status from STARTING to RUNNING. 171 // This will change the internal status from STARTING to RUNNING.
171 void OnStarted(); 172 void OnStarted();
172 173
173 void OnPausedAfterDownload(); 174 void OnPausedAfterDownload();
174 175
175 // Called back from Registry when the worker instance has ack'ed that 176 // Called back from Registry when the worker instance has ack'ed that
176 // its WorkerGlobalScope is actually stopped in the child process. 177 // its WorkerGlobalScope is actually stopped in the child process.
177 // This will change the internal status from STARTING or RUNNING to 178 // This will change the internal status from STARTING or RUNNING to
178 // STOPPED. 179 // STOPPED.
179 void OnStopped(); 180 void OnStopped();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 base::TimeTicks start_timing_; 220 base::TimeTicks start_timing_;
220 221
221 base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_; 222 base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_;
222 223
223 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance); 224 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance);
224 }; 225 };
225 226
226 } // namespace content 227 } // namespace content
227 228
228 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ 229 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698