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_THREAD_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_MOCK_RENDER_THREAD_H_ |
6 #define CONTENT_PUBLIC_TEST_MOCK_RENDER_THREAD_H_ | 6 #define CONTENT_PUBLIC_TEST_MOCK_RENDER_THREAD_H_ |
7 | 7 |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace content { | 23 namespace content { |
24 | 24 |
25 // This class is a very simple mock of RenderThread. It simulates an IPC channel | 25 // This class is a very simple mock of RenderThread. It simulates an IPC channel |
26 // which supports only three messages: | 26 // which supports only three messages: |
27 // ViewHostMsg_CreateWidget : sync message sent by the Widget. | 27 // ViewHostMsg_CreateWidget : sync message sent by the Widget. |
28 // ViewHostMsg_CreateWindow : sync message sent by the Widget. | 28 // ViewHostMsg_CreateWindow : sync message sent by the Widget. |
29 // ViewMsg_Close : async, send to the Widget. | 29 // ViewMsg_Close : async, send to the Widget. |
30 class MockRenderThread : public RenderThread { | 30 class MockRenderThread : public RenderThread { |
31 public: | 31 public: |
32 MockRenderThread(); | 32 MockRenderThread(); |
33 virtual ~MockRenderThread(); | 33 ~MockRenderThread() override; |
34 | 34 |
35 // Provides access to the messages that have been received by this thread. | 35 // Provides access to the messages that have been received by this thread. |
36 IPC::TestSink& sink() { return sink_; } | 36 IPC::TestSink& sink() { return sink_; } |
37 | 37 |
38 // RenderThread implementation: | 38 // RenderThread implementation: |
39 virtual bool Send(IPC::Message* msg) override; | 39 bool Send(IPC::Message* msg) override; |
40 virtual base::MessageLoop* GetMessageLoop() override; | 40 base::MessageLoop* GetMessageLoop() override; |
41 virtual IPC::SyncChannel* GetChannel() override; | 41 IPC::SyncChannel* GetChannel() override; |
42 virtual std::string GetLocale() override; | 42 std::string GetLocale() override; |
43 virtual IPC::SyncMessageFilter* GetSyncMessageFilter() override; | 43 IPC::SyncMessageFilter* GetSyncMessageFilter() override; |
44 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() | 44 scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() override; |
45 override; | 45 void AddRoute(int32 routing_id, IPC::Listener* listener) override; |
46 virtual void AddRoute(int32 routing_id, IPC::Listener* listener) override; | 46 void RemoveRoute(int32 routing_id) override; |
47 virtual void RemoveRoute(int32 routing_id) override; | 47 int GenerateRoutingID() override; |
48 virtual int GenerateRoutingID() override; | 48 void AddFilter(IPC::MessageFilter* filter) override; |
49 virtual void AddFilter(IPC::MessageFilter* filter) override; | 49 void RemoveFilter(IPC::MessageFilter* filter) override; |
50 virtual void RemoveFilter(IPC::MessageFilter* filter) override; | 50 void AddObserver(RenderProcessObserver* observer) override; |
51 virtual void AddObserver(RenderProcessObserver* observer) override; | 51 void RemoveObserver(RenderProcessObserver* observer) override; |
52 virtual void RemoveObserver(RenderProcessObserver* observer) override; | 52 void SetResourceDispatcherDelegate( |
53 virtual void SetResourceDispatcherDelegate( | |
54 ResourceDispatcherDelegate* delegate) override; | 53 ResourceDispatcherDelegate* delegate) override; |
55 virtual void EnsureWebKitInitialized() override; | 54 void EnsureWebKitInitialized() override; |
56 virtual void RecordAction(const base::UserMetricsAction& action) override; | 55 void RecordAction(const base::UserMetricsAction& action) override; |
57 virtual void RecordComputedAction(const std::string& action) override; | 56 void RecordComputedAction(const std::string& action) override; |
58 virtual scoped_ptr<base::SharedMemory> HostAllocateSharedMemoryBuffer( | 57 scoped_ptr<base::SharedMemory> HostAllocateSharedMemoryBuffer( |
59 size_t buffer_size) override; | 58 size_t buffer_size) override; |
60 virtual void RegisterExtension(v8::Extension* extension) override; | 59 void RegisterExtension(v8::Extension* extension) override; |
61 virtual void ScheduleIdleHandler(int64 initial_delay_ms) override; | 60 void ScheduleIdleHandler(int64 initial_delay_ms) override; |
62 virtual void IdleHandler() override; | 61 void IdleHandler() override; |
63 virtual int64 GetIdleNotificationDelayInMs() const override; | 62 int64 GetIdleNotificationDelayInMs() const override; |
64 virtual void SetIdleNotificationDelayInMs( | 63 void SetIdleNotificationDelayInMs( |
65 int64 idle_notification_delay_in_ms) override; | 64 int64 idle_notification_delay_in_ms) override; |
66 virtual void UpdateHistograms(int sequence_number) override; | 65 void UpdateHistograms(int sequence_number) override; |
67 virtual int PostTaskToAllWebWorkers(const base::Closure& closure) override; | 66 int PostTaskToAllWebWorkers(const base::Closure& closure) override; |
68 virtual bool ResolveProxy(const GURL& url, std::string* proxy_list) override; | 67 bool ResolveProxy(const GURL& url, std::string* proxy_list) override; |
69 virtual base::WaitableEvent* GetShutdownEvent() override; | 68 base::WaitableEvent* GetShutdownEvent() override; |
70 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
71 virtual void PreCacheFont(const LOGFONT& log_font) override; | 70 virtual void PreCacheFont(const LOGFONT& log_font) override; |
72 virtual void ReleaseCachedFonts() override; | 71 virtual void ReleaseCachedFonts() override; |
73 #endif | 72 #endif |
74 virtual ServiceRegistry* GetServiceRegistry() override; | 73 ServiceRegistry* GetServiceRegistry() override; |
75 | 74 |
76 ////////////////////////////////////////////////////////////////////////// | 75 ////////////////////////////////////////////////////////////////////////// |
77 // The following functions are called by the test itself. | 76 // The following functions are called by the test itself. |
78 | 77 |
79 void set_routing_id(int32 id) { | 78 void set_routing_id(int32 id) { |
80 routing_id_ = id; | 79 routing_id_ = id; |
81 } | 80 } |
82 | 81 |
83 void set_surface_id(int32 id) { | 82 void set_surface_id(int32 id) { |
84 surface_id_ = id; | 83 surface_id_ = id; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // A list of message filters added to this thread. | 160 // A list of message filters added to this thread. |
162 std::vector<scoped_refptr<IPC::MessageFilter> > filters_; | 161 std::vector<scoped_refptr<IPC::MessageFilter> > filters_; |
163 | 162 |
164 // Observers to notify. | 163 // Observers to notify. |
165 ObserverList<RenderProcessObserver> observers_; | 164 ObserverList<RenderProcessObserver> observers_; |
166 }; | 165 }; |
167 | 166 |
168 } // namespace content | 167 } // namespace content |
169 | 168 |
170 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_THREAD_H_ | 169 #endif // CONTENT_PUBLIC_TEST_MOCK_RENDER_THREAD_H_ |
OLD | NEW |