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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/observer_list.h" |
10 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
11 #include "content/public/browser/render_process_host_factory.h" | 12 #include "content/public/browser/render_process_host_factory.h" |
12 #include "ipc/ipc_test_sink.h" | 13 #include "ipc/ipc_test_sink.h" |
13 | 14 |
14 class StoragePartition; | 15 class StoragePartition; |
15 class TransportDIB; | 16 class TransportDIB; |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 class MockRenderProcessHostFactory; | 20 class MockRenderProcessHostFactory; |
(...skipping 11 matching lines...) Expand all Loading... |
31 | 32 |
32 // Provides test access to how many times a bad message has been received. | 33 // Provides test access to how many times a bad message has been received. |
33 int bad_msg_count() const { return bad_msg_count_; } | 34 int bad_msg_count() const { return bad_msg_count_; } |
34 | 35 |
35 // RenderProcessHost implementation (public portion). | 36 // RenderProcessHost implementation (public portion). |
36 virtual void EnableSendQueue() OVERRIDE; | 37 virtual void EnableSendQueue() OVERRIDE; |
37 virtual bool Init() OVERRIDE; | 38 virtual bool Init() OVERRIDE; |
38 virtual int GetNextRoutingID() OVERRIDE; | 39 virtual int GetNextRoutingID() OVERRIDE; |
39 virtual void AddRoute(int32 routing_id, IPC::Listener* listener) OVERRIDE; | 40 virtual void AddRoute(int32 routing_id, IPC::Listener* listener) OVERRIDE; |
40 virtual void RemoveRoute(int32 routing_id) OVERRIDE; | 41 virtual void RemoveRoute(int32 routing_id) OVERRIDE; |
| 42 virtual void AddObserver(RenderProcessHostObserver* observer) OVERRIDE; |
| 43 virtual void RemoveObserver(RenderProcessHostObserver* observer) OVERRIDE; |
41 virtual bool WaitForBackingStoreMsg(int render_widget_id, | 44 virtual bool WaitForBackingStoreMsg(int render_widget_id, |
42 const base::TimeDelta& max_delay, | 45 const base::TimeDelta& max_delay, |
43 IPC::Message* msg) OVERRIDE; | 46 IPC::Message* msg) OVERRIDE; |
44 virtual void ReceivedBadMessage() OVERRIDE; | 47 virtual void ReceivedBadMessage() OVERRIDE; |
45 virtual void WidgetRestored() OVERRIDE; | 48 virtual void WidgetRestored() OVERRIDE; |
46 virtual void WidgetHidden() OVERRIDE; | 49 virtual void WidgetHidden() OVERRIDE; |
47 virtual int VisibleWidgetCount() const OVERRIDE; | 50 virtual int VisibleWidgetCount() const OVERRIDE; |
48 virtual bool IsGuest() const OVERRIDE; | 51 virtual bool IsGuest() const OVERRIDE; |
49 virtual StoragePartition* GetStoragePartition() const OVERRIDE; | 52 virtual StoragePartition* GetStoragePartition() const OVERRIDE; |
50 virtual void AddWord(const string16& word); | 53 virtual void AddWord(const string16& word); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 int GetActiveViewCount(); | 92 int GetActiveViewCount(); |
90 | 93 |
91 private: | 94 private: |
92 // Stores IPC messages that would have been sent to the renderer. | 95 // Stores IPC messages that would have been sent to the renderer. |
93 IPC::TestSink sink_; | 96 IPC::TestSink sink_; |
94 TransportDIB* transport_dib_; | 97 TransportDIB* transport_dib_; |
95 int bad_msg_count_; | 98 int bad_msg_count_; |
96 const MockRenderProcessHostFactory* factory_; | 99 const MockRenderProcessHostFactory* factory_; |
97 int id_; | 100 int id_; |
98 BrowserContext* browser_context_; | 101 BrowserContext* browser_context_; |
| 102 ObserverList<RenderProcessHostObserver> observers_; |
99 | 103 |
100 IDMap<RenderWidgetHost> render_widget_hosts_; | 104 IDMap<RenderWidgetHost> render_widget_hosts_; |
101 int prev_routing_id_; | 105 int prev_routing_id_; |
102 IDMap<IPC::Listener> listeners_; | 106 IDMap<IPC::Listener> listeners_; |
103 bool fast_shutdown_started_; | 107 bool fast_shutdown_started_; |
| 108 bool deletion_callback_called_; |
104 | 109 |
105 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost); | 110 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost); |
106 }; | 111 }; |
107 | 112 |
108 class MockRenderProcessHostFactory : public RenderProcessHostFactory { | 113 class MockRenderProcessHostFactory : public RenderProcessHostFactory { |
109 public: | 114 public: |
110 MockRenderProcessHostFactory(); | 115 MockRenderProcessHostFactory(); |
111 virtual ~MockRenderProcessHostFactory(); | 116 virtual ~MockRenderProcessHostFactory(); |
112 | 117 |
113 virtual RenderProcessHost* CreateRenderProcessHost( | 118 virtual RenderProcessHost* CreateRenderProcessHost( |
(...skipping 10 matching lines...) Expand all Loading... |
124 // for deleting all MockRenderProcessHosts that have not deleted by a test in | 129 // for deleting all MockRenderProcessHosts that have not deleted by a test in |
125 // the destructor and prevent them from being leaked. | 130 // the destructor and prevent them from being leaked. |
126 mutable ScopedVector<MockRenderProcessHost> processes_; | 131 mutable ScopedVector<MockRenderProcessHost> processes_; |
127 | 132 |
128 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); | 133 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); |
129 }; | 134 }; |
130 | 135 |
131 } // namespace content | 136 } // namespace content |
132 | 137 |
133 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ | 138 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ |
OLD | NEW |