| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // SimulateSendReplyToBrowser. |
| 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, int request_id); |
| 96 int request_id, | |
| 97 int active_version_id); | |
| 98 virtual void OnFetchEvent(int embedded_worker_id, | 96 virtual void OnFetchEvent(int embedded_worker_id, |
| 99 int request_id, | 97 int request_id, |
| 100 const ServiceWorkerFetchRequest& request); | 98 const ServiceWorkerFetchRequest& request); |
| 101 | 99 |
| 102 // These functions simulate sending an EmbeddedHostMsg message to the | 100 // These functions simulate sending an EmbeddedHostMsg message to the |
| 103 // browser. | 101 // browser. |
| 104 void SimulatePausedAfterDownload(int embedded_worker_id); | 102 void SimulatePausedAfterDownload(int embedded_worker_id); |
| 105 void SimulateWorkerReadyForInspection(int embedded_worker_id); | 103 void SimulateWorkerReadyForInspection(int embedded_worker_id); |
| 106 void SimulateWorkerScriptLoaded(int thread_id, int embedded_worker_id); | 104 void SimulateWorkerScriptLoaded(int thread_id, int embedded_worker_id); |
| 107 void SimulateWorkerScriptEvaluated(int embedded_worker_id); | 105 void SimulateWorkerScriptEvaluated(int embedded_worker_id); |
| 108 void SimulateWorkerStarted(int embedded_worker_id); | 106 void SimulateWorkerStarted(int embedded_worker_id); |
| 109 void SimulateWorkerStopped(int embedded_worker_id); | 107 void SimulateWorkerStopped(int embedded_worker_id); |
| 110 void SimulateSend(IPC::Message* message); | 108 void SimulateSend(IPC::Message* message); |
| 111 | 109 |
| 112 EmbeddedWorkerRegistry* registry(); | 110 EmbeddedWorkerRegistry* registry(); |
| 113 | 111 |
| 114 private: | 112 private: |
| 115 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); | 113 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); |
| 116 void OnResumeAfterDownloadStub(int embedded_worker_id); | 114 void OnResumeAfterDownloadStub(int embedded_worker_id); |
| 117 void OnStopWorkerStub(int embedded_worker_id); | 115 void OnStopWorkerStub(int embedded_worker_id); |
| 118 void OnMessageToWorkerStub(int thread_id, | 116 void OnMessageToWorkerStub(int thread_id, |
| 119 int embedded_worker_id, | 117 int embedded_worker_id, |
| 120 const IPC::Message& message); | 118 const IPC::Message& message); |
| 121 void OnActivateEventStub(int request_id); | 119 void OnActivateEventStub(int request_id); |
| 122 void OnInstallEventStub(int request_id, int active_version_id); | 120 void OnInstallEventStub(int request_id); |
| 123 void OnFetchEventStub(int request_id, | 121 void OnFetchEventStub(int request_id, |
| 124 const ServiceWorkerFetchRequest& request); | 122 const ServiceWorkerFetchRequest& request); |
| 125 | 123 |
| 126 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; | 124 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; |
| 127 | 125 |
| 128 IPC::TestSink sink_; | 126 IPC::TestSink sink_; |
| 129 IPC::TestSink inner_sink_; | 127 IPC::TestSink inner_sink_; |
| 130 | 128 |
| 131 int next_thread_id_; | 129 int next_thread_id_; |
| 132 int mock_render_process_id_; | 130 int mock_render_process_id_; |
| 133 | 131 |
| 134 // Updated each time MessageToWorker message is received. | 132 // Updated each time MessageToWorker message is received. |
| 135 int current_embedded_worker_id_; | 133 int current_embedded_worker_id_; |
| 136 | 134 |
| 137 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; | 135 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; |
| 138 | 136 |
| 139 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); | 137 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); |
| 140 }; | 138 }; |
| 141 | 139 |
| 142 } // namespace content | 140 } // namespace content |
| 143 | 141 |
| 144 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 142 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
| OLD | NEW |