Skip to content

Commit

Permalink
Support sharing of ContentMain and BrowserMain code with embedded use…
Browse files Browse the repository at this point in the history
… cases.

For the browser use case it is convenient to have a single ContentMain entry point function that handles all initialization, run and shutdown. For embedded use cases it is often necessary to integrate with existing application message loops where initialization and shutdown must be handled separately.

To support sharing of this code the following changes were required:

1. Refactor the ContentMain function to create a ContentMainRunner class containing separate initialization, run and shutdown functions.

2. Refactor the BrowserMain function and BrowserMainLoop class to create a BrowserMainRunner class containing separate initialization, run and shutdown functions.

3. Add a new BrowserMainParts::GetMainMessageLoop method. This is necessary to support creation of a custom MessageLoop implementation while sharing BrowserMainRunner initialization and shutdown code.

BUG=112507
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9190018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120574 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
marshall@chromium.org committed Feb 6, 2012
1 parent b3cc0c2 commit 6f2b39b
Show file tree
Hide file tree
Showing 26 changed files with 879 additions and 567 deletions.
4 changes: 2 additions & 2 deletions chrome/app/chrome_main.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/app/chrome_main_delegate.h"

#include "content/app/content_main.h"
#include "content/public/app/content_main.h"

#if defined(OS_WIN)
#define DLLEXPORT __declspec(dllexport)
Expand Down
5 changes: 1 addition & 4 deletions chrome/app/chrome_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
#include "chrome/plugin/chrome_content_plugin_client.h"
#include "chrome/renderer/chrome_content_renderer_client.h"
#include "chrome/utility/chrome_content_utility_client.h"
#include "content/app/content_main.h"
#include "content/common/content_counters.h"
#include "content/public/app/content_main_delegate.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_paths.h"
Expand Down Expand Up @@ -699,8 +697,7 @@ int ChromeMainDelegate::RunProcess(
return kMainFunctions[i].function(main_function_params);
}

NOTREACHED() << "Unknown process type: " << process_type;
return 1;
return -1;
}

void ChromeMainDelegate::ProcessExiting(const std::string& process_type) {
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/chrome_browser_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,10 @@ void ChromeBrowserMainParts::PreMainMessageLoopStart() {
chrome_extra_parts_[i]->PreMainMessageLoopStart();
}

MessageLoop* ChromeBrowserMainParts::GetMainMessageLoop() {
return NULL;
}

void ChromeBrowserMainParts::PostMainMessageLoopStart() {
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PostMainMessageLoopStart();
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/chrome_browser_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class ChromeBrowserMainParts : public content::BrowserMainParts {
virtual void PostEarlyInitialization() OVERRIDE;
virtual void ToolkitInitialized() OVERRIDE;
virtual void PreMainMessageLoopStart() OVERRIDE;
virtual MessageLoop* GetMainMessageLoop() OVERRIDE;
virtual void PostMainMessageLoopStart() OVERRIDE;
virtual int PreCreateThreads() OVERRIDE;
virtual void PreMainMessageLoopRun() OVERRIDE;
Expand Down
4 changes: 2 additions & 2 deletions chrome/test/base/chrome_test_launcher.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand All @@ -11,7 +11,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/test/base/chrome_test_suite.h"
#include "content/app/content_main.h"
#include "content/public/app/content_main.h"

#if defined(OS_MACOSX)
#include "chrome/browser/chrome_browser_application_mac.h"
Expand Down
6 changes: 5 additions & 1 deletion chrome_frame/test/net/fake_external_tab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include "chrome_frame/test/simulate_input.h"
#include "chrome_frame/test/win_event_receiver.h"
#include "chrome_frame/utils.h"
#include "content/app/content_main.h"
#include "content/public/app/content_main.h"
#include "content/public/app/startup_helper_win.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
Expand Down Expand Up @@ -613,6 +613,10 @@ void CFUrlRequestUnittestRunner::PreEarlyInitialization() {
FilterDisabledTests();
}

MessageLoop* CFUrlRequestUnittestRunner::GetMainMessageLoop() {
return NULL;
}

int CFUrlRequestUnittestRunner::PreCreateThreads() {
fake_chrome_.reset(new FakeExternalTab());
fake_chrome_->Initialize();
Expand Down
1 change: 1 addition & 0 deletions chrome_frame/test/net/fake_external_tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class CFUrlRequestUnittestRunner
virtual void PreEarlyInitialization() OVERRIDE;
virtual void PostEarlyInitialization() OVERRIDE {}
virtual void PreMainMessageLoopStart() OVERRIDE {}
virtual MessageLoop* GetMainMessageLoop() OVERRIDE;
virtual void PostMainMessageLoopStart() OVERRIDE {}
virtual void ToolkitInitialized() OVERRIDE {}
virtual int PreCreateThreads() OVERRIDE;
Expand Down
Loading

0 comments on commit 6f2b39b

Please sign in to comment.