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

Side by Side Diff: mojo/embedder/embedder.cc

Issue 231353002: Make mojo_system static and mojo_system_impl a component, never use both (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the mac loader path dependencies Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/content_tests.gypi ('k') | mojo/embedder/test_embedder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/embedder/embedder.h" 5 #include "mojo/embedder/embedder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "mojo/system/channel.h" 11 #include "mojo/system/channel.h"
12 #include "mojo/system/core_impl.h" 12 #include "mojo/system/core.h"
13 #include "mojo/system/entrypoints.h"
13 #include "mojo/system/message_pipe.h" 14 #include "mojo/system/message_pipe.h"
14 #include "mojo/system/message_pipe_dispatcher.h" 15 #include "mojo/system/message_pipe_dispatcher.h"
15 #include "mojo/system/raw_channel.h" 16 #include "mojo/system/raw_channel.h"
16 17
17 namespace mojo { 18 namespace mojo {
18 namespace embedder { 19 namespace embedder {
19 20
21 void Init() {
22 system::entrypoints::SetCore(new system::Core());
23 }
24
20 struct ChannelInfo { 25 struct ChannelInfo {
21 scoped_refptr<system::Channel> channel; 26 scoped_refptr<system::Channel> channel;
22 }; 27 };
23 28
24 static void CreateChannelOnIOThread( 29 static void CreateChannelOnIOThread(
25 ScopedPlatformHandle platform_handle, 30 ScopedPlatformHandle platform_handle,
26 scoped_refptr<system::MessagePipe> message_pipe, 31 scoped_refptr<system::MessagePipe> message_pipe,
27 DidCreateChannelCallback callback, 32 DidCreateChannelCallback callback,
28 scoped_refptr<base::TaskRunner> callback_thread_task_runner) { 33 scoped_refptr<base::TaskRunner> callback_thread_task_runner) {
29 CHECK(platform_handle.is_valid()); 34 CHECK(platform_handle.is_valid());
(...skipping 18 matching lines...) Expand all
48 // Hand the channel back to the embedder. 53 // Hand the channel back to the embedder.
49 if (callback_thread_task_runner) { 54 if (callback_thread_task_runner) {
50 callback_thread_task_runner->PostTask(FROM_HERE, 55 callback_thread_task_runner->PostTask(FROM_HERE,
51 base::Bind(callback, 56 base::Bind(callback,
52 channel_info.release())); 57 channel_info.release()));
53 } else { 58 } else {
54 callback.Run(channel_info.release()); 59 callback.Run(channel_info.release());
55 } 60 }
56 } 61 }
57 62
58 void Init() {
59 Core::Init(new system::CoreImpl());
60 }
61
62 ScopedMessagePipeHandle CreateChannel( 63 ScopedMessagePipeHandle CreateChannel(
63 ScopedPlatformHandle platform_handle, 64 ScopedPlatformHandle platform_handle,
64 scoped_refptr<base::TaskRunner> io_thread_task_runner, 65 scoped_refptr<base::TaskRunner> io_thread_task_runner,
65 DidCreateChannelCallback callback, 66 DidCreateChannelCallback callback,
66 scoped_refptr<base::TaskRunner> callback_thread_task_runner) { 67 scoped_refptr<base::TaskRunner> callback_thread_task_runner) {
67 DCHECK(platform_handle.is_valid()); 68 DCHECK(platform_handle.is_valid());
68 69
69 std::pair<scoped_refptr<system::MessagePipeDispatcher>, 70 std::pair<scoped_refptr<system::MessagePipeDispatcher>,
70 scoped_refptr<system::MessagePipe> > remote_message_pipe = 71 scoped_refptr<system::MessagePipe> > remote_message_pipe =
71 system::MessagePipeDispatcher::CreateRemoteMessagePipe(); 72 system::MessagePipeDispatcher::CreateRemoteMessagePipe();
72 73
73 system::CoreImpl* core_impl = static_cast<system::CoreImpl*>(Core::Get()); 74 system::Core* core = system::entrypoints::GetCore();
74 DCHECK(core_impl); 75 DCHECK(core);
75 ScopedMessagePipeHandle rv( 76 ScopedMessagePipeHandle rv(
76 MessagePipeHandle(core_impl->AddDispatcher(remote_message_pipe.first))); 77 MessagePipeHandle(core->AddDispatcher(remote_message_pipe.first)));
77 // TODO(vtl): Do we properly handle the failure case here? 78 // TODO(vtl): Do we properly handle the failure case here?
78 if (rv.is_valid()) { 79 if (rv.is_valid()) {
79 io_thread_task_runner->PostTask(FROM_HERE, 80 io_thread_task_runner->PostTask(FROM_HERE,
80 base::Bind(&CreateChannelOnIOThread, 81 base::Bind(&CreateChannelOnIOThread,
81 base::Passed(&platform_handle), 82 base::Passed(&platform_handle),
82 remote_message_pipe.second, 83 remote_message_pipe.second,
83 callback, 84 callback,
84 callback_thread_task_runner)); 85 callback_thread_task_runner));
85 } 86 }
86 return rv.Pass(); 87 return rv.Pass();
87 } 88 }
88 89
89 void DestroyChannelOnIOThread(ChannelInfo* channel_info) { 90 void DestroyChannelOnIOThread(ChannelInfo* channel_info) {
90 DCHECK(channel_info); 91 DCHECK(channel_info);
91 DCHECK(channel_info->channel.get()); 92 DCHECK(channel_info->channel.get());
92 channel_info->channel->Shutdown(); 93 channel_info->channel->Shutdown();
93 delete channel_info; 94 delete channel_info;
94 } 95 }
95 96
96 } // namespace embedder 97 } // namespace embedder
97 } // namespace mojo 98 } // namespace mojo
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | mojo/embedder/test_embedder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698