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

Side by Side Diff: mojo/embedder/channel_init.h

Issue 621153003: Move mojo edk into mojo/edk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix checkdeps Created 6 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
« no previous file with comments | « mojo/embedder/README.md ('k') | mojo/embedder/channel_init.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_EMBEDDER_CHANNEL_INIT_H_
6 #define MOJO_EMBEDDER_CHANNEL_INIT_H_
7
8 #include "base/files/file.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "mojo/public/cpp/system/core.h"
12 #include "mojo/system/system_impl_export.h"
13
14 namespace base {
15 class MessageLoopProxy;
16 class TaskRunner;
17 }
18
19 namespace mojo {
20 namespace embedder {
21 struct ChannelInfo;
22 }
23
24 namespace embedder {
25
26 // |ChannelInit| handles creation (and destruction) of the Mojo channel. It is
27 // not thread-safe, but may be used on any single thread (with a |MessageLoop|).
28 class MOJO_SYSTEM_IMPL_EXPORT ChannelInit {
29 public:
30 ChannelInit();
31 ~ChannelInit();
32
33 // Initializes the channel. This takes ownership of |file|. Returns the
34 // primordial MessagePipe for the channel.
35 mojo::ScopedMessagePipeHandle Init(
36 base::PlatformFile file,
37 scoped_refptr<base::TaskRunner> io_thread_task_runner);
38
39 // Notifies the channel that we (hence it) will soon be destroyed.
40 void WillDestroySoon();
41
42 private:
43 // Invoked on the thread on which this object lives once the channel has been
44 // established. (This is a static method that takes a weak pointer to self,
45 // since we want to destroy the channel even if we're destroyed.)
46 static void OnCreatedChannel(base::WeakPtr<ChannelInit> self,
47 scoped_refptr<base::TaskRunner> io_thread,
48 ChannelInfo* channel);
49
50 scoped_refptr<base::TaskRunner> io_thread_task_runner_;
51
52 // If non-null the channel has been established.
53 ChannelInfo* channel_info_;
54
55 base::WeakPtrFactory<ChannelInit> weak_factory_;
56
57 DISALLOW_COPY_AND_ASSIGN(ChannelInit);
58 };
59
60 } // namespace embedder
61 } // namespace mojo
62
63 #endif // MOJO_EMBEDDER_CHANNEL_INIT_H_
OLDNEW
« no previous file with comments | « mojo/embedder/README.md ('k') | mojo/embedder/channel_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698