| OLD | NEW |
| 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 #include "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
| 6 #include "app/resource_bundle.h" | 6 #include "app/resource_bundle.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/field_trial.h" | 8 #include "base/field_trial.h" |
| 9 #include "base/histogram.h" | 9 #include "base/histogram.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/platform_thread.h" | 12 #include "base/platform_thread.h" |
| 13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
| 14 #include "base/scoped_nsautorelease_pool.h" | 14 #include "base/scoped_nsautorelease_pool.h" |
| 15 #include "base/stats_counters.h" | 15 #include "base/stats_counters.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/system_monitor.h" | 17 #include "base/system_monitor.h" |
| 18 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
| 19 #include "chrome/common/chrome_counters.h" | 19 #include "chrome/common/chrome_counters.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/logging_chrome.h" | 21 #include "chrome/common/logging_chrome.h" |
| 22 #include "chrome/common/main_function_params.h" | 22 #include "chrome/common/main_function_params.h" |
| 23 #include "chrome/common/net/net_resource_provider.h" | 23 #include "chrome/common/net/net_resource_provider.h" |
| 24 #include "chrome/renderer/renderer_main_platform_delegate.h" | 24 #include "chrome/renderer/renderer_main_platform_delegate.h" |
| 25 #include "chrome/renderer/render_process.h" | 25 #include "chrome/renderer/render_process.h" |
| 26 #include "chrome/renderer/render_thread.h" | 26 #include "chrome/renderer/render_thread.h" |
| 27 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 28 #include "net/base/net_module.h" | 28 #include "net/base/net_module.h" |
| 29 | 29 |
| 30 |
| 31 #include "chrome/common/mach_ipc_mac.h" |
| 32 |
| 30 #if defined(USE_LINUX_BREAKPAD) | 33 #if defined(USE_LINUX_BREAKPAD) |
| 31 #include "chrome/app/breakpad_linux.h" | 34 #include "chrome/app/breakpad_linux.h" |
| 32 #endif | 35 #endif |
| 33 | 36 |
| 34 // This function provides some ways to test crash and assertion handling | 37 // This function provides some ways to test crash and assertion handling |
| 35 // behavior of the renderer. | 38 // behavior of the renderer. |
| 36 static void HandleRendererErrorTestParameters(const CommandLine& command_line) { | 39 static void HandleRendererErrorTestParameters(const CommandLine& command_line) { |
| 37 // This parameter causes an assertion. | 40 // This parameter causes an assertion. |
| 38 if (command_line.HasSwitch(switches::kRendererAssertTest)) { | 41 if (command_line.HasSwitch(switches::kRendererAssertTest)) { |
| 39 DCHECK(false); | 42 DCHECK(false); |
| 40 } | 43 } |
| 41 | 44 |
| 42 // This parameter causes a null pointer crash (crash reporter trigger). | 45 // This parameter causes a null pointer crash (crash reporter trigger). |
| 43 if (command_line.HasSwitch(switches::kRendererCrashTest)) { | 46 if (command_line.HasSwitch(switches::kRendererCrashTest)) { |
| 44 int* bad_pointer = NULL; | 47 int* bad_pointer = NULL; |
| 45 *bad_pointer = 0; | 48 *bad_pointer = 0; |
| 46 } | 49 } |
| 47 | 50 |
| 48 if (command_line.HasSwitch(switches::kRendererStartupDialog)) { | 51 if (command_line.HasSwitch(switches::kRendererStartupDialog)) { |
| 49 ChildProcess::WaitForDebugger(L"Renderer"); | 52 ChildProcess::WaitForDebugger(L"Renderer"); |
| 50 } | 53 } |
| 51 } | 54 } |
| 52 | 55 |
| 53 // mainline routine for running as the Renderer process | 56 // mainline routine for running as the Renderer process |
| 54 int RendererMain(const MainFunctionParams& parameters) { | 57 int RendererMain(const MainFunctionParams& parameters) { |
| 55 const CommandLine& parsed_command_line = parameters.command_line_; | 58 const CommandLine& parsed_command_line = parameters.command_line_; |
| 56 base::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool_; | 59 base::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool_; |
| 57 | 60 |
| 61 mach_port_t host_port = mach_host_self(); |
| 62 fprintf(stderr, "host port: %lu\n", (unsigned long)host_port); |
| 63 |
| 64 // send to already named port |
| 65 MachPortSender sender("com.Google.MyService"); |
| 66 MachSendMessage message(57); // our message ID is 57 |
| 67 |
| 68 // add some ports to be translated for us |
| 69 message.AddDescriptor(mach_task_self()); // our task |
| 70 message.AddDescriptor(mach_thread_self()); // this thread |
| 71 message.AddDescriptor(host_port); // uhh...not sure. but certainly important
. |
| 72 |
| 73 char messageString[] = "Hello server!\n"; |
| 74 message.SetData(messageString, strlen(messageString)+1); |
| 75 // timeout 1000ms |
| 76 kern_return_t result = sender.SendMessage(message, 1000); |
| 77 fprintf(stderr, "send result: %lu\n", (unsigned long)result); |
| 78 if (result != KERN_SUCCESS) |
| 79 fprintf(stderr, "(Failed :-( )\n"); |
| 80 |
| 81 |
| 58 #if defined(USE_LINUX_BREAKPAD) | 82 #if defined(USE_LINUX_BREAKPAD) |
| 59 // Needs to be called after we have chrome::DIR_USER_DATA. | 83 // Needs to be called after we have chrome::DIR_USER_DATA. |
| 60 InitCrashReporter(); | 84 InitCrashReporter(); |
| 61 #endif | 85 #endif |
| 62 | 86 |
| 63 // Configure the network module so it has access to resources. | 87 // Configure the network module so it has access to resources. |
| 64 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); | 88 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); |
| 65 | 89 |
| 66 // This function allows pausing execution using the --renderer-startup-dialog | 90 // This function allows pausing execution using the --renderer-startup-dialog |
| 67 // flag allowing us to attach a debugger. | 91 // flag allowing us to attach a debugger. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 159 |
| 136 if (run_loop) { | 160 if (run_loop) { |
| 137 if (pool) | 161 if (pool) |
| 138 pool->Recycle(); | 162 pool->Recycle(); |
| 139 MessageLoop::current()->Run(); | 163 MessageLoop::current()->Run(); |
| 140 } | 164 } |
| 141 } | 165 } |
| 142 platform.PlatformUninitialize(); | 166 platform.PlatformUninitialize(); |
| 143 return 0; | 167 return 0; |
| 144 } | 168 } |
| OLD | NEW |