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

Side by Side Diff: content/browser/renderer_host/mock_render_process_host.h

Issue 8515027: Define the public version of the browser side RenderProcessHost interface. This interface is not ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_BROWSER_RENDERER_HOST_MOCK_RENDER_PROCESS_HOST_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MOCK_RENDER_PROCESS_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MOCK_RENDER_PROCESS_HOST_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_MOCK_RENDER_PROCESS_HOST_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
11 #include "content/browser/renderer_host/render_process_host.h" 11 #include "content/public/browser/render_process_host.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 MockRenderProcessHostFactory; 15 class MockRenderProcessHostFactory;
15 class TransportDIB; 16 class TransportDIB;
16 17
17 // A mock render process host that has no corresponding renderer process. All 18 // A mock render process host that has no corresponding renderer process. All
18 // IPC messages are sent into the message sink for inspection by tests. 19 // IPC messages are sent into the message sink for inspection by tests.
19 class MockRenderProcessHost : public RenderProcessHost { 20 class MockRenderProcessHost : public content::RenderProcessHost {
20 public: 21 public:
21 explicit MockRenderProcessHost(content::BrowserContext* browser_context); 22 explicit MockRenderProcessHost(content::BrowserContext* browser_context);
22 virtual ~MockRenderProcessHost(); 23 virtual ~MockRenderProcessHost();
23 24
24 // Provides access to all IPC messages that would have been sent to the 25 // Provides access to all IPC messages that would have been sent to the
25 // renderer via this RenderProcessHost. 26 // renderer via this RenderProcessHost.
26 IPC::TestSink& sink() { return sink_; } 27 IPC::TestSink& sink() { return sink_; }
27 28
28 // Provides tests access to the max page ID currently used for this process. 29 // Provides tests access to the max page ID currently used for this process.
29 int max_page_id() const { return max_page_id_; } 30 int max_page_id() const { return max_page_id_; }
30 31
31 // 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.
32 int bad_msg_count() const { return bad_msg_count_; } 33 int bad_msg_count() const { return bad_msg_count_; }
33 34
34 // RenderProcessHost implementation (public portion). 35 // RenderProcessHost implementation (public portion).
35 virtual void EnableSendQueue() OVERRIDE; 36 virtual void EnableSendQueue() OVERRIDE;
36 virtual bool Init(bool is_accessibility_enabled) OVERRIDE; 37 virtual bool Init(bool is_accessibility_enabled) OVERRIDE;
37 virtual int GetNextRoutingID() OVERRIDE; 38 virtual int GetNextRoutingID() OVERRIDE;
38 virtual void CancelResourceRequests(int render_widget_id) OVERRIDE; 39 virtual void CancelResourceRequests(int render_widget_id) OVERRIDE;
39 virtual void CrossSiteSwapOutACK( 40 virtual void CrossSiteSwapOutACK(
40 const ViewMsg_SwapOut_Params& params) OVERRIDE; 41 const ViewMsg_SwapOut_Params& params) OVERRIDE;
41 virtual bool WaitForUpdateMsg(int render_widget_id, 42 virtual bool WaitForUpdateMsg(int render_widget_id,
42 const base::TimeDelta& max_delay, 43 const base::TimeDelta& max_delay,
43 IPC::Message* msg) OVERRIDE; 44 IPC::Message* msg) OVERRIDE;
44 virtual void ReceivedBadMessage() OVERRIDE; 45 virtual void ReceivedBadMessage() OVERRIDE;
45 virtual void WidgetRestored() OVERRIDE; 46 virtual void WidgetRestored() OVERRIDE;
46 virtual void WidgetHidden() OVERRIDE; 47 virtual void WidgetHidden() OVERRIDE;
47 virtual int VisibleWidgetCount() const OVERRIDE; 48 virtual int VisibleWidgetCount() const OVERRIDE;
48 virtual void AddWord(const string16& word); 49 virtual void AddWord(const string16& word);
49 virtual bool FastShutdownIfPossible() OVERRIDE; 50 virtual bool FastShutdownIfPossible();
50 virtual void DumpHandles() OVERRIDE; 51 virtual bool FastShutdownStarted() const;
51 virtual base::ProcessHandle GetHandle() OVERRIDE; 52 virtual void DumpHandles();
52 virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id) OVERRIDE; 53 virtual base::ProcessHandle GetHandle();
54 virtual TransportDIB* GetTransportDIB(TransportDIB::Id dib_id);
53 virtual void SetCompositingSurface( 55 virtual void SetCompositingSurface(
54 int render_widget_id, 56 int render_widget_id,
55 gfx::PluginWindowHandle compositing_surface) OVERRIDE; 57 gfx::PluginWindowHandle compositing_surface) OVERRIDE;
58 virtual int GetID() const;
59 virtual bool HasConnection() const;
60 virtual void SetIgnoreInputEvents(bool ignore_input_events);
61 virtual bool IgnoreInputEvents() const;
62 virtual void Attach(IPC::Channel::Listener* listener, int routing_id);
63 virtual void Release(int listener_id);
64 virtual void Cleanup();
65 virtual void ReportExpectingClose(int32 listener_id);
66 virtual void AddPendingView();
67 virtual void RemovePendingView();
68 virtual void SetSuddenTerminationAllowed(bool allowed);
69 virtual bool SuddenTerminationAllowed() const;
70 virtual void UpdateMaxPageID(int32 page_id);
71 virtual IPC::Channel::Listener* GetListenerByID(int routing_id);
72 virtual content::BrowserContext* GetBrowserContext() const;
73 virtual IPC::ChannelProxy* GetChannel();
74 virtual listeners_iterator ListenersIterator();
75 virtual bool FastShutdownForPageCount(size_t count);
76 virtual base::TimeDelta GetChildProcessIdleTime() const;
77 virtual void UpdateAndSendMaxPageID(int32 page_id);
56 78
57 // IPC::Channel::Sender via RenderProcessHost. 79 // IPC::Channel::Sender via RenderProcessHost.
58 virtual bool Send(IPC::Message* msg) OVERRIDE; 80 virtual bool Send(IPC::Message* msg) OVERRIDE;
59 81
60 // IPC::Channel::Listener via RenderProcessHost. 82 // IPC::Channel::Listener via RenderProcessHost.
61 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 83 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
62 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 84 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
63 85
64 // Attaches the factory object so we can remove this object in its destructor 86 // Attaches the factory object so we can remove this object in its destructor
65 // and prevent MockRenderProcessHostFacotry from deleting it. 87 // and prevent MockRenderProcessHostFacotry from deleting it.
66 void SetFactory(const MockRenderProcessHostFactory* factory) { 88 void SetFactory(const MockRenderProcessHostFactory* factory) {
67 factory_ = factory; 89 factory_ = factory;
68 } 90 }
69 91
70 private: 92 private:
71 // Stores IPC messages that would have been sent to the renderer. 93 // Stores IPC messages that would have been sent to the renderer.
72 IPC::TestSink sink_; 94 IPC::TestSink sink_;
73 TransportDIB* transport_dib_; 95 TransportDIB* transport_dib_;
74 int bad_msg_count_; 96 int bad_msg_count_;
75 const MockRenderProcessHostFactory* factory_; 97 const MockRenderProcessHostFactory* factory_;
98 int id_;
99 content::BrowserContext* browser_context_;
100 int32 max_page_id_;
101
102 IDMap<IPC::Channel::Listener> listeners_;
103 bool fast_shutdown_started_;
76 104
77 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost); 105 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHost);
78 }; 106 };
79 107
80 class MockRenderProcessHostFactory : public RenderProcessHostFactory { 108 class MockRenderProcessHostFactory : public content::RenderProcessHostFactory {
81 public: 109 public:
82 MockRenderProcessHostFactory(); 110 MockRenderProcessHostFactory();
83 virtual ~MockRenderProcessHostFactory(); 111 virtual ~MockRenderProcessHostFactory();
84 112
85 virtual RenderProcessHost* CreateRenderProcessHost( 113 virtual content::RenderProcessHost* CreateRenderProcessHost(
86 content::BrowserContext* browser_context) const OVERRIDE; 114 content::BrowserContext* browser_context) const OVERRIDE;
87 115
88 // Removes the given MockRenderProcessHost from the MockRenderProcessHost list 116 // Removes the given MockRenderProcessHost from the MockRenderProcessHost list
89 // without deleting it. When a test deletes a MockRenderProcessHost, we need 117 // without deleting it. When a test deletes a MockRenderProcessHost, we need
90 // to remove it from |processes_| to prevent it from being deleted twice. 118 // to remove it from |processes_| to prevent it from being deleted twice.
91 void Remove(MockRenderProcessHost* host) const; 119 void Remove(MockRenderProcessHost* host) const;
92 120
93 private: 121 private:
94 // A list of MockRenderProcessHosts created by this object. This list is used 122 // A list of MockRenderProcessHosts created by this object. This list is used
95 // for deleting all MockRenderProcessHosts that have not deleted by a test in 123 // for deleting all MockRenderProcessHosts that have not deleted by a test in
96 // the destructor and prevent them from being leaked. 124 // the destructor and prevent them from being leaked.
97 mutable ScopedVector<MockRenderProcessHost> processes_; 125 mutable ScopedVector<MockRenderProcessHost> processes_;
98 126
99 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory); 127 DISALLOW_COPY_AND_ASSIGN(MockRenderProcessHostFactory);
100 }; 128 };
101 129
102 #endif // CONTENT_BROWSER_RENDERER_HOST_MOCK_RENDER_PROCESS_HOST_H_ 130 #endif // CONTENT_BROWSER_RENDERER_HOST_MOCK_RENDER_PROCESS_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698