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