Index: content/shell/shell_main.cc |
=================================================================== |
--- content/shell/shell_main.cc (revision 117304) |
+++ content/shell/shell_main.cc (working copy) |
@@ -4,6 +4,7 @@ |
#include "content/app/content_main.h" |
+#include "content/shell/shell.h" |
#include "content/shell/shell_main_delegate.h" |
#include "sandbox/src/sandbox_types.h" |
@@ -11,14 +12,64 @@ |
#include "content/public/app/startup_helper_win.h" |
#endif |
+#if defined(TEST_EMBEDDED_MESSAGE_LOOP) |
+#include "content/app/content_main_runner.h" |
+#endif |
+ |
#if defined(OS_WIN) |
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { |
sandbox::SandboxInterfaceInfo sandbox_info = {0}; |
content::InitializeSandboxInfo(&sandbox_info); |
+ |
+ // The main delegate object that will outlive the content runner. |
ShellMainDelegate delegate; |
+ |
+#if defined(TEST_EMBEDDED_MESSAGE_LOOP) |
+ // Retrieve the requested process type. |
+ std::string process_type = content::GetProcessType(0, NULL); |
+ if (!process_type.empty()) { |
+ // For non-browser processes use the default implementation. |
+ return content::ContentMain(instance, &sandbox_info, &delegate); |
+ } |
+ |
+ // Use our own content runner for the browser process. |
+ scoped_ptr<content::ContentMainRunner> content_runner( |
+ content::ContentMainRunner::CreateMainRunner()); |
+ |
+ // Initialize the content runner. |
+ int exit_code = content_runner->Initialize(instance, &sandbox_info, |
+ &delegate); |
+ if (exit_code >= 0) |
+ return exit_code; |
+ |
+ // Run the process. Results in a call to ShellMainDelegate::RunKnownProcess() |
+ // which will create the browser runner and message loop without blocking. |
+ exit_code = content_runner->Run(); |
+ |
+ MSG msg; |
+ |
+ // Run the application message loop. |
+ while (GetMessage(&msg, NULL, 0, 0)) { |
+ TranslateMessage(&msg); |
+ DispatchMessage(&msg); |
+ |
+ // Perform a single iteration of browser message loop work. |
+ delegate.DoBrowserMessageLoopWork(); |
+ } |
+ |
+ // Shut down the browser runner. |
+ delegate.ShutdownBrowser(); |
+ |
+ // Shut down the content runner. |
+ content_runner->Shutdown(); |
+ |
+ return exit_code; |
+#else // !TEST_EMBEDDED_MESSAGE_LOOP |
return content::ContentMain(instance, &sandbox_info, &delegate); |
+#endif // !TEST_EMBEDDED_MESSAGE_LOOP |
} |
+ |
#endif |
#if defined(OS_POSIX) |