OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ |
6 #define CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ | 6 #define CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
16 #include "content/public/browser/render_process_host_factory.h" | 16 #include "content/public/browser/render_process_host_factory.h" |
| 17 #include "content/public/common/service_registry.h" |
17 #include "ipc/ipc_test_sink.h" | 18 #include "ipc/ipc_test_sink.h" |
18 | 19 |
19 class StoragePartition; | 20 class StoragePartition; |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
23 class MockRenderProcessHostFactory; | 24 class MockRenderProcessHostFactory; |
24 | 25 |
25 // A mock render process host that has no corresponding renderer process. All | 26 // A mock render process host that has no corresponding renderer process. All |
26 // IPC messages are sent into the message sink for inspection by tests. | 27 // IPC messages are sent into the message sink for inspection by tests. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 130 |
130 void SetProcessHandle(scoped_ptr<base::ProcessHandle> new_handle) { | 131 void SetProcessHandle(scoped_ptr<base::ProcessHandle> new_handle) { |
131 process_handle = std::move(new_handle); | 132 process_handle = std::move(new_handle); |
132 } | 133 } |
133 | 134 |
134 void GetAudioOutputControllers( | 135 void GetAudioOutputControllers( |
135 const GetAudioOutputControllersCallback& callback) const override {} | 136 const GetAudioOutputControllersCallback& callback) const override {} |
136 | 137 |
137 int worker_ref_count() const { return worker_ref_count_; } | 138 int worker_ref_count() const { return worker_ref_count_; } |
138 | 139 |
| 140 void SetServiceRegistry(scoped_ptr<ServiceRegistry> service_registry) { |
| 141 service_registry_ = std::move(service_registry); |
| 142 } |
| 143 |
139 private: | 144 private: |
140 // Stores IPC messages that would have been sent to the renderer. | 145 // Stores IPC messages that would have been sent to the renderer. |
141 IPC::TestSink sink_; | 146 IPC::TestSink sink_; |
142 int bad_msg_count_; | 147 int bad_msg_count_; |
143 const MockRenderProcessHostFactory* factory_; | 148 const MockRenderProcessHostFactory* factory_; |
144 int id_; | 149 int id_; |
145 bool has_connection_; | 150 bool has_connection_; |
146 BrowserContext* browser_context_; | 151 BrowserContext* browser_context_; |
147 base::ObserverList<RenderProcessHostObserver> observers_; | 152 base::ObserverList<RenderProcessHostObserver> observers_; |
148 | 153 |
149 IDMap<RenderWidgetHost> render_widget_hosts_; | 154 IDMap<RenderWidgetHost> render_widget_hosts_; |
150 int prev_routing_id_; | 155 int prev_routing_id_; |
151 IDMap<IPC::Listener> listeners_; | 156 IDMap<IPC::Listener> listeners_; |
152 bool fast_shutdown_started_; | 157 bool fast_shutdown_started_; |
153 bool deletion_callback_called_; | 158 bool deletion_callback_called_; |
154 bool is_for_guests_only_; | 159 bool is_for_guests_only_; |
155 bool is_process_backgrounded_; | 160 bool is_process_backgrounded_; |
156 scoped_ptr<base::ProcessHandle> process_handle; | 161 scoped_ptr<base::ProcessHandle> process_handle; |
157 int worker_ref_count_; | 162 int worker_ref_count_; |
| 163 scoped_ptr<ServiceRegistry> service_registry_; |
158 | 164 |
159 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost); | 165 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost); |
160 }; | 166 }; |
161 | 167 |
162 class MockRenderProcessHostFactory : public RenderProcessHostFactory { | 168 class MockRenderProcessHostFactory : public RenderProcessHostFactory { |
163 public: | 169 public: |
164 MockRenderProcessHostFactory(); | 170 MockRenderProcessHostFactory(); |
165 ~MockRenderProcessHostFactory() override; | 171 ~MockRenderProcessHostFactory() override; |
166 | 172 |
167 RenderProcessHost* CreateRenderProcessHost( | 173 RenderProcessHost* CreateRenderProcessHost( |
(...skipping 10 matching lines...) Expand all Loading... |
178 // for deleting all MockRenderProcessHosts that have not deleted by a test in | 184 // for deleting all MockRenderProcessHosts that have not deleted by a test in |
179 // the destructor and prevent them from being leaked. | 185 // the destructor and prevent them from being leaked. |
180 mutable ScopedVector<MockRenderProcessHost> processes_; | 186 mutable ScopedVector<MockRenderProcessHost> processes_; |
181 | 187 |
182 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); | 188 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); |
183 }; | 189 }; |
184 | 190 |
185 } // namespace content | 191 } // namespace content |
186 | 192 |
187 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ | 193 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ |
OLD | NEW |