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

Unified Diff: content/shell/shell_main.cc

Issue 9190018: Support sharing of ContentMain and BrowserMain code with embedded use cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
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)

Powered by Google App Engine
This is Rietveld 408576698