| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 CHROME_RENDERER_MOCK_RENDER_THREAD_H_ | 5 #ifndef CHROME_RENDERER_MOCK_RENDER_THREAD_H_ |
| 6 #define CHROME_RENDERER_MOCK_RENDER_THREAD_H_ | 6 #define CHROME_RENDERER_MOCK_RENDER_THREAD_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "chrome/common/ipc_test_sink.h" | 10 #include "chrome/common/ipc_test_sink.h" |
| 11 #include "chrome/renderer/render_thread.h" | 11 #include "chrome/renderer/render_thread.h" |
| 12 | 12 |
| 13 // This class is very simple mock of RenderThread. It simulates an IPC channel | 13 // This class is very simple mock of RenderThread. It simulates an IPC channel |
| 14 // which supports only two messages: | 14 // which supports only two messages: |
| 15 // ViewHostMsg_CreateWidget : sync message sent by the Widget. | 15 // ViewHostMsg_CreateWidget : sync message sent by the Widget. |
| 16 // ViewMsg_Close : async, send to the Widget. | 16 // ViewMsg_Close : async, send to the Widget. |
| 17 class MockRenderThread : public RenderThreadBase { | 17 class MockRenderThread : public RenderThreadBase { |
| 18 public: | 18 public: |
| 19 MockRenderThread(); | 19 MockRenderThread(); |
| 20 virtual ~MockRenderThread(); | 20 virtual ~MockRenderThread(); |
| 21 | 21 |
| 22 // Provides access to the messages that have been received by this thread. | 22 // Provides access to the messages that have been received by this thread. |
| 23 IPC::TestSink& sink() { return sink_; } | 23 IPC::TestSink& sink() { return sink_; } |
| 24 | 24 |
| 25 // Called by the Widget. Not used in the test. | |
| 26 virtual bool InSend() const { | |
| 27 return false; | |
| 28 } | |
| 29 | |
| 30 // Called by the Widget. The routing_id must match the routing id assigned | 25 // Called by the Widget. The routing_id must match the routing id assigned |
| 31 // to the Widget in reply to ViewHostMsg_CreateWidget message. | 26 // to the Widget in reply to ViewHostMsg_CreateWidget message. |
| 32 virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); | 27 virtual void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); |
| 33 | 28 |
| 34 // Called by the Widget. The routing id must match the routing id of AddRoute. | 29 // Called by the Widget. The routing id must match the routing id of AddRoute. |
| 35 virtual void RemoveRoute(int32 routing_id); | 30 virtual void RemoveRoute(int32 routing_id); |
| 36 | 31 |
| 37 // Called by the Widget. Used to send messages to the browser. | 32 // Called by the Widget. Used to send messages to the browser. |
| 38 // We short-circuit the mechanim and handle the messages right here on this | 33 // We short-circuit the mechanim and handle the messages right here on this |
| 39 // class. | 34 // class. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 79 |
| 85 // We only keep track of one Widget, we learn its pointer when it | 80 // We only keep track of one Widget, we learn its pointer when it |
| 86 // adds a new route. | 81 // adds a new route. |
| 87 IPC::Channel::Listener* widget_; | 82 IPC::Channel::Listener* widget_; |
| 88 | 83 |
| 89 // The last known good deserializer for sync messages. | 84 // The last known good deserializer for sync messages. |
| 90 scoped_ptr<IPC::MessageReplyDeserializer> reply_deserializer_; | 85 scoped_ptr<IPC::MessageReplyDeserializer> reply_deserializer_; |
| 91 }; | 86 }; |
| 92 | 87 |
| 93 #endif // CHROME_RENDERER_MOCK_RENDER_THREAD_H_ | 88 #endif // CHROME_RENDERER_MOCK_RENDER_THREAD_H_ |
| OLD | NEW |