| 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/renderer/render_process_impl.h" | 5 #include "content/renderer/render_process_impl.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 | 107 |
| 108 int RenderProcessImpl::GetEnabledBindings() const { | 108 int RenderProcessImpl::GetEnabledBindings() const { |
| 109 return enabled_bindings_; | 109 return enabled_bindings_; |
| 110 } | 110 } |
| 111 | 111 |
| 112 // ----------------------------------------------------------------------------- | 112 // ----------------------------------------------------------------------------- |
| 113 // Platform specific code for dealing with bitmap transport... | 113 // Platform specific code for dealing with bitmap transport... |
| 114 | 114 |
| 115 TransportDIB* RenderProcessImpl::CreateTransportDIB(size_t size) { | 115 TransportDIB* RenderProcessImpl::CreateTransportDIB(size_t size) { |
| 116 #if defined(OS_WIN) || defined(OS_LINUX) || \ | 116 #if defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID) |
| 117 defined(OS_OPENBSD) || defined(OS_ANDROID) | 117 // POSIX creates transport DIBs in the browser, so we need to do a sync IPC to |
| 118 // Windows and Linux create transport DIBs inside the renderer | |
| 119 return TransportDIB::Create(size, transport_dib_next_sequence_number_++); | |
| 120 #elif defined(OS_MACOSX) | |
| 121 // Mac creates transport DIBs in the browser, so we need to do a sync IPC to | |
| 122 // get one. The TransportDIB is cached in the browser. | 118 // get one. The TransportDIB is cached in the browser. |
| 123 TransportDIB::Handle handle; | 119 TransportDIB::Handle handle; |
| 124 IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(size, true, &handle); | 120 IPC::Message* msg = new ViewHostMsg_AllocTransportDIB(size, true, &handle); |
| 125 if (!main_thread()->Send(msg)) | 121 if (!main_thread()->Send(msg)) |
| 126 return NULL; | 122 return NULL; |
| 127 if (handle.fd < 0) | 123 if (handle.fd < 0) |
| 128 return NULL; | 124 return NULL; |
| 129 return TransportDIB::Map(handle); | 125 return TransportDIB::Map(handle); |
| 130 #endif // defined(OS_MACOSX) | 126 #else |
| 127 // Windows, legacy GTK and Android create transport DIBs inside the |
| 128 // renderer. |
| 129 return TransportDIB::Create(size, transport_dib_next_sequence_number_++); |
| 130 #endif |
| 131 } | 131 } |
| 132 | 132 |
| 133 void RenderProcessImpl::FreeTransportDIB(TransportDIB* dib) { | 133 void RenderProcessImpl::FreeTransportDIB(TransportDIB* dib) { |
| 134 if (!dib) | 134 if (!dib) |
| 135 return; | 135 return; |
| 136 | 136 |
| 137 #if defined(OS_MACOSX) | 137 #if defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID) |
| 138 // On Mac we need to tell the browser that it can drop a reference to the | 138 // On POSIX we need to tell the browser that it can drop a reference to the |
| 139 // shared memory. | 139 // shared memory. |
| 140 IPC::Message* msg = new ViewHostMsg_FreeTransportDIB(dib->id()); | 140 IPC::Message* msg = new ViewHostMsg_FreeTransportDIB(dib->id()); |
| 141 main_thread()->Send(msg); | 141 main_thread()->Send(msg); |
| 142 #endif | 142 #endif |
| 143 | 143 |
| 144 delete dib; | 144 delete dib; |
| 145 } | 145 } |
| 146 | 146 |
| 147 // ----------------------------------------------------------------------------- | 147 // ----------------------------------------------------------------------------- |
| 148 | 148 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 void RenderProcessImpl::ClearTransportDIBCache() { | 243 void RenderProcessImpl::ClearTransportDIBCache() { |
| 244 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { | 244 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { |
| 245 if (shared_mem_cache_[i]) { | 245 if (shared_mem_cache_[i]) { |
| 246 FreeTransportDIB(shared_mem_cache_[i]); | 246 FreeTransportDIB(shared_mem_cache_[i]); |
| 247 shared_mem_cache_[i] = NULL; | 247 shared_mem_cache_[i] = NULL; |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace content | 252 } // namespace content |
| OLD | NEW |