| 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" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "ipc/ipc_listener.h" | 12 #include "ipc/ipc_listener.h" |
| 13 #include "ipc/ipc_test_sink.h" | 13 #include "ipc/ipc_test_sink.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 struct EmbeddedWorkerMsg_StartWorker_Params; | 17 struct EmbeddedWorkerMsg_StartWorker_Params; |
| 18 class GURL; | 18 class GURL; |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 class EmbeddedWorkerRegistry; | 22 class EmbeddedWorkerRegistry; |
| 23 class EmbeddedWorkerTestHelper; | 23 class EmbeddedWorkerTestHelper; |
| 24 class MessagePortMessageFilter; |
| 24 class ServiceWorkerContextCore; | 25 class ServiceWorkerContextCore; |
| 25 class ServiceWorkerContextWrapper; | 26 class ServiceWorkerContextWrapper; |
| 26 struct ServiceWorkerFetchRequest; | 27 struct ServiceWorkerFetchRequest; |
| 27 | 28 |
| 28 // In-Process EmbeddedWorker test helper. | 29 // In-Process EmbeddedWorker test helper. |
| 29 // | 30 // |
| 30 // Usage: create an instance of this class to test browser-side embedded worker | 31 // Usage: create an instance of this class to test browser-side embedded worker |
| 31 // code without creating a child process. This class will create a | 32 // code without creating a child process. This class will create a |
| 32 // ServiceWorkerContextWrapper and ServiceWorkerContextCore for you. | 33 // ServiceWorkerContextWrapper and ServiceWorkerContextCore for you. |
| 33 // | 34 // |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 void OnResumeAfterDownloadStub(int embedded_worker_id); | 118 void OnResumeAfterDownloadStub(int embedded_worker_id); |
| 118 void OnStopWorkerStub(int embedded_worker_id); | 119 void OnStopWorkerStub(int embedded_worker_id); |
| 119 void OnMessageToWorkerStub(int thread_id, | 120 void OnMessageToWorkerStub(int thread_id, |
| 120 int embedded_worker_id, | 121 int embedded_worker_id, |
| 121 const IPC::Message& message); | 122 const IPC::Message& message); |
| 122 void OnActivateEventStub(int request_id); | 123 void OnActivateEventStub(int request_id); |
| 123 void OnInstallEventStub(int request_id); | 124 void OnInstallEventStub(int request_id); |
| 124 void OnFetchEventStub(int request_id, | 125 void OnFetchEventStub(int request_id, |
| 125 const ServiceWorkerFetchRequest& request); | 126 const ServiceWorkerFetchRequest& request); |
| 126 | 127 |
| 128 MessagePortMessageFilter* NewMessagePortMessageFilter(); |
| 129 |
| 127 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; | 130 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; |
| 128 | 131 |
| 129 IPC::TestSink sink_; | 132 IPC::TestSink sink_; |
| 130 IPC::TestSink inner_sink_; | 133 IPC::TestSink inner_sink_; |
| 131 | 134 |
| 132 int next_thread_id_; | 135 int next_thread_id_; |
| 133 int mock_render_process_id_; | 136 int mock_render_process_id_; |
| 134 | 137 |
| 135 std::map<int, int64> embedded_worker_id_service_worker_version_id_map_; | 138 std::map<int, int64> embedded_worker_id_service_worker_version_id_map_; |
| 136 | 139 |
| 137 // Updated each time MessageToWorker message is received. | 140 // Updated each time MessageToWorker message is received. |
| 138 int current_embedded_worker_id_; | 141 int current_embedded_worker_id_; |
| 139 | 142 |
| 143 std::vector<scoped_refptr<MessagePortMessageFilter>> |
| 144 message_port_message_filters_; |
| 145 |
| 140 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; | 146 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; |
| 141 | 147 |
| 142 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); | 148 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); |
| 143 }; | 149 }; |
| 144 | 150 |
| 145 } // namespace content | 151 } // namespace content |
| 146 | 152 |
| 147 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 153 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
| OLD | NEW |