OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/renderer_host/mock_render_process_host.h" | 5 #include "chrome/browser/renderer_host/mock_render_process_host.h" |
6 | 6 |
7 MockRenderProcessHost::MockRenderProcessHost(Profile* profile) | 7 MockRenderProcessHost::MockRenderProcessHost(Profile* profile) |
8 : RenderProcessHost(profile), | 8 : RenderProcessHost(profile), |
9 transport_dib_(NULL), | 9 transport_dib_(NULL), |
10 bad_msg_count_(0) { | 10 bad_msg_count_(0) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 bool MockRenderProcessHost::FastShutdownIfPossible() { | 67 bool MockRenderProcessHost::FastShutdownIfPossible() { |
68 // We aren't actually going to do anything, but set |fast_shutdown_started_| | 68 // We aren't actually going to do anything, but set |fast_shutdown_started_| |
69 // to true so that tests know we've been called. | 69 // to true so that tests know we've been called. |
70 fast_shutdown_started_ = true; | 70 fast_shutdown_started_ = true; |
71 return true; | 71 return true; |
72 } | 72 } |
73 | 73 |
74 bool MockRenderProcessHost::SendWithTimeout(IPC::Message* msg, int timeout_ms) { | 74 bool MockRenderProcessHost::SendWithTimeout(IPC::Message* msg, int timeout_ms) { |
75 // Save the message in the sink. Just ignore timeout_ms. | 75 // Save the message in the sink. Just ignore timeout_ms. |
76 sink_.Send(msg); | 76 sink_.OnMessageReceived(*msg); |
77 delete msg; | 77 delete msg; |
78 return true; | 78 return true; |
79 } | 79 } |
80 | 80 |
81 bool MockRenderProcessHost::Send(IPC::Message* msg) { | 81 bool MockRenderProcessHost::Send(IPC::Message* msg) { |
82 // Save the message in the sink. | 82 // Save the message in the sink. |
83 sink_.Send(msg); | 83 sink_.OnMessageReceived(*msg); |
84 delete msg; | 84 delete msg; |
85 return true; | 85 return true; |
86 } | 86 } |
87 | 87 |
88 TransportDIB* MockRenderProcessHost::GetTransportDIB(TransportDIB::Id dib_id) { | 88 TransportDIB* MockRenderProcessHost::GetTransportDIB(TransportDIB::Id dib_id) { |
89 if (transport_dib_) | 89 if (transport_dib_) |
90 return transport_dib_; | 90 return transport_dib_; |
91 #if defined(OS_WIN) | 91 #if defined(OS_WIN) |
92 HANDLE duped; | 92 HANDLE duped; |
93 DuplicateHandle(GetCurrentProcess(), dib_id.handle, GetCurrentProcess(), | 93 DuplicateHandle(GetCurrentProcess(), dib_id.handle, GetCurrentProcess(), |
94 &duped, 0, TRUE, DUPLICATE_SAME_ACCESS); | 94 &duped, 0, TRUE, DUPLICATE_SAME_ACCESS); |
95 transport_dib_ = TransportDIB::Map(duped); | 95 transport_dib_ = TransportDIB::Map(duped); |
96 #elif defined(OS_MACOSX) | 96 #elif defined(OS_MACOSX) |
97 // On Mac, TransportDIBs are always created in the browser, so we cannot map | 97 // On Mac, TransportDIBs are always created in the browser, so we cannot map |
98 // one from a dib_id. | 98 // one from a dib_id. |
99 transport_dib_ = TransportDIB::Create(100 * 100 * 4, 0); | 99 transport_dib_ = TransportDIB::Create(100 * 100 * 4, 0); |
100 #elif defined(OS_LINUX) | 100 #elif defined(OS_LINUX) |
101 transport_dib_ = TransportDIB::Map(dib_id); | 101 transport_dib_ = TransportDIB::Map(dib_id); |
102 #endif | 102 #endif |
103 | 103 |
104 return transport_dib_; | 104 return transport_dib_; |
105 } | 105 } |
106 | 106 |
107 void MockRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { | 107 void MockRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { |
108 } | 108 } |
109 | 109 |
110 void MockRenderProcessHost::OnChannelConnected(int32 peer_pid) { | 110 void MockRenderProcessHost::OnChannelConnected(int32 peer_pid) { |
111 } | 111 } |
OLD | NEW |