| OLD | NEW |
| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 protected: | 98 protected: |
| 99 // Called when StartWorker, StopWorker and SendMessageToWorker message | 99 // Called when StartWorker, StopWorker and SendMessageToWorker message |
| 100 // is sent to the embedded worker. Override if necessary. By default | 100 // is sent to the embedded worker. Override if necessary. By default |
| 101 // they verify given parameters and: | 101 // they verify given parameters and: |
| 102 // - OnStartWorker calls SimulateWorkerStarted | 102 // - OnStartWorker calls SimulateWorkerStarted |
| 103 // - OnStopWorker calls SimulateWorkerStoped | 103 // - OnStopWorker calls SimulateWorkerStoped |
| 104 // - OnSendMessageToWorker calls the message's respective On*Event handler | 104 // - OnSendMessageToWorker calls the message's respective On*Event handler |
| 105 virtual void OnStartWorker(int embedded_worker_id, | 105 virtual void OnStartWorker(int embedded_worker_id, |
| 106 int64_t service_worker_version_id, | 106 int64_t service_worker_version_id, |
| 107 const GURL& scope, | 107 const GURL& scope, |
| 108 const GURL& script_url, | 108 const GURL& script_url); |
| 109 bool pause_after_download); | |
| 110 virtual void OnResumeAfterDownload(int embedded_worker_id); | |
| 111 virtual void OnStopWorker(int embedded_worker_id); | 109 virtual void OnStopWorker(int embedded_worker_id); |
| 112 virtual bool OnMessageToWorker(int thread_id, | 110 virtual bool OnMessageToWorker(int thread_id, |
| 113 int embedded_worker_id, | 111 int embedded_worker_id, |
| 114 const IPC::Message& message); | 112 const IPC::Message& message); |
| 115 | 113 |
| 116 // Called to setup mojo for a new embedded worker. Override to register | 114 // Called to setup mojo for a new embedded worker. Override to register |
| 117 // services the worker should expose to the browser. | 115 // services the worker should expose to the browser. |
| 118 virtual void OnSetupMojo(ServiceRegistry* service_registry); | 116 virtual void OnSetupMojo(ServiceRegistry* service_registry); |
| 119 | 117 |
| 120 // On*Event handlers. Called by the default implementation of | 118 // On*Event handlers. Called by the default implementation of |
| (...skipping 19 matching lines...) Expand all Loading... |
| 140 void SimulateWorkerStarted(int embedded_worker_id); | 138 void SimulateWorkerStarted(int embedded_worker_id); |
| 141 void SimulateWorkerStopped(int embedded_worker_id); | 139 void SimulateWorkerStopped(int embedded_worker_id); |
| 142 void SimulateSend(IPC::Message* message); | 140 void SimulateSend(IPC::Message* message); |
| 143 | 141 |
| 144 EmbeddedWorkerRegistry* registry(); | 142 EmbeddedWorkerRegistry* registry(); |
| 145 | 143 |
| 146 private: | 144 private: |
| 147 class MockEmbeddedWorkerSetup; | 145 class MockEmbeddedWorkerSetup; |
| 148 | 146 |
| 149 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); | 147 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); |
| 150 void OnResumeAfterDownloadStub(int embedded_worker_id); | |
| 151 void OnStopWorkerStub(int embedded_worker_id); | 148 void OnStopWorkerStub(int embedded_worker_id); |
| 152 void OnMessageToWorkerStub(int thread_id, | 149 void OnMessageToWorkerStub(int thread_id, |
| 153 int embedded_worker_id, | 150 int embedded_worker_id, |
| 154 const IPC::Message& message); | 151 const IPC::Message& message); |
| 155 void OnActivateEventStub(int request_id); | 152 void OnActivateEventStub(int request_id); |
| 156 void OnInstallEventStub(int request_id); | 153 void OnInstallEventStub(int request_id); |
| 157 void OnFetchEventStub(int request_id, | 154 void OnFetchEventStub(int request_id, |
| 158 const ServiceWorkerFetchRequest& request); | 155 const ServiceWorkerFetchRequest& request); |
| 159 void OnPushEventStub(int request_id, const PushEventPayload& payload); | 156 void OnPushEventStub(int request_id, const PushEventPayload& payload); |
| 160 void OnSetupMojoStub( | 157 void OnSetupMojoStub( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 191 message_port_message_filters_; | 188 message_port_message_filters_; |
| 192 | 189 |
| 193 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; | 190 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; |
| 194 | 191 |
| 195 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); | 192 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); |
| 196 }; | 193 }; |
| 197 | 194 |
| 198 } // namespace content | 195 } // namespace content |
| 199 | 196 |
| 200 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 197 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
| OLD | NEW |