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.h" | 8 #include "base/message_loop.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 delete msg; | 115 delete msg; |
116 return true; | 116 return true; |
117 } | 117 } |
118 | 118 |
119 TransportDIB* MockRenderProcessHost::MapTransportDIB(TransportDIB::Id dib_id) { | 119 TransportDIB* MockRenderProcessHost::MapTransportDIB(TransportDIB::Id dib_id) { |
120 #if defined(OS_WIN) | 120 #if defined(OS_WIN) |
121 HANDLE duped; | 121 HANDLE duped; |
122 DuplicateHandle(GetCurrentProcess(), dib_id.handle, GetCurrentProcess(), | 122 DuplicateHandle(GetCurrentProcess(), dib_id.handle, GetCurrentProcess(), |
123 &duped, 0, TRUE, DUPLICATE_SAME_ACCESS); | 123 &duped, 0, TRUE, DUPLICATE_SAME_ACCESS); |
124 return TransportDIB::Map(duped); | 124 return TransportDIB::Map(duped); |
125 #elif defined(OS_MACOSX) | 125 #elif defined(TOOLKIT_GTK) |
126 // On Mac, TransportDIBs are always created in the browser, so we cannot map | 126 return TransportDIB::Map(dib_id.shmkey); |
127 // one from a dib_id. | |
128 return TransportDIB::Create(100 * 100 * 4, 0); | |
129 #elif defined(OS_ANDROID) | 127 #elif defined(OS_ANDROID) |
130 // On Android, Handles and Ids are the same underlying type. | 128 // On Android, Handles and Ids are the same underlying type. |
131 return TransportDIB::Map(dib_id); | 129 return TransportDIB::Map(dib_id); |
132 #elif defined(OS_POSIX) | 130 #else |
133 return TransportDIB::Map(dib_id.shmkey); | 131 // On POSIX, TransportDIBs are always created in the browser, so we cannot map |
| 132 // one from a dib_id. |
| 133 return TransportDIB::Create(100 * 100 * 4, 0); |
134 #endif | 134 #endif |
135 } | 135 } |
136 | 136 |
137 TransportDIB* MockRenderProcessHost::GetTransportDIB(TransportDIB::Id dib_id) { | 137 TransportDIB* MockRenderProcessHost::GetTransportDIB(TransportDIB::Id dib_id) { |
138 if (transport_dib_) | 138 if (transport_dib_) |
139 return transport_dib_; | 139 return transport_dib_; |
140 | 140 |
141 transport_dib_ = MapTransportDIB(dib_id); | 141 transport_dib_ = MapTransportDIB(dib_id); |
142 return transport_dib_; | 142 return transport_dib_; |
143 } | 143 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 for (ScopedVector<MockRenderProcessHost>::iterator it = processes_.begin(); | 266 for (ScopedVector<MockRenderProcessHost>::iterator it = processes_.begin(); |
267 it != processes_.end(); ++it) { | 267 it != processes_.end(); ++it) { |
268 if (*it == host) { | 268 if (*it == host) { |
269 processes_.weak_erase(it); | 269 processes_.weak_erase(it); |
270 break; | 270 break; |
271 } | 271 } |
272 } | 272 } |
273 } | 273 } |
274 | 274 |
275 } // content | 275 } // content |
OLD | NEW |