Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
|
jam
2011/10/13 17:35:32
nit: it would be better if this file was svn moved
Jói
2011/10/13 18:47:27
Yeah, sorry about that, it's hard to fix now but I
jam
2011/10/13 19:03:44
this won't get automatically fixed on commit, but
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_TEST_MOCK_RENDER_THREAD_H_ | |
| 6 #define CONTENT_TEST_MOCK_RENDER_THREAD_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/shared_memory.h" | |
| 10 #include "content/public/renderer/render_thread.h" | |
| 11 #include "ipc/ipc_test_sink.h" | |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" | |
| 13 | |
| 14 namespace IPC { | |
| 15 class MessageReplyDeserializer; | |
| 16 } | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 class MockRenderThread : public content::RenderThread { | |
|
jam
2011/10/13 17:35:32
nit: add small comment?
Jói
2011/10/13 18:47:27
Done.
| |
| 21 public: | |
| 22 MockRenderThread(); | |
| 23 ~MockRenderThread(); | |
| 24 | |
| 25 // Provides access to the messages that have been received by this thread. | |
| 26 IPC::TestSink& sink() { return sink_; } | |
| 27 | |
| 28 // content::RenderThread implementation: | |
| 29 virtual bool Send(IPC::Message* msg) OVERRIDE; | |
| 30 virtual MessageLoop* GetMessageLoop() OVERRIDE; | |
| 31 virtual IPC::SyncChannel* GetChannel() OVERRIDE; | |
| 32 virtual ResourceDispatcher* GetResourceDispatcher() OVERRIDE; | |
| 33 virtual std::string GetLocale() OVERRIDE; | |
| 34 virtual void AddRoute(int32 routing_id, | |
| 35 IPC::Channel::Listener* listener) OVERRIDE; | |
| 36 virtual void RemoveRoute(int32 routing_id) OVERRIDE; | |
| 37 virtual void AddFilter(IPC::ChannelProxy::MessageFilter* filter) OVERRIDE; | |
| 38 virtual void RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) OVERRIDE; | |
| 39 virtual void SetOutgoingMessageFilter( | |
| 40 IPC::ChannelProxy::OutgoingMessageFilter* filter) OVERRIDE; | |
| 41 virtual void AddObserver(content::RenderProcessObserver* observer) OVERRIDE; | |
| 42 virtual void RemoveObserver( | |
| 43 content::RenderProcessObserver* observer) OVERRIDE; | |
| 44 virtual void WidgetHidden() OVERRIDE; | |
| 45 virtual void WidgetRestored() OVERRIDE; | |
| 46 virtual void EnsureWebKitInitialized() OVERRIDE; | |
| 47 virtual void RecordUserMetrics(const std::string& action) OVERRIDE; | |
| 48 virtual base::SharedMemoryHandle HostAllocateSharedMemoryBuffer( | |
| 49 uint32 buffer_size) OVERRIDE; | |
| 50 virtual void RegisterExtension(v8::Extension* extension) OVERRIDE; | |
| 51 virtual bool IsRegisteredExtension( | |
| 52 const std::string& v8_extension_name) const OVERRIDE; | |
| 53 virtual void ScheduleIdleHandler(double initial_delay_s) OVERRIDE; | |
| 54 virtual void IdleHandler() OVERRIDE; | |
| 55 virtual double GetIdleNotificationDelayInS() const OVERRIDE; | |
| 56 virtual void SetIdleNotificationDelayInS( | |
| 57 double idle_notification_delay_in_s) OVERRIDE; | |
| 58 #if defined(OS_WIN) | |
| 59 virtual void PreCacheFont(const LOGFONT& log_font) OVERRIDE; | |
| 60 virtual void ReleaseCachedFonts() OVERRIDE; | |
| 61 #endif | |
| 62 | |
| 63 ////////////////////////////////////////////////////////////////////////// | |
| 64 // The following functions are called by the test itself. | |
| 65 | |
| 66 void set_routing_id(int32 id) { | |
| 67 routing_id_ = id; | |
| 68 } | |
| 69 | |
| 70 int32 opener_id() const { | |
| 71 return opener_id_; | |
| 72 } | |
| 73 | |
| 74 bool has_widget() const { | |
| 75 return widget_ ? true : false; | |
| 76 } | |
| 77 | |
| 78 // Simulates the Widget receiving a close message. This should result | |
| 79 // on releasing the internal reference counts and destroying the internal | |
| 80 // state. | |
| 81 void SendCloseMessage(); | |
| 82 | |
| 83 protected: | |
| 84 // This function operates as a regular IPC listener. Subclasses | |
| 85 // overriding this should first delegate to this implementation. | |
| 86 virtual bool OnMessageReceived(const IPC::Message& msg); | |
| 87 | |
| 88 // The Widget expects to be returned valid route_id. | |
| 89 void OnMsgCreateWidget(int opener_id, | |
| 90 WebKit::WebPopupType popup_type, | |
| 91 int* route_id); | |
| 92 | |
| 93 #if defined(OS_WIN) | |
| 94 void OnDuplicateSection(base::SharedMemoryHandle renderer_handle, | |
| 95 base::SharedMemoryHandle* browser_handle); | |
| 96 #endif | |
| 97 | |
| 98 IPC::TestSink sink_; | |
| 99 | |
| 100 // Routing id what will be assigned to the Widget. | |
| 101 int32 routing_id_; | |
| 102 | |
| 103 // Opener id reported by the Widget. | |
| 104 int32 opener_id_; | |
| 105 | |
| 106 // We only keep track of one Widget, we learn its pointer when it | |
| 107 // adds a new route. | |
| 108 IPC::Channel::Listener* widget_; | |
| 109 | |
| 110 // The last known good deserializer for sync messages. | |
| 111 scoped_ptr<IPC::MessageReplyDeserializer> reply_deserializer_; | |
| 112 }; | |
| 113 | |
| 114 } // namespace content | |
| 115 | |
| 116 #endif // CONTENT_TEST_MOCK_RENDER_THREAD_H_ | |
| OLD | NEW |