summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-01 15:54:35 +0000
committermaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-01 15:54:35 +0000
commit9c50aa443369f4b33e0d04b5188332cdc138f809 (patch)
treee09ceb8308e5ac8bd7245b3d56889d46ea3af490 /chrome
parent221518780e2702e7cb10c5b73f1d1e06c96c118e (diff)
downloadchromium_src-9c50aa443369f4b33e0d04b5188332cdc138f809.zip
chromium_src-9c50aa443369f4b33e0d04b5188332cdc138f809.tar.gz
chromium_src-9c50aa443369f4b33e0d04b5188332cdc138f809.tar.bz2
Rename the source files containing main function so they can be quickly
identified to their owning project. Add #ifdef to make the ChromeMain function exclude parts depending on the relevancy of the dll generated. BUG=1211534 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/chrome_dll.vcproj26
-rw-r--r--chrome/app/chrome_dll.vsprops10
-rw-r--r--chrome/app/chrome_dll_main.cc (renamed from chrome/app/chrome_main.cc)59
-rw-r--r--chrome/app/chrome_exe.vcproj14
-rw-r--r--chrome/app/chrome_exe_main.cc (renamed from chrome/app/main.cc)17
5 files changed, 78 insertions, 48 deletions
diff --git a/chrome/app/chrome_dll.vcproj b/chrome/app/chrome_dll.vcproj
index eab878e..f525a6e 100644
--- a/chrome/app/chrome_dll.vcproj
+++ b/chrome/app/chrome_dll.vcproj
@@ -21,7 +21,7 @@
<Configuration
Name="Debug|Win32"
ConfigurationType="2"
- InheritedPropertySheets=".\chrome_dll.vsprops;$(SolutionDir)..\build\debug.vsprops;..\installer\util\prebuild\util_prebuild.vsprops"
+ InheritedPropertySheets="$(SolutionDir)..\build\debug.vsprops;.\chrome_dll.vsprops;..\installer\util\prebuild\util_prebuild.vsprops"
>
<Tool
Name="VCPreBuildEventTool"
@@ -87,7 +87,7 @@
<Configuration
Name="Release|Win32"
ConfigurationType="2"
- InheritedPropertySheets=".\chrome_dll.vsprops;$(SolutionDir)..\build\release.vsprops;..\installer\util\prebuild\util_prebuild.vsprops"
+ InheritedPropertySheets="$(SolutionDir)..\build\release.vsprops;.\chrome_dll.vsprops;..\installer\util\prebuild\util_prebuild.vsprops"
>
<Tool
Name="VCPreBuildEventTool"
@@ -202,43 +202,43 @@
>
</File>
<File
- RelativePath="..\..\net\base\net_resources.rc"
+ RelativePath="..\browser\debugger\resources\debugger_resources.rc"
>
</File>
<File
- RelativePath="..\renderer\renderer_resources.rc"
+ RelativePath="..\..\net\base\net_resources.rc"
>
</File>
<File
- RelativePath="..\..\webkit\glue\resources\row_resize.cur"
+ RelativePath="..\renderer\renderer_resources.rc"
>
</File>
<File
- RelativePath="..\..\webkit\glue\resources\vertical_text.cur"
+ RelativePath="..\..\webkit\glue\resources\row_resize.cur"
>
</File>
<File
- RelativePath="..\..\webkit\glue\webkit_resources.rc"
+ RelativePath="$(IntDir)\..\util_prebuild\setup_strings.h"
>
</File>
<File
- RelativePath="..\..\webkit\glue\resources\zoom_in.cur"
+ RelativePath="$(IntDir)\..\util_prebuild\setup_strings.rc"
>
</File>
<File
- RelativePath="..\..\webkit\glue\resources\zoom_out.cur"
+ RelativePath="..\..\webkit\glue\resources\vertical_text.cur"
>
</File>
<File
- RelativePath="$(IntDir)\..\util_prebuild\setup_strings.h"
+ RelativePath="..\..\webkit\glue\webkit_resources.rc"
>
</File>
<File
- RelativePath="$(IntDir)\..\util_prebuild\setup_strings.rc"
+ RelativePath="..\..\webkit\glue\resources\zoom_in.cur"
>
</File>
<File
- RelativePath="..\browser\debugger\resources\debugger_resources.rc"
+ RelativePath="..\..\webkit\glue\resources\zoom_out.cur"
>
</File>
</Filter>
@@ -247,7 +247,7 @@
>
</File>
<File
- RelativePath=".\chrome_main.cc"
+ RelativePath=".\chrome_dll_main.cc"
>
</File>
</Files>
diff --git a/chrome/app/chrome_dll.vsprops b/chrome/app/chrome_dll.vsprops
index 3c6593e..a3668d3 100644
--- a/chrome/app/chrome_dll.vsprops
+++ b/chrome/app/chrome_dll.vsprops
@@ -3,22 +3,16 @@
ProjectType="Visual C++"
Version="8.00"
Name="chrome_dll"
- InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\breakpad\using_breakpad.vsprops;$(SolutionDir)..\third_party\libxml\build\using_libxml.vsprops;$(SolutionDir)..\third_party\libxslt\build\using_libxslt.vsprops;$(SolutionDir)..\skia\using_skia.vsprops;$(SolutionDir)..\third_party\libpng\using_libpng.vsprops;..\tools\build\win\using_generated_strings.vsprops;.\chrome_link.vsprops;$(SolutionDir)third_party\wtl\using_wtl.vsprops"
+ InheritedPropertySheets=".\chrome_binaries.vsprops"
>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="&quot;$(OutDir)\webkit&quot;;..\third_party\webkit\out"
- PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"
+ PreprocessorDefinitions="CHROME_DLL;BROWSER_DLL;RENDERER_DLL;PLUGIN_DLL"
/>
<Tool
Name="VCLinkerTool"
DelayLoadDLLs="crypt32.dll;cryptui.dll;winhttp.dll;wininet.dll;wsock32.dll;winspool.drv;comdlg32.dll;imagehlp.dll;psapi.dll;urlmon.dll;imm32.dll"
ProgramDatabaseFile="$(OutDir)\$(ProjectName).pdb"
- SubSystem="2"
BaseAddress="0x01000000"
/>
- <Tool
- Name="VCResourceCompilerTool"
- AdditionalIncludeDirectories="&quot;$(IntDir)&quot;;&quot;$(SolutionDir)&quot;;&quot;$(IntDir)\..\&quot;"
- />
</VisualStudioPropertySheet>
diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_dll_main.cc
index a6f8091..8461c2c 100644
--- a/chrome/app/chrome_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -40,13 +40,13 @@
#include "base/stats_table.h"
#include "base/string_util.h"
#include "base/win_util.h"
+#ifdef BROWSER_DLL
#include "chrome/browser/render_process_host.h"
+#endif
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_counters.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/env_util.h"
-#include "chrome/common/env_vars.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/resource_bundle.h"
#include "sandbox/src/sandbox.h"
@@ -56,7 +56,19 @@ extern int BrowserMain(CommandLine &, int, sandbox::BrokerServices*);
extern int RendererMain(CommandLine &, int, sandbox::TargetServices*);
extern int PluginMain(CommandLine &, int, sandbox::TargetServices*);
-static const wchar_t kProfilingDll[] = L"memory_watcher.dll";
+// TODO(erikkay): isn't this already defined somewhere?
+#define DLLEXPORT __declspec(dllexport)
+
+// We use extern C for the prototype DLLEXPORT to avoid C++ name mangling.
+extern "C" {
+DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
+ sandbox::SandboxInterfaceInfo* sandbox_info,
+ TCHAR* command_line, int show_command);
+}
+
+namespace {
+
+const wchar_t kProfilingDll[] = L"memory_watcher.dll";
// Load the memory profiling DLL. All it needs to be activated
// is to be loaded. Return true on success, false otherwise.
@@ -67,16 +79,6 @@ bool LoadMemoryProfiler() {
CAppModule _Module;
-// TODO(erikkay): isn't this already defined somewhere?
-#define DLLEXPORT __declspec(dllexport)
-
-// We use extern C for the prototype DLLEXPORT to avoid C++ name mangling.
-extern "C" {
-DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
- sandbox::SandboxInterfaceInfo *sandbox_info,
- TCHAR* command_line, int show_command);
-}
-
#pragma optimize("", off)
// Handlers for invalid parameter and pure call. They generate a breakpoint to
// tell breakpad that it needs to dump the process.
@@ -111,6 +113,8 @@ void ChromeAssert(const std::string& str) {
#pragma optimize("", on)
+
+#if defined(RENDERER_DLL) || defined(PLUGIN_DLL)
// Try to unload DLLs that malfunction with the sandboxed processes.
static void EvictTroublesomeDlls() {
const wchar_t* troublesome_dlls[] = {
@@ -130,9 +134,12 @@ static void EvictTroublesomeDlls() {
}
}
}
+#endif // defined(RENDERER_DLL) || defined(PLUGIN_DLL)
+
+} // namespace
DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
- sandbox::SandboxInterfaceInfo *sandbox_info,
+ sandbox::SandboxInterfaceInfo* sandbox_info,
TCHAR* command_line, int show_command) {
#ifdef _CRTDBG_MAP_ALLOC
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
@@ -212,6 +219,7 @@ DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
std::wstring process_type =
parsed_command_line.GetSwitchValue(switches::kProcessType);
+#if defined(RENDERER_DLL) || defined(PLUGIN_DLL)
bool do_dll_eviction = false;
// Checks if the sandbox is enabled in this process and initializes it if this
@@ -225,6 +233,7 @@ DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
do_dll_eviction = true;
}
}
+#endif // defined(RENDERER_DLL) || defined(PLUGIN_DLL)
_Module.Init(NULL, instance);
@@ -237,10 +246,12 @@ DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
if (!user_data_dir.empty())
PathService::Override(chrome::DIR_USER_DATA, user_data_dir);
+#ifdef BROWSER_DLL
bool single_process =
parsed_command_line.HasSwitch(switches::kSingleProcess);
if (single_process)
RenderProcessHost::set_run_renderer_in_process(true);
+#endif // BROWSER_DLL
bool icu_result = icu_util::Initialize();
CHECK(icu_result);
@@ -257,7 +268,7 @@ DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
parsed_command_line.HasSwitch(switches::kEnableDCHECK)) {
logging::SetLogAssertHandler(ChromeAssert);
}
-#endif
+#endif // NDEBUG
if (!process_type.empty()) {
// Initialize ResourceBundle which handles files loaded from external
@@ -266,23 +277,37 @@ DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
ResourceBundle::InitSharedInstance(std::wstring());
}
+#if defined(RENDERER_DLL) || defined(PLUGIN_DLL)
// Eviction of injected DLLs is done early enough that it is likely
// to only cover DLLs injected by means of appInit_dlls registry key.
if (do_dll_eviction)
EvictTroublesomeDlls();
+#endif // defined(RENDERER_DLL) || defined(PLUGIN_DLL)
startup_timer.Stop(); // End of Startup Time Measurement.
int rv;
- if (process_type == switches::kRendererProcess) {
+ // This condition exist to simplify the #ifdef
+ if (0) {
+
+#ifdef RENDERER_DLL
+ } else if (process_type == switches::kRendererProcess) {
rv = RendererMain(parsed_command_line, show_command, target_services);
+#endif // RENDERER_DLL
+
+#ifdef PLUGIN_DLL
} else if (process_type == switches::kPluginProcess) {
rv = PluginMain(parsed_command_line, show_command, target_services);
+#endif // PLUGIN_DLL
+
+#ifdef BROWSER_DLL
} else if (process_type.empty()) {
int ole_result = OleInitialize(NULL);
DCHECK(ole_result == S_OK);
rv = BrowserMain(parsed_command_line, show_command, broker_services);
OleUninitialize();
+#endif // BROWSER_DLL
+
} else {
NOTREACHED() << "Unknown process type";
rv = -1;
@@ -294,7 +319,7 @@ DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
#ifdef _CRTDBG_MAP_ALLOC
_CrtDumpMemoryLeaks();
-#endif
+#endif // _CRTDBG_MAP_ALLOC
_Module.Term();
diff --git a/chrome/app/chrome_exe.vcproj b/chrome/app/chrome_exe.vcproj
index d0a06f3..61110a0 100644
--- a/chrome/app/chrome_exe.vcproj
+++ b/chrome/app/chrome_exe.vcproj
@@ -149,7 +149,7 @@
<Tool
Name="VCPostBuildEventTool"
Description="Copy first run complete sentinel file"
- CommandLine="copy $(ProjectDir)\FirstRun $(OutDir)\&quot;First Run&quot;&#x0D;&#x0A;check_dependents.bat $(TargetPath) chrome.exe.deps"
+ CommandLine="copy $(ProjectDir)\FirstRun $(OutDir)\&quot;First Run&quot;&#x0D;&#x0A;check_dependents.bat $(TargetPath) chrome.exe.deps&#x0D;&#x0A;"
/>
</Configuration>
</Configurations>
@@ -168,10 +168,6 @@
>
</File>
<File
- RelativePath=".\chrome.ico"
- >
- </File>
- <File
RelativePath=".\chrome_exe.rc"
>
</File>
@@ -193,6 +189,10 @@
>
</File>
<File
+ RelativePath=".\chrome_exe_main.cc"
+ >
+ </File>
+ <File
RelativePath="..\common\chrome_switches.cc"
>
</File>
@@ -213,10 +213,6 @@
>
</File>
<File
- RelativePath=".\main.cc"
- >
- </File>
- <File
RelativePath=".\result_codes.h"
>
</File>
diff --git a/chrome/app/main.cc b/chrome/app/chrome_exe_main.cc
index ab2848b..a28ad16 100644
--- a/chrome/app/main.cc
+++ b/chrome/app/chrome_exe_main.cc
@@ -42,6 +42,10 @@
#include "sandbox/src/sandbox_factory.h"
#include "sandbox/src/dep.h"
+// When defined, a different dll is loaded depending on the process type.
+// Otherwise, the mighty chrome.dll is loaded.
+//#define USE_SEPARATE_DLLS
+
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
wchar_t* command_line, int show_command) {
// The exit manager is in charge of calling the dtors of singletons.
@@ -54,24 +58,35 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
CommandLine parsed_command_line;
std::wstring process_type =
parsed_command_line.GetSwitchValue(switches::kProcessType);
+
+ const wchar_t* dll_name = L"chrome.dll";
if (process_type == switches::kPluginProcess) {
// Plugin process.
// For plugins, we enable ATL7 thunking support because we saw old activex
// built with VC2002 in the wild still being used.
sandbox::SetCurrentProcessDEP(sandbox::DEP_ENABLED_ATL7_COMPAT);
+#ifdef USE_SEPARATE_DLLS
+ dll_name = L"plugin.dll";
+#endif
} else if (process_type == switches::kRendererProcess) {
// Renderer process.
// For the processes we control, we enforce strong DEP support.
sandbox::SetCurrentProcessDEP(sandbox::DEP_ENABLED);
+#ifdef USE_SEPARATE_DLLS
+ dll_name = L"renderer.dll";
+#endif
} else {
// Browser process.
// For the processes we control, we enforce strong DEP support.
sandbox::SetCurrentProcessDEP(sandbox::DEP_ENABLED);
+#ifdef USE_SEPARATE_DLLS
+ dll_name = L"browser.dll";
+#endif
}
// TODO(erikkay): Get guid from build macros rather than hardcoding.
// TODO(erikkay): verify client.Init() return value for official builds
- client.Init(L"{8A69D345-D564-463c-AFF1-A69D9E530F96}", L"chrome.dll");
+ client.Init(L"{8A69D345-D564-463c-AFF1-A69D9E530F96}", dll_name);
// Initialize the crash reporter.
if (GoogleUpdateSettings::GetCollectStatsConsent()) {