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

Side by Side Diff: content/common/mojo/channel_init.h

Issue 1350023003: Add a Mojo EDK for Chrome that uses one OS pipe per message pipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move to mojo::edk namespace in preparation for runtim flag Created 5 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef CONTENT_COMMON_MOJO_CHANNEL_INIT_H_ 5 #ifndef CONTENT_COMMON_MOJO_CHANNEL_INIT_H_
6 #define CONTENT_COMMON_MOJO_CHANNEL_INIT_H_ 6 #define CONTENT_COMMON_MOJO_CHANNEL_INIT_H_
7 7
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "ipc/mojo/scoped_ipc_support.h" 12 #include "ipc/mojo/scoped_ipc_support.h"
13 #include "third_party/mojo/src/mojo/public/cpp/system/message_pipe.h"
14
15 #if !defined(USE_CHROME_EDK)
13 #include "third_party/mojo/src/mojo/edk/embedder/channel_info_forward.h" 16 #include "third_party/mojo/src/mojo/edk/embedder/channel_info_forward.h"
14 #include "third_party/mojo/src/mojo/public/cpp/system/message_pipe.h" 17 #endif
15 18
16 namespace base { 19 namespace base {
17 class TaskRunner; 20 class TaskRunner;
18 } 21 }
19 22
20 namespace content { 23 namespace content {
21 24
22 // ChannelInit handles creation and destruction of the Mojo channel. It is not 25 // ChannelInit handles creation and destruction of the Mojo channel. It is not
23 // thread-safe, but may be used on any single thread with a MessageLoop. 26 // thread-safe, but may be used on any single thread with a MessageLoop.
24 class CONTENT_EXPORT ChannelInit { 27 class CONTENT_EXPORT ChannelInit {
25 public: 28 public:
26 ChannelInit(); 29 ChannelInit();
27 ~ChannelInit(); 30 ~ChannelInit();
28 31
29 // Initializes the channel. This takes ownership of |file|. Returns the 32 // Initializes the channel. This takes ownership of |file|. Returns the
30 // primordial MessagePipe for the channel. 33 // primordial MessagePipe for the channel.
31 mojo::ScopedMessagePipeHandle Init( 34 mojo::ScopedMessagePipeHandle Init(
32 base::PlatformFile file, 35 base::PlatformFile file,
33 scoped_refptr<base::TaskRunner> io_thread_task_runner); 36 scoped_refptr<base::TaskRunner> io_thread_task_runner);
34 37
35 // Notifies the channel that we (hence it) will soon be destroyed. 38 // Notifies the channel that we (hence it) will soon be destroyed.
36 void WillDestroySoon(); 39 void WillDestroySoon();
37 40
38 // Shuts down the channel. Must be called from the IO thread. 41 // Shuts down the channel. Must be called from the IO thread.
39 void ShutdownOnIOThread(); 42 void ShutdownOnIOThread();
40 43
41 private: 44 private:
45 #if !defined(USE_CHROME_EDK)
42 // Invoked on the thread on which this object lives once the channel has been 46 // Invoked on the thread on which this object lives once the channel has been
43 // established. This is a static method that takes a weak pointer to self, 47 // established. This is a static method that takes a weak pointer to self,
44 // since we want to destroy the channel if we were destroyed first. 48 // since we want to destroy the channel if we were destroyed first.
45 static void OnCreatedChannel( 49 static void OnCreatedChannel(
46 base::WeakPtr<ChannelInit> self, 50 base::WeakPtr<ChannelInit> self,
47 scoped_ptr<IPC::ScopedIPCSupport> ipc_support, 51 scoped_ptr<IPC::ScopedIPCSupport> ipc_support,
48 mojo::embedder::ChannelInfo* channel); 52 mojo::embedder::ChannelInfo* channel);
49 53
50 // If non-null the channel has been established. 54 // If non-null the channel has been established.
51 mojo::embedder::ChannelInfo* channel_info_; 55 mojo::embedder::ChannelInfo* channel_info_;
56 #endif
52 57
53 scoped_ptr<IPC::ScopedIPCSupport> ipc_support_; 58 scoped_ptr<IPC::ScopedIPCSupport> ipc_support_;
54 base::WeakPtrFactory<ChannelInit> weak_factory_; 59 base::WeakPtrFactory<ChannelInit> weak_factory_;
55 60
56 DISALLOW_COPY_AND_ASSIGN(ChannelInit); 61 DISALLOW_COPY_AND_ASSIGN(ChannelInit);
57 }; 62 };
58 63
59 } // namespace content 64 } // namespace content
60 65
61 #endif // CONTENT_COMMON_MOJO_CHANNEL_INIT_H_ 66 #endif // CONTENT_COMMON_MOJO_CHANNEL_INIT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698