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 #include "content/public/test/mock_render_process_host.h" | 5 #include "content/public/test/mock_render_process_host.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 bool MockRenderProcessHost::Send(IPC::Message* msg) { | 137 bool MockRenderProcessHost::Send(IPC::Message* msg) { |
138 // Save the message in the sink. | 138 // Save the message in the sink. |
139 sink_.OnMessageReceived(*msg); | 139 sink_.OnMessageReceived(*msg); |
140 delete msg; | 140 delete msg; |
141 return true; | 141 return true; |
142 } | 142 } |
143 | 143 |
144 TransportDIB* MockRenderProcessHost::MapTransportDIB(TransportDIB::Id dib_id) { | 144 TransportDIB* MockRenderProcessHost::MapTransportDIB(TransportDIB::Id dib_id) { |
145 #if defined(OS_WIN) | 145 #if defined(OS_WIN) |
146 HANDLE duped; | 146 // NULL should be used here instead of INVALID_HANDLE_VALUE (or pseudo-handle) |
147 DuplicateHandle(GetCurrentProcess(), dib_id.handle, GetCurrentProcess(), | 147 // except for when dealing with the small number of Win16-derived APIs |
148 &duped, 0, TRUE, DUPLICATE_SAME_ACCESS); | 148 // that require INVALID_HANDLE_VALUE (e.g. CreateFile and friends). |
| 149 HANDLE duped = NULL; |
| 150 if (!DuplicateHandle(GetCurrentProcess(), dib_id.handle, GetCurrentProcess(), |
| 151 &duped, 0, TRUE, DUPLICATE_SAME_ACCESS)) |
| 152 duped = NULL; |
149 return TransportDIB::Map(duped); | 153 return TransportDIB::Map(duped); |
150 #elif defined(TOOLKIT_GTK) | 154 #elif defined(TOOLKIT_GTK) |
151 return TransportDIB::Map(dib_id.shmkey); | 155 return TransportDIB::Map(dib_id.shmkey); |
152 #elif defined(OS_ANDROID) | 156 #elif defined(OS_ANDROID) |
153 // On Android, Handles and Ids are the same underlying type. | 157 // On Android, Handles and Ids are the same underlying type. |
154 return TransportDIB::Map(dib_id); | 158 return TransportDIB::Map(dib_id); |
155 #else | 159 #else |
156 // On POSIX, TransportDIBs are always created in the browser, so we cannot map | 160 // On POSIX, TransportDIBs are always created in the browser, so we cannot map |
157 // one from a dib_id. | 161 // one from a dib_id. |
158 return TransportDIB::Create(100 * 100 * 4, 0); | 162 return TransportDIB::Create(100 * 100 * 4, 0); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 for (ScopedVector<MockRenderProcessHost>::iterator it = processes_.begin(); | 307 for (ScopedVector<MockRenderProcessHost>::iterator it = processes_.begin(); |
304 it != processes_.end(); ++it) { | 308 it != processes_.end(); ++it) { |
305 if (*it == host) { | 309 if (*it == host) { |
306 processes_.weak_erase(it); | 310 processes_.weak_erase(it); |
307 break; | 311 break; |
308 } | 312 } |
309 } | 313 } |
310 } | 314 } |
311 | 315 |
312 } // content | 316 } // content |
OLD | NEW |