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

Side by Side Diff: content/browser/service_worker/embedded_worker_test_helper.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: rebase? 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 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_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 bool pause_after_download); 83 bool pause_after_download);
84 virtual void OnResumeAfterDownload(int embedded_worker_id); 84 virtual void OnResumeAfterDownload(int embedded_worker_id);
85 virtual void OnStopWorker(int embedded_worker_id); 85 virtual void OnStopWorker(int embedded_worker_id);
86 virtual bool OnMessageToWorker(int thread_id, 86 virtual bool OnMessageToWorker(int thread_id,
87 int embedded_worker_id, 87 int embedded_worker_id,
88 const IPC::Message& message); 88 const IPC::Message& message);
89 89
90 // On*Event handlers. Called by the default implementation of 90 // On*Event handlers. Called by the default implementation of
91 // OnMessageToWorker when events are sent to the embedded 91 // OnMessageToWorker when events are sent to the embedded
92 // worker. By default they just return success via 92 // worker. By default they just return success via
93 // SimulateSendReplyToBrowser. 93 // SimulateSend.
94 virtual void OnActivateEvent(int embedded_worker_id, int request_id); 94 virtual void OnActivateEvent(int embedded_worker_id, int request_id);
95 virtual void OnInstallEvent(int embedded_worker_id, 95 virtual void OnInstallEvent(int embedded_worker_id,
96 int request_id, 96 int request_id,
97 int active_version_id); 97 int active_version_id);
98 virtual void OnFetchEvent(int embedded_worker_id, 98 virtual void OnFetchEvent(int embedded_worker_id,
99 int request_id, 99 int request_id,
100 const ServiceWorkerFetchRequest& request); 100 const ServiceWorkerFetchRequest& request);
101 101
102 // These functions simulate sending an EmbeddedHostMsg message to the 102 // These functions simulate sending an EmbeddedHostMsg message to the
103 // browser. 103 // browser.
104 void SimulatePausedAfterDownload(int embedded_worker_id); 104 void SimulatePausedAfterDownload(int embedded_worker_id);
105 void SimulateWorkerReadyForInspection(int embedded_worker_id); 105 void SimulateWorkerReadyForInspection(int embedded_worker_id);
106 void SimulateWorkerScriptLoaded(int thread_id, int embedded_worker_id); 106 void SimulateWorkerScriptLoaded(int thread_id, int embedded_worker_id);
107 void SimulateWorkerScriptEvaluated(int embedded_worker_id); 107 void SimulateWorkerScriptEvaluated(int embedded_worker_id);
108 void SimulateWorkerStarted(int embedded_worker_id); 108 void SimulateWorkerStarted(int embedded_worker_id);
109 void SimulateWorkerStopped(int embedded_worker_id); 109 void SimulateWorkerStopped(int embedded_worker_id);
110 void SimulateSend(IPC::Message* message); 110 void SimulateSend(IPC::Message* message);
111 111
112 EmbeddedWorkerRegistry* registry(); 112 EmbeddedWorkerRegistry* registry();
113 113
114 int next_thread_id_;
kinuko 2015/02/10 09:15:51 nit: could we have a simple method like GetNextThr
115
114 private: 116 private:
115 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); 117 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params);
116 void OnResumeAfterDownloadStub(int embedded_worker_id); 118 void OnResumeAfterDownloadStub(int embedded_worker_id);
117 void OnStopWorkerStub(int embedded_worker_id); 119 void OnStopWorkerStub(int embedded_worker_id);
118 void OnMessageToWorkerStub(int thread_id, 120 void OnMessageToWorkerStub(int thread_id,
119 int embedded_worker_id, 121 int embedded_worker_id,
120 const IPC::Message& message); 122 const IPC::Message& message);
121 void OnActivateEventStub(int request_id); 123 void OnActivateEventStub(int request_id);
122 void OnInstallEventStub(int request_id, int active_version_id); 124 void OnInstallEventStub(int request_id, int active_version_id);
123 void OnFetchEventStub(int request_id, 125 void OnFetchEventStub(int request_id,
124 const ServiceWorkerFetchRequest& request); 126 const ServiceWorkerFetchRequest& request);
125 127
126 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; 128 scoped_refptr<ServiceWorkerContextWrapper> wrapper_;
127 129
128 IPC::TestSink sink_; 130 IPC::TestSink sink_;
129 IPC::TestSink inner_sink_; 131 IPC::TestSink inner_sink_;
130 132
131 int next_thread_id_;
132 int mock_render_process_id_; 133 int mock_render_process_id_;
133 134
134 // Updated each time MessageToWorker message is received. 135 // Updated each time MessageToWorker message is received.
135 int current_embedded_worker_id_; 136 int current_embedded_worker_id_;
136 137
137 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; 138 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_;
138 139
139 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); 140 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper);
140 }; 141 };
141 142
142 } // namespace content 143 } // namespace content
143 144
144 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ 145 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698