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

Unified Diff: mojo/edk/embedder/embedder.cc

Issue 728553002: Update mojo sdk to rev afb4440fd5a10cba980878c326180b7ad7960480 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « mojo/edk/embedder/embedder.h ('k') | mojo/edk/embedder/embedder_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/embedder/embedder.cc
diff --git a/mojo/edk/embedder/embedder.cc b/mojo/edk/embedder/embedder.cc
index ca2169ab29809d768d4cf741d2ef66950ee24809..7b0dd3997cc824546b90ff4f01b5445b0dd42abe 100644
--- a/mojo/edk/embedder/embedder.cc
+++ b/mojo/edk/embedder/embedder.cc
@@ -9,12 +9,13 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop_proxy.h"
+#include "mojo/edk/embedder/embedder_internal.h"
#include "mojo/edk/embedder/platform_support.h"
#include "mojo/edk/system/channel.h"
#include "mojo/edk/system/channel_endpoint.h"
#include "mojo/edk/system/channel_info.h"
+#include "mojo/edk/system/configuration.h"
#include "mojo/edk/system/core.h"
-#include "mojo/edk/system/entrypoints.h"
#include "mojo/edk/system/message_pipe_dispatcher.h"
#include "mojo/edk/system/platform_handle_dispatcher.h"
#include "mojo/edk/system/raw_channel.h"
@@ -26,14 +27,13 @@ namespace {
// Helper for |CreateChannel...()|. (Note: May return null for some failures.)
scoped_refptr<system::Channel> MakeChannel(
- system::Core* core,
ScopedPlatformHandle platform_handle,
scoped_refptr<system::ChannelEndpoint> channel_endpoint) {
DCHECK(platform_handle.is_valid());
// Create and initialize a |system::Channel|.
scoped_refptr<system::Channel> channel =
- new system::Channel(core->platform_support());
+ new system::Channel(internal::g_core->platform_support());
if (!channel->Init(system::RawChannel::Create(platform_handle.Pass()))) {
// This is very unusual (e.g., maybe |platform_handle| was invalid or we
// reached some system resource limit).
@@ -49,14 +49,12 @@ scoped_refptr<system::Channel> MakeChannel(
}
void CreateChannelHelper(
- system::Core* core,
ScopedPlatformHandle platform_handle,
scoped_ptr<ChannelInfo> channel_info,
scoped_refptr<system::ChannelEndpoint> channel_endpoint,
DidCreateChannelCallback callback,
scoped_refptr<base::TaskRunner> callback_thread_task_runner) {
- channel_info->channel =
- MakeChannel(core, platform_handle.Pass(), channel_endpoint);
+ channel_info->channel = MakeChannel(platform_handle.Pass(), channel_endpoint);
// Hand the channel back to the embedder.
if (callback_thread_task_runner.get()) {
@@ -69,8 +67,21 @@ void CreateChannelHelper(
} // namespace
+namespace internal {
+
+// Declared in embedder_internal.h.
+system::Core* g_core = nullptr;
+
+} // namespace internal
+
void Init(scoped_ptr<PlatformSupport> platform_support) {
- system::entrypoints::SetCore(new system::Core(platform_support.Pass()));
+ // TODO(vtl): Uncomment after fixing Python bindings tests. crbug.com/432670
+ // DCHECK(!internal::g_core);
+ internal::g_core = new system::Core(platform_support.Pass());
+}
+
+Configuration* GetConfiguration() {
+ return system::GetMutableConfiguration();
}
// TODO(vtl): Write tests for this.
@@ -84,14 +95,13 @@ ScopedMessagePipeHandle CreateChannelOnIOThread(
scoped_refptr<system::MessagePipeDispatcher> dispatcher =
system::MessagePipeDispatcher::CreateRemoteMessagePipe(&channel_endpoint);
- system::Core* core = system::entrypoints::GetCore();
- DCHECK(core);
+ DCHECK(internal::g_core);
ScopedMessagePipeHandle rv(
- MessagePipeHandle(core->AddDispatcher(dispatcher)));
+ MessagePipeHandle(internal::g_core->AddDispatcher(dispatcher)));
- *channel_info = new ChannelInfo(
- MakeChannel(core, platform_handle.Pass(), channel_endpoint),
- base::MessageLoopProxy::current());
+ *channel_info =
+ new ChannelInfo(MakeChannel(platform_handle.Pass(), channel_endpoint),
+ base::MessageLoopProxy::current());
return rv.Pass();
}
@@ -109,24 +119,20 @@ ScopedMessagePipeHandle CreateChannel(
scoped_refptr<system::MessagePipeDispatcher> dispatcher =
system::MessagePipeDispatcher::CreateRemoteMessagePipe(&channel_endpoint);
- system::Core* core = system::entrypoints::GetCore();
- DCHECK(core);
+ DCHECK(internal::g_core);
ScopedMessagePipeHandle rv(
- MessagePipeHandle(core->AddDispatcher(dispatcher)));
+ MessagePipeHandle(internal::g_core->AddDispatcher(dispatcher)));
scoped_ptr<ChannelInfo> channel_info(new ChannelInfo());
// We'll have to set |channel_info->channel| on the I/O thread.
channel_info->channel_thread_task_runner = io_thread_task_runner;
if (rv.is_valid()) {
- io_thread_task_runner->PostTask(FROM_HERE,
- base::Bind(&CreateChannelHelper,
- base::Unretained(core),
- base::Passed(&platform_handle),
- base::Passed(&channel_info),
- channel_endpoint,
- callback,
- callback_thread_task_runner));
+ io_thread_task_runner->PostTask(
+ FROM_HERE,
+ base::Bind(&CreateChannelHelper, base::Passed(&platform_handle),
+ base::Passed(&channel_info), channel_endpoint, callback,
+ callback_thread_task_runner));
} else {
(callback_thread_task_runner.get() ? callback_thread_task_runner
: io_thread_task_runner)
@@ -175,9 +181,8 @@ MojoResult CreatePlatformHandleWrapper(
scoped_refptr<system::Dispatcher> dispatcher(
new system::PlatformHandleDispatcher(platform_handle.Pass()));
- system::Core* core = system::entrypoints::GetCore();
- DCHECK(core);
- MojoHandle h = core->AddDispatcher(dispatcher);
+ DCHECK(internal::g_core);
+ MojoHandle h = internal::g_core->AddDispatcher(dispatcher);
if (h == MOJO_HANDLE_INVALID) {
LOG(ERROR) << "Handle table full";
dispatcher->Close();
@@ -192,10 +197,9 @@ MojoResult PassWrappedPlatformHandle(MojoHandle platform_handle_wrapper_handle,
ScopedPlatformHandle* platform_handle) {
DCHECK(platform_handle);
- system::Core* core = system::entrypoints::GetCore();
- DCHECK(core);
+ DCHECK(internal::g_core);
scoped_refptr<system::Dispatcher> dispatcher(
- core->GetDispatcher(platform_handle_wrapper_handle));
+ internal::g_core->GetDispatcher(platform_handle_wrapper_handle));
if (!dispatcher.get())
return MOJO_RESULT_INVALID_ARGUMENT;
« no previous file with comments | « mojo/edk/embedder/embedder.h ('k') | mojo/edk/embedder/embedder_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698