diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-20 17:09:37 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-20 17:10:44 +0000 |
commit | cf74402db8af5735815caefe721276c5f9dda7aa (patch) | |
tree | 02d0a093b75d99d7d2c8a359041648f1167cfc47 /mojo | |
parent | 8271001b6f844eee8b8a3fadf0dce9d3f2b4478e (diff) | |
download | chromium_src-cf74402db8af5735815caefe721276c5f9dda7aa.zip chromium_src-cf74402db8af5735815caefe721276c5f9dda7aa.tar.gz chromium_src-cf74402db8af5735815caefe721276c5f9dda7aa.tar.bz2 |
Mojo: Add PlatformSupport argument to mojo::embedder::Init().
Also add InitWithSimplePlatformSupport() to test_embedder.h. Use that
for all tests, for now (this won't be right in the long run).
R=darin@chromium.org
Review URL: https://codereview.chromium.org/489593004
Cr-Commit-Position: refs/heads/master@{#290856}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290856 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo')
-rw-r--r-- | mojo/android/system/core_impl.cc | 9 | ||||
-rw-r--r-- | mojo/common/test/run_all_perftests.cc | 4 | ||||
-rw-r--r-- | mojo/common/test/run_all_unittests.cc | 4 | ||||
-rw-r--r-- | mojo/embedder/embedder.cc | 5 | ||||
-rw-r--r-- | mojo/embedder/embedder.h | 5 | ||||
-rw-r--r-- | mojo/embedder/embedder_unittest.cc | 8 | ||||
-rw-r--r-- | mojo/embedder/test_embedder.cc | 7 | ||||
-rw-r--r-- | mojo/embedder/test_embedder.h | 4 | ||||
-rw-r--r-- | mojo/services/dbus_echo/dbus_echo_service.cc | 4 | ||||
-rw-r--r-- | mojo/shell/app_child_process.cc | 5 | ||||
-rw-r--r-- | mojo/shell/context.cc | 5 | ||||
-rw-r--r-- | mojo/system/core.cc | 4 | ||||
-rw-r--r-- | mojo/system/core.h | 2 | ||||
-rw-r--r-- | mojo/system/core_test_base.cc | 4 |
14 files changed, 49 insertions, 21 deletions
diff --git a/mojo/android/system/core_impl.cc b/mojo/android/system/core_impl.cc index 704e8c7..62822fd 100644 --- a/mojo/android/system/core_impl.cc +++ b/mojo/android/system/core_impl.cc @@ -10,9 +10,11 @@ #include "base/android/library_loader/library_loader_hooks.h" #include "base/android/scoped_java_ref.h" #include "base/bind.h" +#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "jni/CoreImpl_jni.h" #include "mojo/embedder/embedder.h" +#include "mojo/embedder/simple_platform_support.h" #include "mojo/public/c/environment/async_waiter.h" #include "mojo/public/c/system/core.h" #include "mojo/public/cpp/environment/environment.h" @@ -50,7 +52,8 @@ namespace mojo { namespace android { static void Constructor(JNIEnv* env, jobject jcaller) { - mojo::embedder::Init(); + embedder::Init(scoped_ptr<embedder::PlatformSupport>( + new embedder::SimplePlatformSupport())); } static jlong GetTimeTicksNow(JNIEnv* env, jobject jcaller) { @@ -343,7 +346,7 @@ static jobject AsyncWait(JNIEnv* env, new AsyncWaitCallbackData(env, jcaller, callback); MojoAsyncWaitID cancel_id; if (static_cast<MojoHandle>(mojo_handle) != MOJO_HANDLE_INVALID) { - cancel_id = mojo::Environment::GetDefaultAsyncWaiter()->AsyncWait( + cancel_id = Environment::GetDefaultAsyncWaiter()->AsyncWait( mojo_handle, signals, deadline, AsyncWaitCallback, callback_data); } else { cancel_id = kInvalidHandleCancelID; @@ -371,7 +374,7 @@ static void CancelAsyncWait(JNIEnv* env, } scoped_ptr<AsyncWaitCallbackData> deleter( reinterpret_cast<AsyncWaitCallbackData*>(data_ptr)); - mojo::Environment::GetDefaultAsyncWaiter()->CancelWait(id); + Environment::GetDefaultAsyncWaiter()->CancelWait(id); } bool RegisterCoreImpl(JNIEnv* env) { diff --git a/mojo/common/test/run_all_perftests.cc b/mojo/common/test/run_all_perftests.cc index b5032a6..87e39ce 100644 --- a/mojo/common/test/run_all_perftests.cc +++ b/mojo/common/test/run_all_perftests.cc @@ -4,11 +4,11 @@ #include "base/test/perf_test_suite.h" #include "mojo/common/test/test_support_impl.h" -#include "mojo/embedder/embedder.h" +#include "mojo/embedder/test_embedder.h" #include "mojo/public/tests/test_support_private.h" int main(int argc, char** argv) { - mojo::embedder::Init(); + mojo::embedder::test::InitWithSimplePlatformSupport(); mojo::test::TestSupport::Init(new mojo::test::TestSupportImpl()); return base::PerfTestSuite(argc, argv).Run(); } diff --git a/mojo/common/test/run_all_unittests.cc b/mojo/common/test/run_all_unittests.cc index 6bf61c0..814a259 100644 --- a/mojo/common/test/run_all_unittests.cc +++ b/mojo/common/test/run_all_unittests.cc @@ -6,7 +6,7 @@ #include "base/test/launcher/unit_test_launcher.h" #include "base/test/test_suite.h" #include "mojo/common/test/test_support_impl.h" -#include "mojo/embedder/embedder.h" +#include "mojo/embedder/test_embedder.h" #include "mojo/public/tests/test_support_private.h" #include "testing/gtest/include/gtest/gtest.h" @@ -17,7 +17,7 @@ int main(int argc, char** argv) { base::TestSuite test_suite(argc, argv); - mojo::embedder::Init(); + mojo::embedder::test::InitWithSimplePlatformSupport(); mojo::test::TestSupport::Init(new mojo::test::TestSupportImpl()); return base::LaunchUnitTests( diff --git a/mojo/embedder/embedder.cc b/mojo/embedder/embedder.cc index cfeddba..f51987cc 100644 --- a/mojo/embedder/embedder.cc +++ b/mojo/embedder/embedder.cc @@ -8,6 +8,7 @@ #include "base/location.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" +#include "mojo/embedder/platform_support.h" #include "mojo/system/channel.h" #include "mojo/system/core.h" #include "mojo/system/entrypoints.h" @@ -98,8 +99,8 @@ void CreateChannelHelper( } // namespace -void Init() { - system::entrypoints::SetCore(new system::Core()); +void Init(scoped_ptr<PlatformSupport> platform_support) { + system::entrypoints::SetCore(new system::Core(platform_support.Pass())); } // TODO(vtl): Write tests for this. diff --git a/mojo/embedder/embedder.h b/mojo/embedder/embedder.h index c6638e5..e1d9c60 100644 --- a/mojo/embedder/embedder.h +++ b/mojo/embedder/embedder.h @@ -7,6 +7,7 @@ #include "base/callback.h" #include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" #include "base/task_runner.h" #include "mojo/embedder/scoped_platform_handle.h" #include "mojo/public/cpp/system/core.h" @@ -15,8 +16,10 @@ namespace mojo { namespace embedder { +class PlatformSupport; + // Must be called first to initialize the (global, singleton) system. -MOJO_SYSTEM_IMPL_EXPORT void Init(); +MOJO_SYSTEM_IMPL_EXPORT void Init(scoped_ptr<PlatformSupport> platform_support); // A "channel" is a connection on top of an OS "pipe", on top of which Mojo // message pipes (etc.) can be multiplexed. It must "live" on some I/O thread. diff --git a/mojo/embedder/embedder_unittest.cc b/mojo/embedder/embedder_unittest.cc index afe608e..5b74f44 100644 --- a/mojo/embedder/embedder_unittest.cc +++ b/mojo/embedder/embedder_unittest.cc @@ -113,7 +113,7 @@ class EmbedderTest : public testing::Test { }; TEST_F(EmbedderTest, ChannelsBasic) { - Init(); + mojo::embedder::test::InitWithSimplePlatformSupport(); { PlatformChannelPair channel_pair; @@ -170,7 +170,7 @@ TEST_F(EmbedderTest, ChannelsBasic) { } TEST_F(EmbedderTest, ChannelsHandlePassing) { - Init(); + mojo::embedder::test::InitWithSimplePlatformSupport(); { PlatformChannelPair channel_pair; @@ -331,7 +331,7 @@ TEST_F(EmbedderTest, ChannelsHandlePassing) { // 11. (wait/cl.) // 12. (wait/cl.) TEST_F(EmbedderTest, MultiprocessChannels) { - Init(); + mojo::embedder::test::InitWithSimplePlatformSupport(); mojo::test::MultiprocessTestHelper multiprocess_test_helper; multiprocess_test_helper.StartChild("MultiprocessChannelsClient"); @@ -462,7 +462,7 @@ MOJO_MULTIPROCESS_TEST_CHILD_TEST(MultiprocessChannelsClient) { system::test::TestIOThread test_io_thread( system::test::TestIOThread::kAutoStart); - Init(); + mojo::embedder::test::InitWithSimplePlatformSupport(); { ScopedTestChannel client_channel(test_io_thread.task_runner(), diff --git a/mojo/embedder/test_embedder.cc b/mojo/embedder/test_embedder.cc index 049855d..7f50abb 100644 --- a/mojo/embedder/test_embedder.cc +++ b/mojo/embedder/test_embedder.cc @@ -6,6 +6,9 @@ #include "base/logging.h" #include "base/macros.h" +#include "base/memory/scoped_ptr.h" +#include "mojo/embedder/embedder.h" +#include "mojo/embedder/simple_platform_support.h" #include "mojo/system/core.h" #include "mojo/system/entrypoints.h" #include "mojo/system/handle_table.h" @@ -38,6 +41,10 @@ bool ShutdownCheckNoLeaks(Core* core_impl) { namespace embedder { namespace test { +void InitWithSimplePlatformSupport() { + Init(scoped_ptr<PlatformSupport>(new SimplePlatformSupport())); +} + bool Shutdown() { system::Core* core = system::entrypoints::GetCore(); CHECK(core); diff --git a/mojo/embedder/test_embedder.h b/mojo/embedder/test_embedder.h index a29adaf..48f6326 100644 --- a/mojo/embedder/test_embedder.h +++ b/mojo/embedder/test_embedder.h @@ -11,6 +11,10 @@ namespace mojo { namespace embedder { namespace test { +// Calls |Init()| with a |SimplePlatformSupport| (use this in tests if, e.g., +// you don't care about sandboxing, etc.). +MOJO_SYSTEM_IMPL_EXPORT void InitWithSimplePlatformSupport(); + // This shuts down the global, singleton instance. (Note: "Real" embedders are // not expected to ever shut down this instance. This |Shutdown()| function will // do more work to ensure that tests don't leak, etc.) Returns true if there diff --git a/mojo/services/dbus_echo/dbus_echo_service.cc b/mojo/services/dbus_echo/dbus_echo_service.cc index ae8029f..ce79abd 100644 --- a/mojo/services/dbus_echo/dbus_echo_service.cc +++ b/mojo/services/dbus_echo/dbus_echo_service.cc @@ -12,6 +12,7 @@ #include "mojo/dbus/dbus_external_service.h" #include "mojo/embedder/channel_init.h" #include "mojo/embedder/embedder.h" +#include "mojo/embedder/simple_platform_support.h" #include "mojo/public/cpp/environment/environment.h" #include "mojo/services/dbus_echo/echo.mojom.h" @@ -45,7 +46,8 @@ int main(int argc, char** argv) { false, // Timestamp false); // Tick count - mojo::embedder::Init(); + mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( + new mojo::embedder::SimplePlatformSupport())); base::MessageLoopForIO message_loop; base::RunLoop run_loop; diff --git a/mojo/shell/app_child_process.cc b/mojo/shell/app_child_process.cc index 8cc4d81..3b9dcb4 100644 --- a/mojo/shell/app_child_process.cc +++ b/mojo/shell/app_child_process.cc @@ -11,6 +11,7 @@ #include "base/logging.h" #include "base/macros.h" #include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/scoped_native_library.h" #include "base/single_thread_task_runner.h" @@ -19,6 +20,7 @@ #include "base/threading/thread_checker.h" #include "mojo/common/message_pump_mojo.h" #include "mojo/embedder/embedder.h" +#include "mojo/embedder/simple_platform_support.h" #include "mojo/public/cpp/system/core.h" #include "mojo/shell/app_child_process.mojom.h" @@ -93,7 +95,8 @@ class AppContext { void Init() { // Initialize Mojo before starting any threads. - embedder::Init(); + embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( + new mojo::embedder::SimplePlatformSupport())); // Create and start our I/O thread. base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0); diff --git a/mojo/shell/context.cc b/mojo/shell/context.cc index a6585e2..fe4d6f5 100644 --- a/mojo/shell/context.cc +++ b/mojo/shell/context.cc @@ -8,6 +8,7 @@ #include "base/command_line.h" #include "base/lazy_instance.h" +#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/strings/string_split.h" #include "build/build_config.h" @@ -15,6 +16,7 @@ #include "mojo/application_manager/application_manager.h" #include "mojo/application_manager/background_shell_application_loader.h" #include "mojo/embedder/embedder.h" +#include "mojo/embedder/simple_platform_support.h" #include "mojo/public/cpp/application/application_connection.h" #include "mojo/public/cpp/application/application_delegate.h" #include "mojo/public/cpp/application/application_impl.h" @@ -52,7 +54,8 @@ const char* kLocalMojoURLs[] = { class Setup { public: Setup() { - embedder::Init(); + embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( + new mojo::embedder::SimplePlatformSupport())); } ~Setup() { diff --git a/mojo/system/core.cc b/mojo/system/core.cc index 82cb117..62c6c31 100644 --- a/mojo/system/core.cc +++ b/mojo/system/core.cc @@ -10,7 +10,6 @@ #include "base/time/time.h" #include "mojo/embedder/platform_shared_buffer.h" #include "mojo/embedder/platform_support.h" -#include "mojo/embedder/simple_platform_support.h" // TODO(vtl): Remove this. #include "mojo/public/c/system/macros.h" #include "mojo/system/constants.h" #include "mojo/system/data_pipe.h" @@ -77,7 +76,8 @@ namespace system { // held. // TODO(vtl): This should take a |scoped_ptr<PlatformSupport>| as a parameter. -Core::Core() : platform_support_(new embedder::SimplePlatformSupport()) { +Core::Core(scoped_ptr<embedder::PlatformSupport> platform_support) + : platform_support_(platform_support.Pass()) { } Core::~Core() { diff --git a/mojo/system/core.h b/mojo/system/core.h index eb9d0f7..d074da3 100644 --- a/mojo/system/core.h +++ b/mojo/system/core.h @@ -38,7 +38,7 @@ class MOJO_SYSTEM_IMPL_EXPORT Core { // --------------------------------------------------------------------------- // These methods are only to be used by via the embedder API (and internally): - Core(); + explicit Core(scoped_ptr<embedder::PlatformSupport> platform_support); virtual ~Core(); // Adds |dispatcher| to the handle table, returning the handle for it. Returns diff --git a/mojo/system/core_test_base.cc b/mojo/system/core_test_base.cc index d42df536..ad61495 100644 --- a/mojo/system/core_test_base.cc +++ b/mojo/system/core_test_base.cc @@ -9,6 +9,7 @@ #include "base/compiler_specific.h" #include "base/logging.h" #include "base/memory/ref_counted.h" +#include "mojo/embedder/simple_platform_support.h" #include "mojo/system/constants.h" #include "mojo/system/core.h" #include "mojo/system/dispatcher.h" @@ -174,7 +175,8 @@ CoreTestBase::~CoreTestBase() { } void CoreTestBase::SetUp() { - core_ = new Core(); + core_ = new Core(scoped_ptr<embedder::PlatformSupport>( + new embedder::SimplePlatformSupport())); } void CoreTestBase::TearDown() { |