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 HANDLE duped; |
sky
2014/03/05 17:36:50
Can you instead explicitly set to duped to NULL he
zhaoqin
2014/03/05 19:09:42
I think it is better to set on failure instead of
| |
147 DuplicateHandle(GetCurrentProcess(), dib_id.handle, GetCurrentProcess(), | 147 if (!DuplicateHandle(GetCurrentProcess(), dib_id.handle, GetCurrentProcess(), |
148 &duped, 0, TRUE, DUPLICATE_SAME_ACCESS); | 148 &duped, 0, TRUE, DUPLICATE_SAME_ACCESS)) |
149 duped = NULL; | |
Will Harris
2014/03/05 17:40:35
should this be INVALID_HANDLE_VALUE?
jschuh
2014/03/05 17:52:03
No. INVALID_HANDLE_VALUE can bite you because it a
| |
149 return TransportDIB::Map(duped); | 150 return TransportDIB::Map(duped); |
150 #elif defined(TOOLKIT_GTK) | 151 #elif defined(TOOLKIT_GTK) |
151 return TransportDIB::Map(dib_id.shmkey); | 152 return TransportDIB::Map(dib_id.shmkey); |
152 #elif defined(OS_ANDROID) | 153 #elif defined(OS_ANDROID) |
153 // On Android, Handles and Ids are the same underlying type. | 154 // On Android, Handles and Ids are the same underlying type. |
154 return TransportDIB::Map(dib_id); | 155 return TransportDIB::Map(dib_id); |
155 #else | 156 #else |
156 // On POSIX, TransportDIBs are always created in the browser, so we cannot map | 157 // On POSIX, TransportDIBs are always created in the browser, so we cannot map |
157 // one from a dib_id. | 158 // one from a dib_id. |
158 return TransportDIB::Create(100 * 100 * 4, 0); | 159 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(); | 304 for (ScopedVector<MockRenderProcessHost>::iterator it = processes_.begin(); |
304 it != processes_.end(); ++it) { | 305 it != processes_.end(); ++it) { |
305 if (*it == host) { | 306 if (*it == host) { |
306 processes_.weak_erase(it); | 307 processes_.weak_erase(it); |
307 break; | 308 break; |
308 } | 309 } |
309 } | 310 } |
310 } | 311 } |
311 | 312 |
312 } // content | 313 } // content |
OLD | NEW |