diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-21 16:44:38 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-21 16:44:38 +0000 |
commit | e0bd76c3edce49acc5a015b2dac9c3094a01abf5 (patch) | |
tree | 810766d0d10a499f9e7f8dfdbbcbe35176ed60e9 /content/app | |
parent | 6c090076f885a3d1c92725a79fee856b1aa1c050 (diff) | |
download | chromium_src-e0bd76c3edce49acc5a015b2dac9c3094a01abf5.zip chromium_src-e0bd76c3edce49acc5a015b2dac9c3094a01abf5.tar.gz chromium_src-e0bd76c3edce49acc5a015b2dac9c3094a01abf5.tar.bz2 |
Add creation of ServiceManager to Content
BUG=None
TEST=Mojo.Init
R=jam@chromium.org, sky@chromium.org, jam
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=258438
Review URL: https://codereview.chromium.org/187183002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258607 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/app')
-rw-r--r-- | content/app/content_main_runner.cc | 11 | ||||
-rw-r--r-- | content/app/mojo/mojo_browsertest.cc | 29 | ||||
-rw-r--r-- | content/app/mojo/mojo_init.cc | 34 | ||||
-rw-r--r-- | content/app/mojo/mojo_init.h | 15 |
4 files changed, 88 insertions, 1 deletions
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc index adf27a9..957d604 100644 --- a/content/app/content_main_runner.cc +++ b/content/app/content_main_runner.cc @@ -101,6 +101,10 @@ int tc_set_new_mode(int mode); } #endif +#if defined(USE_MOJO) +#include "content/app/mojo/mojo_init.h" +#endif + namespace content { extern int GpuMain(const content::MainFunctionParams&); #if defined(ENABLE_PLUGINS) @@ -529,7 +533,7 @@ class ContentMainRunnerImpl : public ContentMainRunner { virtual int Initialize(const ContentMainParams& params) OVERRIDE { ui_task_ = params.ui_task; -#if defined(OS_WIN) +#if defined(OS_WIN) RegisterInvalidParamHandler(); _Module.Init(NULL, static_cast<HINSTANCE>(params.instance)); @@ -661,6 +665,11 @@ class ContentMainRunnerImpl : public ContentMainRunner { std::string process_type = command_line.GetSwitchValueASCII(switches::kProcessType); +#if defined(USE_MOJO) + // Initialize mojo here so that services can be registered. + InitializeMojo(); +#endif + if (!GetContentClient()) SetContentClient(&empty_content_client_); ContentClientInitializer::Set(process_type, delegate_); diff --git a/content/app/mojo/mojo_browsertest.cc b/content/app/mojo/mojo_browsertest.cc new file mode 100644 index 0000000..eaada42 --- /dev/null +++ b/content/app/mojo/mojo_browsertest.cc @@ -0,0 +1,29 @@ +// Copyright (c) 2014 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 "content/test/content_browser_test.h" +#include "mojo/service_manager/service_manager.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace content { + +class MojoTest : public ContentBrowserTest { + public: + MojoTest() {} + + protected: + bool HasCreatedInstance() { + return mojo::ServiceManager::TestAPI::HasCreatedInstance(); + } + + private: + DISALLOW_COPY_AND_ASSIGN(MojoTest); +}; + +// Placeholder test to confirm we are initializing Mojo. +IN_PROC_BROWSER_TEST_F(MojoTest, Init) { + EXPECT_TRUE(HasCreatedInstance()); +} + +} // namespace content diff --git a/content/app/mojo/mojo_init.cc b/content/app/mojo/mojo_init.cc new file mode 100644 index 0000000..c34917f --- /dev/null +++ b/content/app/mojo/mojo_init.cc @@ -0,0 +1,34 @@ +// Copyright (c) 2014 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 "content/app/mojo/mojo_init.h" + +#include "base/lazy_instance.h" +#include "mojo/embedder/embedder.h" +#include "mojo/service_manager/service_manager.h" + +namespace content { + +namespace { + +struct Initializer { + Initializer() { + // TODO(davemoore): Configuration goes here. For now just create the shared + // instance of the ServiceManager. + mojo::ServiceManager::GetInstance(); + mojo::embedder::Init(); + } +}; + +static base::LazyInstance<Initializer>::Leaky initializer = + LAZY_INSTANCE_INITIALIZER; + +} // namespace + +// Initializes mojo. Use a lazy instance to ensure we only do this once. +void InitializeMojo() { + initializer.Get(); +} + +} // namespace content diff --git a/content/app/mojo/mojo_init.h b/content/app/mojo/mojo_init.h new file mode 100644 index 0000000..59701ae --- /dev/null +++ b/content/app/mojo/mojo_init.h @@ -0,0 +1,15 @@ +// Copyright (c) 2014 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. + +#ifndef CONTENT_APP_MOJO_MOJO_INIT_H_ +#define CONTENT_APP_MOJO_MOJO_INIT_H_ + +namespace content { + +// Perform any necessary Mojo initialization. +void InitializeMojo(); + +} // namespace content + +#endif // CONTENT_COMMON_MOJO_MOJO_INIT_H_ |