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/metrics/persistent_memory_allocator.h" | 14 #include "base/metrics/persistent_memory_allocator.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
17 #include "content/public/browser/render_process_host_factory.h" | 17 #include "content/public/browser/render_process_host_factory.h" |
18 #include "content/public/common/service_registry.h" | |
19 #include "ipc/ipc_test_sink.h" | 18 #include "ipc/ipc_test_sink.h" |
| 19 #include "services/shell/public/cpp/interface_provider.h" |
| 20 #include "services/shell/public/cpp/interface_registry.h" |
20 | 21 |
21 class StoragePartition; | 22 class StoragePartition; |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 | 25 |
25 class MockRenderProcessHostFactory; | 26 class MockRenderProcessHostFactory; |
26 | 27 |
27 // A mock render process host that has no corresponding renderer process. All | 28 // A mock render process host that has no corresponding renderer process. All |
28 // IPC messages are sent into the message sink for inspection by tests. | 29 // IPC messages are sent into the message sink for inspection by tests. |
29 class MockRenderProcessHost : public RenderProcessHost { | 30 class MockRenderProcessHost : public RenderProcessHost { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 void SetWebRtcLogMessageCallback( | 87 void SetWebRtcLogMessageCallback( |
87 base::Callback<void(const std::string&)> callback) override; | 88 base::Callback<void(const std::string&)> callback) override; |
88 void ClearWebRtcLogMessageCallback() override; | 89 void ClearWebRtcLogMessageCallback() override; |
89 WebRtcStopRtpDumpCallback StartRtpDump( | 90 WebRtcStopRtpDumpCallback StartRtpDump( |
90 bool incoming, | 91 bool incoming, |
91 bool outgoing, | 92 bool outgoing, |
92 const WebRtcRtpPacketCallback& packet_callback) override; | 93 const WebRtcRtpPacketCallback& packet_callback) override; |
93 #endif | 94 #endif |
94 void ResumeDeferredNavigation(const GlobalRequestID& request_id) override; | 95 void ResumeDeferredNavigation(const GlobalRequestID& request_id) override; |
95 void NotifyTimezoneChange(const std::string& zone_id) override; | 96 void NotifyTimezoneChange(const std::string& zone_id) override; |
96 ServiceRegistry* GetServiceRegistry() override; | 97 shell::InterfaceRegistry* GetInterfaceRegistry() override; |
| 98 shell::InterfaceProvider* GetRemoteInterfaces() override; |
97 shell::Connection* GetChildConnection() override; | 99 shell::Connection* GetChildConnection() override; |
98 std::unique_ptr<base::SharedPersistentMemoryAllocator> TakeMetricsAllocator() | 100 std::unique_ptr<base::SharedPersistentMemoryAllocator> TakeMetricsAllocator() |
99 override; | 101 override; |
100 const base::TimeTicks& GetInitTimeForNavigationMetrics() const override; | 102 const base::TimeTicks& GetInitTimeForNavigationMetrics() const override; |
101 #if defined(ENABLE_BROWSER_CDMS) | 103 #if defined(ENABLE_BROWSER_CDMS) |
102 scoped_refptr<media::MediaKeys> GetCdm(int render_frame_id, | 104 scoped_refptr<media::MediaKeys> GetCdm(int render_frame_id, |
103 int cdm_id) const override; | 105 int cdm_id) const override; |
104 #endif | 106 #endif |
105 bool IsProcessBackgrounded() const override; | 107 bool IsProcessBackgrounded() const override; |
106 void IncrementWorkerRefCount() override; | 108 void IncrementWorkerRefCount() override; |
(...skipping 23 matching lines...) Expand all Loading... |
130 | 132 |
131 void SetProcessHandle(std::unique_ptr<base::ProcessHandle> new_handle) { | 133 void SetProcessHandle(std::unique_ptr<base::ProcessHandle> new_handle) { |
132 process_handle = std::move(new_handle); | 134 process_handle = std::move(new_handle); |
133 } | 135 } |
134 | 136 |
135 void GetAudioOutputControllers( | 137 void GetAudioOutputControllers( |
136 const GetAudioOutputControllersCallback& callback) const override {} | 138 const GetAudioOutputControllersCallback& callback) const override {} |
137 | 139 |
138 int worker_ref_count() const { return worker_ref_count_; } | 140 int worker_ref_count() const { return worker_ref_count_; } |
139 | 141 |
140 void SetServiceRegistry(std::unique_ptr<ServiceRegistry> service_registry) { | 142 void SetInterfaceRegistry( |
141 service_registry_ = std::move(service_registry); | 143 std::unique_ptr<shell::InterfaceRegistry> interface_registry) { |
| 144 interface_registry_ = std::move(interface_registry); |
| 145 } |
| 146 void SetRemoteInterfaces( |
| 147 std::unique_ptr<shell::InterfaceProvider> remote_interfaces) { |
| 148 remote_interfaces_ = std::move(remote_interfaces); |
142 } | 149 } |
143 | 150 |
144 private: | 151 private: |
145 // Stores IPC messages that would have been sent to the renderer. | 152 // Stores IPC messages that would have been sent to the renderer. |
146 IPC::TestSink sink_; | 153 IPC::TestSink sink_; |
147 int bad_msg_count_; | 154 int bad_msg_count_; |
148 const MockRenderProcessHostFactory* factory_; | 155 const MockRenderProcessHostFactory* factory_; |
149 int id_; | 156 int id_; |
150 bool has_connection_; | 157 bool has_connection_; |
151 BrowserContext* browser_context_; | 158 BrowserContext* browser_context_; |
152 base::ObserverList<RenderProcessHostObserver> observers_; | 159 base::ObserverList<RenderProcessHostObserver> observers_; |
153 | 160 |
154 IDMap<RenderWidgetHost> render_widget_hosts_; | 161 IDMap<RenderWidgetHost> render_widget_hosts_; |
155 int prev_routing_id_; | 162 int prev_routing_id_; |
156 IDMap<IPC::Listener> listeners_; | 163 IDMap<IPC::Listener> listeners_; |
157 bool fast_shutdown_started_; | 164 bool fast_shutdown_started_; |
158 bool deletion_callback_called_; | 165 bool deletion_callback_called_; |
159 bool is_for_guests_only_; | 166 bool is_for_guests_only_; |
160 bool is_process_backgrounded_; | 167 bool is_process_backgrounded_; |
161 std::unique_ptr<base::ProcessHandle> process_handle; | 168 std::unique_ptr<base::ProcessHandle> process_handle; |
162 int worker_ref_count_; | 169 int worker_ref_count_; |
163 std::unique_ptr<ServiceRegistry> service_registry_; | 170 std::unique_ptr<shell::InterfaceRegistry> interface_registry_; |
| 171 std::unique_ptr<shell::InterfaceProvider> remote_interfaces_; |
164 | 172 |
165 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost); | 173 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost); |
166 }; | 174 }; |
167 | 175 |
168 class MockRenderProcessHostFactory : public RenderProcessHostFactory { | 176 class MockRenderProcessHostFactory : public RenderProcessHostFactory { |
169 public: | 177 public: |
170 MockRenderProcessHostFactory(); | 178 MockRenderProcessHostFactory(); |
171 ~MockRenderProcessHostFactory() override; | 179 ~MockRenderProcessHostFactory() override; |
172 | 180 |
173 RenderProcessHost* CreateRenderProcessHost( | 181 RenderProcessHost* CreateRenderProcessHost( |
(...skipping 10 matching lines...) Expand all Loading... |
184 // for deleting all MockRenderProcessHosts that have not deleted by a test in | 192 // for deleting all MockRenderProcessHosts that have not deleted by a test in |
185 // the destructor and prevent them from being leaked. | 193 // the destructor and prevent them from being leaked. |
186 mutable ScopedVector<MockRenderProcessHost> processes_; | 194 mutable ScopedVector<MockRenderProcessHost> processes_; |
187 | 195 |
188 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); | 196 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); |
189 }; | 197 }; |
190 | 198 |
191 } // namespace content | 199 } // namespace content |
192 | 200 |
193 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ | 201 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ |
OLD | NEW |