Chromium Code Reviews| 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 #if !defined(TOOLKIT_GTK) && !defined(OS_ANDROID) | 488 #if !defined(TOOLKIT_GTK) && !defined(OS_ANDROID) |
| 489 // In-process plugins require this to be a UI message loop. | 489 // In-process plugins require this to be a UI message loop. |
| 490 options.message_loop_type = MessageLoop::TYPE_UI; | 490 options.message_loop_type = MessageLoop::TYPE_UI; |
| 491 #else | 491 #else |
| 492 // We can't have multiple UI loops on GTK and Android, so we don't support | 492 // We can't have multiple UI loops on GTK and Android, so we don't support |
| 493 // in-process plugins. | 493 // in-process plugins. |
| 494 options.message_loop_type = MessageLoop::TYPE_DEFAULT; | 494 options.message_loop_type = MessageLoop::TYPE_DEFAULT; |
| 495 #endif | 495 #endif |
| 496 in_process_renderer_->StartWithOptions(options); | 496 in_process_renderer_->StartWithOptions(options); |
| 497 | 497 |
| 498 OnProcessLaunched(); // Fake a callback that the process is ready. | 498 // Fake a callback that the process is ready. |
| 499 OnProcessLaunched(content::FDInfoList()); | |
| 499 } else { | 500 } else { |
| 500 // Build command line for renderer. We call AppendRendererCommandLine() | 501 // Build command line for renderer. We call AppendRendererCommandLine() |
| 501 // first so the process type argument will appear first. | 502 // first so the process type argument will appear first. |
| 502 CommandLine* cmd_line = new CommandLine(renderer_path); | 503 CommandLine* cmd_line = new CommandLine(renderer_path); |
| 503 if (!renderer_prefix.empty()) | 504 if (!renderer_prefix.empty()) |
| 504 cmd_line->PrependWrapper(renderer_prefix); | 505 cmd_line->PrependWrapper(renderer_prefix); |
| 505 AppendRendererCommandLine(cmd_line); | 506 AppendRendererCommandLine(cmd_line); |
| 506 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 507 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
| 507 | 508 |
| 508 // Spawn the child process asynchronously to avoid blocking the UI thread. | 509 // Spawn the child process asynchronously to avoid blocking the UI thread. |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1528 // intercepted the stack is messed up on return from the interceptor | 1529 // intercepted the stack is messed up on return from the interceptor |
| 1529 // which causes random crashes in the browser process. Our hack for now | 1530 // which causes random crashes in the browser process. Our hack for now |
| 1530 // is to not invoke the SetPriorityClass API if the dll is loaded. | 1531 // is to not invoke the SetPriorityClass API if the dll is loaded. |
| 1531 if (GetModuleHandle(L"cbstext.dll")) | 1532 if (GetModuleHandle(L"cbstext.dll")) |
| 1532 return; | 1533 return; |
| 1533 #endif // OS_WIN | 1534 #endif // OS_WIN |
| 1534 | 1535 |
| 1535 child_process_launcher_->SetProcessBackgrounded(backgrounded); | 1536 child_process_launcher_->SetProcessBackgrounded(backgrounded); |
| 1536 } | 1537 } |
| 1537 | 1538 |
| 1538 void RenderProcessHostImpl::OnProcessLaunched() { | 1539 void RenderProcessHostImpl::OnProcessLaunched( |
| 1540 const content::FDInfoList& mapped_files) { | |
| 1539 // No point doing anything, since this object will be destructed soon. We | 1541 // No point doing anything, since this object will be destructed soon. We |
| 1540 // especially don't want to send the RENDERER_PROCESS_CREATED notification, | 1542 // especially don't want to send the RENDERER_PROCESS_CREATED notification, |
| 1541 // since some clients might expect a RENDERER_PROCESS_TERMINATED afterwards to | 1543 // since some clients might expect a RENDERER_PROCESS_TERMINATED afterwards to |
| 1542 // properly cleanup. | 1544 // properly cleanup. |
| 1543 if (deleting_soon_) | 1545 if (deleting_soon_) |
| 1544 return; | 1546 return; |
| 1545 | 1547 |
| 1546 if (child_process_launcher_.get()) { | 1548 if (child_process_launcher_.get()) { |
| 1547 if (!child_process_launcher_->GetHandle()) { | 1549 if (!child_process_launcher_->GetHandle()) { |
| 1548 OnChannelError(); | 1550 OnChannelError(); |
| 1549 return; | 1551 return; |
| 1550 } | 1552 } |
| 1551 | 1553 |
| 1552 child_process_launcher_->SetProcessBackgrounded(backgrounded_); | 1554 child_process_launcher_->SetProcessBackgrounded(backgrounded_); |
| 1553 } | 1555 } |
| 1554 | 1556 |
| 1555 // NOTE: This needs to be before sending queued messages because | 1557 // NOTE: This needs to be before sending queued messages because |
| 1556 // ExtensionService uses this notification to initialize the renderer process | 1558 // ExtensionService uses this notification to initialize the renderer process |
| 1557 // with state that must be there before any JavaScript executes. | 1559 // with state that must be there before any JavaScript executes. |
| 1558 // | 1560 // |
| 1559 // The queued messages contain such things as "navigate". If this notification | 1561 // The queued messages contain such things as "navigate". If this notification |
| 1560 // was after, we can end up executing JavaScript before the initialization | 1562 // was after, we can end up executing JavaScript before the initialization |
| 1561 // happens. | 1563 // happens. |
| 1562 NotificationService::current()->Notify( | 1564 NotificationService::current()->Notify( |
| 1563 NOTIFICATION_RENDERER_PROCESS_CREATED, | 1565 NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 1564 Source<RenderProcessHost>(this), | 1566 Source<RenderProcessHost>(this), |
| 1565 NotificationService::NoDetails()); | 1567 Details<const content::FDInfoList>(&mapped_files)); |
|
jam
2012/10/19 16:39:17
this seems awkward for two reasons:
-it adds seemi
Jay Civelli
2012/10/22 22:09:48
Changed per our discussion. Now using the process
| |
| 1566 | 1568 |
| 1567 while (!queued_messages_.empty()) { | 1569 while (!queued_messages_.empty()) { |
| 1568 Send(queued_messages_.front()); | 1570 Send(queued_messages_.front()); |
| 1569 queued_messages_.pop(); | 1571 queued_messages_.pop(); |
| 1570 } | 1572 } |
| 1571 } | 1573 } |
| 1572 | 1574 |
| 1573 void RenderProcessHostImpl::OnUserMetricsRecordAction( | 1575 void RenderProcessHostImpl::OnUserMetricsRecordAction( |
| 1574 const std::string& action) { | 1576 const std::string& action) { |
| 1575 RecordComputedAction(action); | 1577 RecordComputedAction(action); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1586 const gfx::Size& size, | 1588 const gfx::Size& size, |
| 1587 int32 gpu_process_host_id) { | 1589 int32 gpu_process_host_id) { |
| 1588 TRACE_EVENT0("renderer_host", | 1590 TRACE_EVENT0("renderer_host", |
| 1589 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); | 1591 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); |
| 1590 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, | 1592 RenderWidgetHostImpl::AcknowledgeBufferPresent(route_id, |
| 1591 gpu_process_host_id, | 1593 gpu_process_host_id, |
| 1592 0); | 1594 0); |
| 1593 } | 1595 } |
| 1594 | 1596 |
| 1595 } // namespace content | 1597 } // namespace content |
| OLD | NEW |