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

Side by Side Diff: chrome/browser/renderer_host/browser_render_process_host.cc

Issue 21208: POSIX: Transfer network data using shared memory (Closed)
Patch Set: ... Created 11 years, 10 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
« no previous file with comments | « base/shared_memory_win.cc ('k') | chrome/chrome.xcodeproj/project.pbxproj » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/browser_render_process_host.h" 8 #include "chrome/browser/renderer_host/browser_render_process_host.h"
9 9
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 return base::Process::Current().handle(); 517 return base::Process::Current().handle();
518 return process_.handle(); 518 return process_.handle();
519 } 519 }
520 520
521 void BrowserRenderProcessHost::InitVisitedLinks() { 521 void BrowserRenderProcessHost::InitVisitedLinks() {
522 VisitedLinkMaster* visitedlink_master = profile()->GetVisitedLinkMaster(); 522 VisitedLinkMaster* visitedlink_master = profile()->GetVisitedLinkMaster();
523 if (!visitedlink_master) { 523 if (!visitedlink_master) {
524 return; 524 return;
525 } 525 }
526 526
527 #if defined(OS_WIN) 527 base::SharedMemoryHandle handle_for_process;
528 base::SharedMemoryHandle handle_for_process = NULL; 528 bool r = visitedlink_master->ShareToProcess(GetRendererProcessHandle(),
529 visitedlink_master->ShareToProcess(GetRendererProcessHandle(), 529 &handle_for_process);
530 &handle_for_process); 530 DCHECK(r);
531 DCHECK(handle_for_process); 531
532 if (handle_for_process) { 532 if (base::SharedMemory::IsHandleValid(handle_for_process)) {
533 channel_->Send(new ViewMsg_VisitedLink_NewTable(handle_for_process)); 533 channel_->Send(new ViewMsg_VisitedLink_NewTable(handle_for_process));
534 } 534 }
535 #else
536 // TODO(port): ShareToProcess is Windows-specific.
537 NOTIMPLEMENTED();
538 #endif
539 } 535 }
540 536
541 void BrowserRenderProcessHost::InitUserScripts() { 537 void BrowserRenderProcessHost::InitUserScripts() {
542 UserScriptMaster* user_script_master = profile()->GetUserScriptMaster(); 538 UserScriptMaster* user_script_master = profile()->GetUserScriptMaster();
543 DCHECK(user_script_master); 539 DCHECK(user_script_master);
544 540
545 if (!user_script_master->ScriptsReady()) { 541 if (!user_script_master->ScriptsReady()) {
546 // No scripts ready. :( 542 // No scripts ready. :(
547 return; 543 return;
548 } 544 }
549 545
550 // Update the renderer process with the current scripts. 546 // Update the renderer process with the current scripts.
551 SendUserScriptsUpdate(user_script_master->GetSharedMemory()); 547 SendUserScriptsUpdate(user_script_master->GetSharedMemory());
552 } 548 }
553 549
554 void BrowserRenderProcessHost::SendUserScriptsUpdate( 550 void BrowserRenderProcessHost::SendUserScriptsUpdate(
555 base::SharedMemory *shared_memory) { 551 base::SharedMemory *shared_memory) {
556 base::SharedMemoryHandle handle_for_process = NULL; 552 base::SharedMemoryHandle handle_for_process;
557 shared_memory->ShareToProcess(GetRendererProcessHandle(), 553 bool r = shared_memory->ShareToProcess(GetRendererProcessHandle(),
558 &handle_for_process); 554 &handle_for_process);
559 DCHECK(handle_for_process); 555 DCHECK(r);
560 if (handle_for_process) { 556 if (base::SharedMemory::IsHandleValid(handle_for_process)) {
561 channel_->Send(new ViewMsg_UserScripts_NewScripts(handle_for_process)); 557 channel_->Send(new ViewMsg_UserScripts_NewScripts(handle_for_process));
562 } 558 }
563 } 559 }
564 560
565 bool BrowserRenderProcessHost::FastShutdownIfPossible() { 561 bool BrowserRenderProcessHost::FastShutdownIfPossible() {
566 if (!process_.handle()) 562 if (!process_.handle())
567 return false; // Render process is probably crashed. 563 return false; // Render process is probably crashed.
568 if (BrowserRenderProcessHost::run_renderer_in_process()) 564 if (BrowserRenderProcessHost::run_renderer_in_process())
569 return false; // Since process mode can't do fast shutdown. 565 return false; // Since process mode can't do fast shutdown.
570 566
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 // child processes determine the pid of the parent. 814 // child processes determine the pid of the parent.
819 // Build the channel ID. This is composed of a unique identifier for the 815 // Build the channel ID. This is composed of a unique identifier for the
820 // parent browser process, an identifier for the renderer/plugin instance, 816 // parent browser process, an identifier for the renderer/plugin instance,
821 // and a random component. We use a random component so that a hacked child 817 // and a random component. We use a random component so that a hacked child
822 // process can't cause denial of service by causing future named pipe creation 818 // process can't cause denial of service by causing future named pipe creation
823 // to fail. 819 // to fail.
824 return StringPrintf(L"%d.%x.%d", 820 return StringPrintf(L"%d.%x.%d",
825 base::GetCurrentProcId(), instance, 821 base::GetCurrentProcId(), instance,
826 base::RandInt(0, std::numeric_limits<int>::max())); 822 base::RandInt(0, std::numeric_limits<int>::max()));
827 } 823 }
OLDNEW
« no previous file with comments | « base/shared_memory_win.cc ('k') | chrome/chrome.xcodeproj/project.pbxproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698