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 class GURL; | 18 class GURL; |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 class EmbeddedWorkerRegistry; | 22 class EmbeddedWorkerRegistry; |
22 class EmbeddedWorkerTestHelper; | 23 class EmbeddedWorkerTestHelper; |
23 class ServiceWorkerContextCore; | 24 class ServiceWorkerContextCore; |
24 class ServiceWorkerContextWrapper; | 25 class ServiceWorkerContextWrapper; |
25 struct ServiceWorkerFetchRequest; | 26 struct ServiceWorkerFetchRequest; |
26 | 27 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // These functions simulate sending an EmbeddedHostMsg message to the | 98 // These functions simulate sending an EmbeddedHostMsg message to the |
98 // browser. | 99 // browser. |
99 void SimulateWorkerStarted(int thread_id, int embedded_worker_id); | 100 void SimulateWorkerStarted(int thread_id, int embedded_worker_id); |
100 void SimulateWorkerStopped(int embedded_worker_id); | 101 void SimulateWorkerStopped(int embedded_worker_id); |
101 void SimulateSend(IPC::Message* message); | 102 void SimulateSend(IPC::Message* message); |
102 | 103 |
103 protected: | 104 protected: |
104 EmbeddedWorkerRegistry* registry(); | 105 EmbeddedWorkerRegistry* registry(); |
105 | 106 |
106 private: | 107 private: |
107 void OnStartWorkerStub(int embedded_worker_id, | 108 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); |
108 int64 service_worker_version_id, | |
109 const GURL& scope, | |
110 const GURL& script_url); | |
111 void OnStopWorkerStub(int embedded_worker_id); | 109 void OnStopWorkerStub(int embedded_worker_id); |
112 void OnMessageToWorkerStub(int thread_id, | 110 void OnMessageToWorkerStub(int thread_id, |
113 int embedded_worker_id, | 111 int embedded_worker_id, |
114 const IPC::Message& message); | 112 const IPC::Message& message); |
115 void OnActivateEventStub(int request_id); | 113 void OnActivateEventStub(int request_id); |
116 void OnInstallEventStub(int request_id, int active_version_id); | 114 void OnInstallEventStub(int request_id, int active_version_id); |
117 void OnFetchEventStub(int request_id, | 115 void OnFetchEventStub(int request_id, |
118 const ServiceWorkerFetchRequest& request); | 116 const ServiceWorkerFetchRequest& request); |
119 | 117 |
120 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; | 118 scoped_refptr<ServiceWorkerContextWrapper> wrapper_; |
121 | 119 |
122 IPC::TestSink sink_; | 120 IPC::TestSink sink_; |
123 IPC::TestSink inner_sink_; | 121 IPC::TestSink inner_sink_; |
124 | 122 |
125 int next_thread_id_; | 123 int next_thread_id_; |
126 | 124 |
127 // Updated each time MessageToWorker message is received. | 125 // Updated each time MessageToWorker message is received. |
128 int current_embedded_worker_id_; | 126 int current_embedded_worker_id_; |
129 | 127 |
130 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; | 128 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; |
131 | 129 |
132 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); | 130 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); |
133 }; | 131 }; |
134 | 132 |
135 } // namespace content | 133 } // namespace content |
136 | 134 |
137 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 135 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
OLD | NEW |