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