Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: content/public/test/mock_render_process_host.h

Issue 16431010: Refactor RenderProcessHost to use IPC::Listener instead of RenderWidgetHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing Windows compile error. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
(...skipping 18 matching lines...) Expand all
29 // renderer via this RenderProcessHost. 29 // renderer via this RenderProcessHost.
30 IPC::TestSink& sink() { return sink_; } 30 IPC::TestSink& sink() { return sink_; }
31 31
32 // Provides test access to how many times a bad message has been received. 32 // Provides test access to how many times a bad message has been received.
33 int bad_msg_count() const { return bad_msg_count_; } 33 int bad_msg_count() const { return bad_msg_count_; }
34 34
35 // RenderProcessHost implementation (public portion). 35 // RenderProcessHost implementation (public portion).
36 virtual void EnableSendQueue() OVERRIDE; 36 virtual void EnableSendQueue() OVERRIDE;
37 virtual bool Init() OVERRIDE; 37 virtual bool Init() OVERRIDE;
38 virtual int GetNextRoutingID() OVERRIDE; 38 virtual int GetNextRoutingID() OVERRIDE;
39 virtual void AddRoute(int32 routing_id, IPC::Listener* listener) OVERRIDE;
40 virtual void RemoveRoute(int32 routing_id) OVERRIDE;
39 virtual void SimulateSwapOutACK( 41 virtual void SimulateSwapOutACK(
40 const ViewMsg_SwapOut_Params& params) OVERRIDE; 42 const ViewMsg_SwapOut_Params& params) OVERRIDE;
41 virtual bool WaitForBackingStoreMsg(int render_widget_id, 43 virtual bool WaitForBackingStoreMsg(int render_widget_id,
42 const base::TimeDelta& max_delay, 44 const base::TimeDelta& max_delay,
43 IPC::Message* msg) OVERRIDE; 45 IPC::Message* msg) OVERRIDE;
44 virtual void ReceivedBadMessage() OVERRIDE; 46 virtual void ReceivedBadMessage() OVERRIDE;
45 virtual void WidgetRestored() OVERRIDE; 47 virtual void WidgetRestored() OVERRIDE;
46 virtual void WidgetHidden() OVERRIDE; 48 virtual void WidgetHidden() OVERRIDE;
47 virtual int VisibleWidgetCount() const OVERRIDE; 49 virtual int VisibleWidgetCount() const OVERRIDE;
48 virtual bool IsGuest() const OVERRIDE; 50 virtual bool IsGuest() const OVERRIDE;
49 virtual StoragePartition* GetStoragePartition() const OVERRIDE; 51 virtual StoragePartition* GetStoragePartition() const OVERRIDE;
50 virtual void AddWord(const string16& word); 52 virtual void AddWord(const string16& word);
51 virtual bool FastShutdownIfPossible() OVERRIDE; 53 virtual bool FastShutdownIfPossible() OVERRIDE;
52 virtual bool FastShutdownStarted() const OVERRIDE; 54 virtual bool FastShutdownStarted() const OVERRIDE;
53 virtual void DumpHandles() OVERRIDE; 55 virtual void DumpHandles() OVERRIDE;
54 virtual base::ProcessHandle GetHandle() const OVERRIDE; 56 virtual base::ProcessHandle GetHandle() const OVERRIDE;
55 virtual TransportDIB* MapTransportDIB(TransportDIB::Id dib_id) OVERRIDE; 57 virtual TransportDIB* MapTransportDIB(TransportDIB::Id dib_id) OVERRIDE;
56 virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id) OVERRIDE; 58 virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id) OVERRIDE;
57 virtual int GetID() const OVERRIDE; 59 virtual int GetID() const OVERRIDE;
58 virtual bool HasConnection() const OVERRIDE; 60 virtual bool HasConnection() const OVERRIDE;
59 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; 61 virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE;
60 virtual bool IgnoreInputEvents() const OVERRIDE; 62 virtual bool IgnoreInputEvents() const OVERRIDE;
61 virtual void Attach(RenderWidgetHost* host, int routing_id) OVERRIDE;
62 virtual void Release(int routing_id) OVERRIDE;
63 virtual void Cleanup() OVERRIDE; 63 virtual void Cleanup() OVERRIDE;
64 virtual void AddPendingView() OVERRIDE; 64 virtual void AddPendingView() OVERRIDE;
65 virtual void RemovePendingView() OVERRIDE; 65 virtual void RemovePendingView() OVERRIDE;
66 virtual void SetSuddenTerminationAllowed(bool allowed) OVERRIDE; 66 virtual void SetSuddenTerminationAllowed(bool allowed) OVERRIDE;
67 virtual bool SuddenTerminationAllowed() const OVERRIDE; 67 virtual bool SuddenTerminationAllowed() const OVERRIDE;
68 virtual RenderWidgetHost* GetRenderWidgetHostByID(int routing_id)
69 OVERRIDE;
70 virtual BrowserContext* GetBrowserContext() const OVERRIDE; 68 virtual BrowserContext* GetBrowserContext() const OVERRIDE;
71 virtual bool InSameStoragePartition( 69 virtual bool InSameStoragePartition(
72 StoragePartition* partition) const OVERRIDE; 70 StoragePartition* partition) const OVERRIDE;
73 virtual IPC::ChannelProxy* GetChannel() OVERRIDE; 71 virtual IPC::ChannelProxy* GetChannel() OVERRIDE;
74 virtual RenderWidgetHostsIterator GetRenderWidgetHostsIterator() OVERRIDE;
75 virtual bool FastShutdownForPageCount(size_t count) OVERRIDE; 72 virtual bool FastShutdownForPageCount(size_t count) OVERRIDE;
76 virtual base::TimeDelta GetChildProcessIdleTime() const OVERRIDE; 73 virtual base::TimeDelta GetChildProcessIdleTime() const OVERRIDE;
77 virtual void SurfaceUpdated(int32 surface_id) OVERRIDE; 74 virtual void SurfaceUpdated(int32 surface_id) OVERRIDE;
78 virtual void ResumeRequestsForView(int route_id) OVERRIDE; 75 virtual void ResumeRequestsForView(int route_id) OVERRIDE;
79 76
80 // IPC::Sender via RenderProcessHost. 77 // IPC::Sender via RenderProcessHost.
81 virtual bool Send(IPC::Message* msg) OVERRIDE; 78 virtual bool Send(IPC::Message* msg) OVERRIDE;
82 79
83 // IPC::Listener via RenderProcessHost. 80 // IPC::Listener via RenderProcessHost.
84 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 81 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
85 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 82 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
86 83
87 // Attaches the factory object so we can remove this object in its destructor 84 // Attaches the factory object so we can remove this object in its destructor
88 // and prevent MockRenderProcessHostFacotry from deleting it. 85 // and prevent MockRenderProcessHostFacotry from deleting it.
89 void SetFactory(const MockRenderProcessHostFactory* factory) { 86 void SetFactory(const MockRenderProcessHostFactory* factory) {
90 factory_ = factory; 87 factory_ = factory;
91 } 88 }
92 89
90 int GetActiveViewCount();
91
93 private: 92 private:
94 // Stores IPC messages that would have been sent to the renderer. 93 // Stores IPC messages that would have been sent to the renderer.
95 IPC::TestSink sink_; 94 IPC::TestSink sink_;
96 TransportDIB* transport_dib_; 95 TransportDIB* transport_dib_;
97 int bad_msg_count_; 96 int bad_msg_count_;
98 const MockRenderProcessHostFactory* factory_; 97 const MockRenderProcessHostFactory* factory_;
99 int id_; 98 int id_;
100 BrowserContext* browser_context_; 99 BrowserContext* browser_context_;
101 100
102 IDMap<RenderWidgetHost> render_widget_hosts_; 101 IDMap<RenderWidgetHost> render_widget_hosts_;
102 IDMap<IPC::Listener> listeners_;
103 bool fast_shutdown_started_; 103 bool fast_shutdown_started_;
104 104
105 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost); 105 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost);
106 }; 106 };
107 107
108 class MockRenderProcessHostFactory : public RenderProcessHostFactory { 108 class MockRenderProcessHostFactory : public RenderProcessHostFactory {
109 public: 109 public:
110 MockRenderProcessHostFactory(); 110 MockRenderProcessHostFactory();
111 virtual ~MockRenderProcessHostFactory(); 111 virtual ~MockRenderProcessHostFactory();
112 112
(...skipping 11 matching lines...) Expand all
124 // for deleting all MockRenderProcessHosts that have not deleted by a test in 124 // for deleting all MockRenderProcessHosts that have not deleted by a test in
125 // the destructor and prevent them from being leaked. 125 // the destructor and prevent them from being leaked.
126 mutable ScopedVector<MockRenderProcessHost> processes_; 126 mutable ScopedVector<MockRenderProcessHost> processes_;
127 127
128 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); 128 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory);
129 }; 129 };
130 130
131 } // namespace content 131 } // namespace content
132 132
133 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_ 133 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_PROCESS_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698