Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 247263005: Remove TransportDIB methods from RenderProcess(Host) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 StoragePartitionImpl* storage_partition_impl, 387 StoragePartitionImpl* storage_partition_impl,
388 bool is_guest) 388 bool is_guest)
389 : fast_shutdown_started_(false), 389 : fast_shutdown_started_(false),
390 deleting_soon_(false), 390 deleting_soon_(false),
391 #ifndef NDEBUG 391 #ifndef NDEBUG
392 is_self_deleted_(false), 392 is_self_deleted_(false),
393 #endif 393 #endif
394 pending_views_(0), 394 pending_views_(0),
395 visible_widgets_(0), 395 visible_widgets_(0),
396 backgrounded_(true), 396 backgrounded_(true),
397 cached_dibs_cleaner_(FROM_HERE,
398 base::TimeDelta::FromSeconds(5),
399 this,
400 &RenderProcessHostImpl::ClearTransportDIBCache),
401 is_initialized_(false), 397 is_initialized_(false),
402 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), 398 id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()),
403 browser_context_(browser_context), 399 browser_context_(browser_context),
404 storage_partition_impl_(storage_partition_impl), 400 storage_partition_impl_(storage_partition_impl),
405 sudden_termination_allowed_(true), 401 sudden_termination_allowed_(true),
406 ignore_input_events_(false), 402 ignore_input_events_(false),
407 is_guest_(is_guest), 403 is_guest_(is_guest),
408 gpu_observer_registered_(false), 404 gpu_observer_registered_(false),
409 delayed_cleanup_needed_(false), 405 delayed_cleanup_needed_(false),
410 within_process_died_observer_(false), 406 within_process_died_observer_(false),
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 gpu_observer_registered_ = false; 480 gpu_observer_registered_ = false;
485 } 481 }
486 482
487 // We may have some unsent messages at this point, but that's OK. 483 // We may have some unsent messages at this point, but that's OK.
488 channel_.reset(); 484 channel_.reset();
489 while (!queued_messages_.empty()) { 485 while (!queued_messages_.empty()) {
490 delete queued_messages_.front(); 486 delete queued_messages_.front();
491 queued_messages_.pop(); 487 queued_messages_.pop();
492 } 488 }
493 489
494 ClearTransportDIBCache();
495 UnregisterHost(GetID()); 490 UnregisterHost(GetID());
496 491
497 if (!CommandLine::ForCurrentProcess()->HasSwitch( 492 if (!CommandLine::ForCurrentProcess()->HasSwitch(
498 switches::kDisableGpuShaderDiskCache)) { 493 switches::kDisableGpuShaderDiskCache)) {
499 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 494 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
500 base::Bind(&RemoveShaderInfo, GetID())); 495 base::Bind(&RemoveShaderInfo, GetID()));
501 } 496 }
502 } 497 }
503 498
504 void RenderProcessHostImpl::EnableSendQueue() { 499 void RenderProcessHostImpl::EnableSendQueue() {
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 } 1250 }
1256 1251
1257 void RenderProcessHostImpl::DumpHandles() { 1252 void RenderProcessHostImpl::DumpHandles() {
1258 #if defined(OS_WIN) 1253 #if defined(OS_WIN)
1259 Send(new ChildProcessMsg_DumpHandles()); 1254 Send(new ChildProcessMsg_DumpHandles());
1260 #else 1255 #else
1261 NOTIMPLEMENTED(); 1256 NOTIMPLEMENTED();
1262 #endif 1257 #endif
1263 } 1258 }
1264 1259
1265 // This is a platform specific function for mapping a transport DIB given its id
1266 TransportDIB* RenderProcessHostImpl::MapTransportDIB(
1267 TransportDIB::Id dib_id) {
1268 #if defined(OS_WIN)
1269 // On Windows we need to duplicate the handle from the remote process
1270 HANDLE section;
1271 DuplicateHandle(GetHandle(), dib_id.handle, GetCurrentProcess(), &section,
1272 FILE_MAP_READ | FILE_MAP_WRITE,
1273 FALSE, 0);
1274 return TransportDIB::Map(section);
1275 #elif defined(OS_ANDROID)
1276 return TransportDIB::Map(dib_id);
1277 #else
1278 // On POSIX, the browser allocates all DIBs and keeps a file descriptor around
1279 // for each.
1280 return widget_helper_->MapTransportDIB(dib_id);
1281 #endif
1282 }
1283
1284 TransportDIB* RenderProcessHostImpl::GetTransportDIB(
1285 TransportDIB::Id dib_id) {
1286 if (!TransportDIB::is_valid_id(dib_id))
1287 return NULL;
1288
1289 const std::map<TransportDIB::Id, TransportDIB*>::iterator
1290 i = cached_dibs_.find(dib_id);
1291 if (i != cached_dibs_.end()) {
1292 cached_dibs_cleaner_.Reset();
1293 return i->second;
1294 }
1295
1296 TransportDIB* dib = MapTransportDIB(dib_id);
1297 if (!dib)
1298 return NULL;
1299
1300 if (cached_dibs_.size() >= MAX_MAPPED_TRANSPORT_DIBS) {
1301 // Clean a single entry from the cache
1302 std::map<TransportDIB::Id, TransportDIB*>::iterator smallest_iterator;
1303 size_t smallest_size = std::numeric_limits<size_t>::max();
1304
1305 for (std::map<TransportDIB::Id, TransportDIB*>::iterator
1306 i = cached_dibs_.begin(); i != cached_dibs_.end(); ++i) {
1307 if (i->second->size() <= smallest_size) {
1308 smallest_iterator = i;
1309 smallest_size = i->second->size();
1310 }
1311 }
1312
1313 delete smallest_iterator->second;
1314 cached_dibs_.erase(smallest_iterator);
1315 }
1316
1317 cached_dibs_[dib_id] = dib;
1318 cached_dibs_cleaner_.Reset();
1319 return dib;
1320 }
1321
1322 void RenderProcessHostImpl::ClearTransportDIBCache() {
1323 STLDeleteContainerPairSecondPointers(
1324 cached_dibs_.begin(), cached_dibs_.end());
1325 cached_dibs_.clear();
1326 }
1327
1328 bool RenderProcessHostImpl::Send(IPC::Message* msg) { 1260 bool RenderProcessHostImpl::Send(IPC::Message* msg) {
1329 TRACE_EVENT0("renderer_host", "RenderProcessHostImpl::Send"); 1261 TRACE_EVENT0("renderer_host", "RenderProcessHostImpl::Send");
1330 if (!channel_) { 1262 if (!channel_) {
1331 if (!is_initialized_) { 1263 if (!is_initialized_) {
1332 queued_messages_.push(msg); 1264 queued_messages_.push(msg);
1333 return true; 1265 return true;
1334 } else { 1266 } else {
1335 delete msg; 1267 delete msg;
1336 return false; 1268 return false;
1337 } 1269 }
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 1820
1889 IDMap<IPC::Listener>::iterator iter(&listeners_); 1821 IDMap<IPC::Listener>::iterator iter(&listeners_);
1890 while (!iter.IsAtEnd()) { 1822 while (!iter.IsAtEnd()) {
1891 iter.GetCurrentValue()->OnMessageReceived( 1823 iter.GetCurrentValue()->OnMessageReceived(
1892 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), 1824 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(),
1893 static_cast<int>(status), 1825 static_cast<int>(status),
1894 exit_code)); 1826 exit_code));
1895 iter.Advance(); 1827 iter.Advance();
1896 } 1828 }
1897 1829
1898 ClearTransportDIBCache();
1899
1900 render_process_host_mojo_.reset(); 1830 render_process_host_mojo_.reset();
1901 1831
1902 // It's possible that one of the calls out to the observers might have caused 1832 // It's possible that one of the calls out to the observers might have caused
1903 // this object to be no longer needed. 1833 // this object to be no longer needed.
1904 if (delayed_cleanup_needed_) 1834 if (delayed_cleanup_needed_)
1905 Cleanup(); 1835 Cleanup();
1906 1836
1907 // This object is not deleted at this point and might be reused later. 1837 // This object is not deleted at this point and might be reused later.
1908 // TODO(darin): clean this up 1838 // TODO(darin): clean this up
1909 } 1839 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 2049
2120 void RenderProcessHostImpl::SetWebUIHandle( 2050 void RenderProcessHostImpl::SetWebUIHandle(
2121 int32 view_routing_id, 2051 int32 view_routing_id,
2122 mojo::ScopedMessagePipeHandle handle) { 2052 mojo::ScopedMessagePipeHandle handle) {
2123 if (!render_process_host_mojo_) 2053 if (!render_process_host_mojo_)
2124 render_process_host_mojo_.reset(new RenderProcessHostMojoImpl(this)); 2054 render_process_host_mojo_.reset(new RenderProcessHostMojoImpl(this));
2125 render_process_host_mojo_->SetWebUIHandle(view_routing_id, handle.Pass()); 2055 render_process_host_mojo_->SetWebUIHandle(view_routing_id, handle.Pass());
2126 } 2056 }
2127 2057
2128 } // namespace content 2058 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/browser/renderer_host/render_widget_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698