| 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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 int mock_render_process_id() const { return mock_render_process_id_;} | 75 int mock_render_process_id() const { return mock_render_process_id_;} |
| 76 | 76 |
| 77 protected: | 77 protected: |
| 78 // Called when StartWorker, StopWorker and SendMessageToWorker message | 78 // Called when StartWorker, StopWorker and SendMessageToWorker message |
| 79 // is sent to the embedded worker. Override if necessary. By default | 79 // is sent to the embedded worker. Override if necessary. By default |
| 80 // they verify given parameters and: | 80 // they verify given parameters and: |
| 81 // - OnStartWorker calls SimulateWorkerStarted | 81 // - OnStartWorker calls SimulateWorkerStarted |
| 82 // - OnStopWorker calls SimulateWorkerStoped | 82 // - OnStopWorker calls SimulateWorkerStoped |
| 83 // - OnSendMessageToWorker calls the message's respective On*Event handler | 83 // - OnSendMessageToWorker calls the message's respective On*Event handler |
| 84 virtual void OnStartWorker(int embedded_worker_id, | 84 virtual void OnStartWorker(int embedded_worker_id, |
| 85 int64 service_worker_version_id, | 85 std::string service_worker_version_uuid, |
| 86 const GURL& scope, | 86 const GURL& scope, |
| 87 const GURL& script_url, | 87 const GURL& script_url, |
| 88 bool pause_after_download); | 88 bool pause_after_download); |
| 89 virtual void OnResumeAfterDownload(int embedded_worker_id); | 89 virtual void OnResumeAfterDownload(int embedded_worker_id); |
| 90 virtual void OnStopWorker(int embedded_worker_id); | 90 virtual void OnStopWorker(int embedded_worker_id); |
| 91 virtual bool OnMessageToWorker(int thread_id, | 91 virtual bool OnMessageToWorker(int thread_id, |
| 92 int embedded_worker_id, | 92 int embedded_worker_id, |
| 93 const IPC::Message& message); | 93 const IPC::Message& message); |
| 94 | 94 |
| 95 // On*Event handlers. Called by the default implementation of | 95 // On*Event handlers. Called by the default implementation of |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 MessagePortMessageFilter* NewMessagePortMessageFilter(); | 134 MessagePortMessageFilter* NewMessagePortMessageFilter(); |
| 135 | 135 |
| 136 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; | 136 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; |
| 137 | 137 |
| 138 IPC::TestSink sink_; | 138 IPC::TestSink sink_; |
| 139 IPC::TestSink inner_sink_; | 139 IPC::TestSink inner_sink_; |
| 140 | 140 |
| 141 int next_thread_id_; | 141 int next_thread_id_; |
| 142 int mock_render_process_id_; | 142 int mock_render_process_id_; |
| 143 | 143 |
| 144 std::map<int, int64> embedded_worker_id_service_worker_version_id_map_; | 144 std::map<int, std::string> |
| 145 embedded_worker_id_service_worker_version_uuid_map_; |
| 145 | 146 |
| 146 // Updated each time MessageToWorker message is received. | 147 // Updated each time MessageToWorker message is received. |
| 147 int current_embedded_worker_id_; | 148 int current_embedded_worker_id_; |
| 148 | 149 |
| 149 std::vector<scoped_refptr<MessagePortMessageFilter>> | 150 std::vector<scoped_refptr<MessagePortMessageFilter>> |
| 150 message_port_message_filters_; | 151 message_port_message_filters_; |
| 151 | 152 |
| 152 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; | 153 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; |
| 153 | 154 |
| 154 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); | 155 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); |
| 155 }; | 156 }; |
| 156 | 157 |
| 157 } // namespace content | 158 } // namespace content |
| 158 | 159 |
| 159 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 160 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
| OLD | NEW |