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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
7 | 7 |
8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 // This is a platform specific function for mapping a transport DIB given its id | 1285 // This is a platform specific function for mapping a transport DIB given its id |
1286 TransportDIB* RenderProcessHostImpl::MapTransportDIB( | 1286 TransportDIB* RenderProcessHostImpl::MapTransportDIB( |
1287 TransportDIB::Id dib_id) { | 1287 TransportDIB::Id dib_id) { |
1288 #if defined(OS_WIN) | 1288 #if defined(OS_WIN) |
1289 // On Windows we need to duplicate the handle from the remote process | 1289 // On Windows we need to duplicate the handle from the remote process |
1290 HANDLE section; | 1290 HANDLE section; |
1291 DuplicateHandle(GetHandle(), dib_id.handle, GetCurrentProcess(), §ion, | 1291 DuplicateHandle(GetHandle(), dib_id.handle, GetCurrentProcess(), §ion, |
1292 FILE_MAP_READ | FILE_MAP_WRITE, | 1292 FILE_MAP_READ | FILE_MAP_WRITE, |
1293 FALSE, 0); | 1293 FALSE, 0); |
1294 return TransportDIB::Map(section); | 1294 return TransportDIB::Map(section); |
1295 #elif defined(TOOLKIT_GTK) | |
1296 return TransportDIB::Map(dib_id.shmkey); | |
1297 #elif defined(OS_ANDROID) | 1295 #elif defined(OS_ANDROID) |
1298 return TransportDIB::Map(dib_id); | 1296 return TransportDIB::Map(dib_id); |
1299 #else | 1297 #else |
1300 // On POSIX, the browser allocates all DIBs and keeps a file descriptor around | 1298 // On POSIX, the browser allocates all DIBs and keeps a file descriptor around |
1301 // for each. | 1299 // for each. |
1302 return widget_helper_->MapTransportDIB(dib_id); | 1300 return widget_helper_->MapTransportDIB(dib_id); |
1303 #endif | 1301 #endif |
1304 } | 1302 } |
1305 | 1303 |
1306 TransportDIB* RenderProcessHostImpl::GetTransportDIB( | 1304 TransportDIB* RenderProcessHostImpl::GetTransportDIB( |
(...skipping 18 matching lines...) Expand all Loading... |
1325 size_t smallest_size = std::numeric_limits<size_t>::max(); | 1323 size_t smallest_size = std::numeric_limits<size_t>::max(); |
1326 | 1324 |
1327 for (std::map<TransportDIB::Id, TransportDIB*>::iterator | 1325 for (std::map<TransportDIB::Id, TransportDIB*>::iterator |
1328 i = cached_dibs_.begin(); i != cached_dibs_.end(); ++i) { | 1326 i = cached_dibs_.begin(); i != cached_dibs_.end(); ++i) { |
1329 if (i->second->size() <= smallest_size) { | 1327 if (i->second->size() <= smallest_size) { |
1330 smallest_iterator = i; | 1328 smallest_iterator = i; |
1331 smallest_size = i->second->size(); | 1329 smallest_size = i->second->size(); |
1332 } | 1330 } |
1333 } | 1331 } |
1334 | 1332 |
1335 #if defined(TOOLKIT_GTK) | |
1336 smallest_iterator->second->Detach(); | |
1337 #else | |
1338 delete smallest_iterator->second; | 1333 delete smallest_iterator->second; |
1339 #endif | |
1340 cached_dibs_.erase(smallest_iterator); | 1334 cached_dibs_.erase(smallest_iterator); |
1341 } | 1335 } |
1342 | 1336 |
1343 cached_dibs_[dib_id] = dib; | 1337 cached_dibs_[dib_id] = dib; |
1344 cached_dibs_cleaner_.Reset(); | 1338 cached_dibs_cleaner_.Reset(); |
1345 return dib; | 1339 return dib; |
1346 } | 1340 } |
1347 | 1341 |
1348 void RenderProcessHostImpl::ClearTransportDIBCache() { | 1342 void RenderProcessHostImpl::ClearTransportDIBCache() { |
1349 #if defined(TOOLKIT_GTK) | |
1350 std::map<TransportDIB::Id, TransportDIB*>::const_iterator dib = | |
1351 cached_dibs_.begin(); | |
1352 for (; dib != cached_dibs_.end(); ++dib) | |
1353 dib->second->Detach(); | |
1354 #else | |
1355 STLDeleteContainerPairSecondPointers( | 1343 STLDeleteContainerPairSecondPointers( |
1356 cached_dibs_.begin(), cached_dibs_.end()); | 1344 cached_dibs_.begin(), cached_dibs_.end()); |
1357 #endif | |
1358 cached_dibs_.clear(); | 1345 cached_dibs_.clear(); |
1359 } | 1346 } |
1360 | 1347 |
1361 bool RenderProcessHostImpl::Send(IPC::Message* msg) { | 1348 bool RenderProcessHostImpl::Send(IPC::Message* msg) { |
1362 TRACE_EVENT0("renderer_host", "RenderProcessHostImpl::Send"); | 1349 TRACE_EVENT0("renderer_host", "RenderProcessHostImpl::Send"); |
1363 if (!channel_) { | 1350 if (!channel_) { |
1364 if (!is_initialized_) { | 1351 if (!is_initialized_) { |
1365 queued_messages_.push(msg); | 1352 queued_messages_.push(msg); |
1366 return true; | 1353 return true; |
1367 } else { | 1354 } else { |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2152 | 2139 |
2153 void RenderProcessHostImpl::SetWebUIHandle( | 2140 void RenderProcessHostImpl::SetWebUIHandle( |
2154 int32 view_routing_id, | 2141 int32 view_routing_id, |
2155 mojo::ScopedMessagePipeHandle handle) { | 2142 mojo::ScopedMessagePipeHandle handle) { |
2156 if (!render_process_host_mojo_) | 2143 if (!render_process_host_mojo_) |
2157 render_process_host_mojo_.reset(new RenderProcessHostMojoImpl(this)); | 2144 render_process_host_mojo_.reset(new RenderProcessHostMojoImpl(this)); |
2158 render_process_host_mojo_->SetWebUIHandle(view_routing_id, handle.Pass()); | 2145 render_process_host_mojo_->SetWebUIHandle(view_routing_id, handle.Pass()); |
2159 } | 2146 } |
2160 | 2147 |
2161 } // namespace content | 2148 } // namespace content |
OLD | NEW |