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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 | 65 |
66 // IPC sink for EmbeddedWorker messages. | 66 // IPC sink for EmbeddedWorker messages. |
67 IPC::TestSink* ipc_sink() { return &sink_; } | 67 IPC::TestSink* ipc_sink() { return &sink_; } |
68 // Inner IPC sink for script context messages sent via EmbeddedWorker. | 68 // Inner IPC sink for script context messages sent via EmbeddedWorker. |
69 IPC::TestSink* inner_ipc_sink() { return &inner_sink_; } | 69 IPC::TestSink* inner_ipc_sink() { return &inner_sink_; } |
70 | 70 |
71 ServiceWorkerContextCore* context(); | 71 ServiceWorkerContextCore* context(); |
72 ServiceWorkerContextWrapper* context_wrapper() { return wrapper_.get(); } | 72 ServiceWorkerContextWrapper* context_wrapper() { return wrapper_.get(); } |
73 void ShutdownContext(); | 73 void ShutdownContext(); |
74 | 74 |
75 int next_thread_id() { return next_thread_id_; } | |
76 void set_next_thread_id(int next_thread_id) { | |
77 next_thread_id_ = next_thread_id; | |
78 } | |
falken
2016/01/05 04:21:16
How about a GetNextThreadId() instead that takes c
jungkees
2016/01/06 02:57:54
Yes, that'd be better. Done.
| |
79 | |
75 int mock_render_process_id() const { return mock_render_process_id_;} | 80 int mock_render_process_id() const { return mock_render_process_id_;} |
81 | |
82 std::map<int, int64> embedded_worker_id_service_worker_version_id_map() { | |
falken
2016/01/05 04:21:16
int64_t
jungkees
2016/01/06 02:57:54
Done.
| |
83 return embedded_worker_id_service_worker_version_id_map_; | |
84 } | |
85 | |
76 // Mock render process. Only set if the one-parameter constructor was used. | 86 // Mock render process. Only set if the one-parameter constructor was used. |
77 MockRenderProcessHost* mock_render_process_host() { | 87 MockRenderProcessHost* mock_render_process_host() { |
78 return render_process_host_.get(); | 88 return render_process_host_.get(); |
79 } | 89 } |
80 | 90 |
81 TestBrowserContext* browser_context() { return browser_context_.get(); } | 91 TestBrowserContext* browser_context() { return browser_context_.get(); } |
82 | 92 |
83 protected: | 93 protected: |
84 // Called when StartWorker, StopWorker and SendMessageToWorker message | 94 // Called when StartWorker, StopWorker and SendMessageToWorker message |
85 // is sent to the embedded worker. Override if necessary. By default | 95 // is sent to the embedded worker. Override if necessary. By default |
(...skipping 22 matching lines...) Expand all Loading... | |
108 virtual void OnPushEvent(int embedded_worker_id, | 118 virtual void OnPushEvent(int embedded_worker_id, |
109 int request_id, | 119 int request_id, |
110 const std::string& data); | 120 const std::string& data); |
111 | 121 |
112 // These functions simulate sending an EmbeddedHostMsg message to the | 122 // These functions simulate sending an EmbeddedHostMsg message to the |
113 // browser. | 123 // browser. |
114 void SimulateWorkerReadyForInspection(int embedded_worker_id); | 124 void SimulateWorkerReadyForInspection(int embedded_worker_id); |
115 void SimulateWorkerScriptCached(int embedded_worker_id); | 125 void SimulateWorkerScriptCached(int embedded_worker_id); |
116 void SimulateWorkerScriptLoaded(int embedded_worker_id); | 126 void SimulateWorkerScriptLoaded(int embedded_worker_id); |
117 void SimulateWorkerThreadStarted(int thread_id, int embedded_worker_id); | 127 void SimulateWorkerThreadStarted(int thread_id, int embedded_worker_id); |
118 void SimulateWorkerScriptEvaluated(int embedded_worker_id); | 128 void SimulateWorkerScriptEvaluated(int embedded_worker_id, bool success); |
119 void SimulateWorkerStarted(int embedded_worker_id); | 129 void SimulateWorkerStarted(int embedded_worker_id); |
120 void SimulateWorkerStopped(int embedded_worker_id); | 130 void SimulateWorkerStopped(int embedded_worker_id); |
121 void SimulateSend(IPC::Message* message); | 131 void SimulateSend(IPC::Message* message); |
122 | 132 |
123 EmbeddedWorkerRegistry* registry(); | 133 EmbeddedWorkerRegistry* registry(); |
124 | 134 |
125 private: | 135 private: |
126 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); | 136 void OnStartWorkerStub(const EmbeddedWorkerMsg_StartWorker_Params& params); |
127 void OnStopWorkerStub(int embedded_worker_id); | 137 void OnStopWorkerStub(int embedded_worker_id); |
128 void OnMessageToWorkerStub(int thread_id, | 138 void OnMessageToWorkerStub(int thread_id, |
(...skipping 27 matching lines...) Expand all Loading... | |
156 message_port_message_filters_; | 166 message_port_message_filters_; |
157 | 167 |
158 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; | 168 base::WeakPtrFactory<EmbeddedWorkerTestHelper> weak_factory_; |
159 | 169 |
160 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); | 170 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerTestHelper); |
161 }; | 171 }; |
162 | 172 |
163 } // namespace content | 173 } // namespace content |
164 | 174 |
165 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ | 175 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ |
OLD | NEW |