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

Side by Side Diff: mojo/system/raw_channel.h

Issue 137063010: Mojo: Move platform handle/channel stuff in system to embedder namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | « mojo/system/platform_handle.cc ('k') | mojo/system/raw_channel_posix.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 MOJO_SYSTEM_RAW_CHANNEL_H_ 5 #ifndef MOJO_SYSTEM_RAW_CHANNEL_H_
6 #define MOJO_SYSTEM_RAW_CHANNEL_H_ 6 #define MOJO_SYSTEM_RAW_CHANNEL_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "mojo/system/constants.h" 11 #include "mojo/system/constants.h"
12 #include "mojo/system/scoped_platform_handle.h" 12 #include "mojo/system/scoped_platform_handle.h"
13 #include "mojo/system/system_impl_export.h" 13 #include "mojo/system/system_impl_export.h"
14 14
15 namespace base { 15 namespace base {
16 class MessageLoop; 16 class MessageLoop;
17 } 17 }
18 18
19 namespace mojo { 19 namespace mojo {
20 namespace system { 20 namespace system {
21 21
22 class MessageInTransit; 22 class MessageInTransit;
23 23
24 // This simply wraps an |int| file descriptor on POSIX and a |HANDLE| on
25 // Windows, but we don't want to impose, e.g., the inclusion of windows.h on
26 // everyone.
27 struct PlatformHandle;
28
29 // |RawChannel| is an interface to objects that wrap an OS "pipe". It presents 24 // |RawChannel| is an interface to objects that wrap an OS "pipe". It presents
30 // the following interface to users: 25 // the following interface to users:
31 // - Receives and dispatches messages on a thread (running a |MessageLoop|; it 26 // - Receives and dispatches messages on a thread (running a |MessageLoop|; it
32 // must be a |MessageLoopForIO| in the case of the POSIX libevent 27 // must be a |MessageLoopForIO| in the case of the POSIX libevent
33 // implementation). 28 // implementation).
34 // - Provides a thread-safe way of writing messages (|WriteMessage()|); 29 // - Provides a thread-safe way of writing messages (|WriteMessage()|);
35 // writing/queueing messages will not block and is atomic from the point of 30 // writing/queueing messages will not block and is atomic from the point of
36 // view of the caller. If necessary, messages are queued (to be written on 31 // view of the caller. If necessary, messages are queued (to be written on
37 // the aforementioned thread). 32 // the aforementioned thread).
38 // 33 //
(...skipping 25 matching lines...) Expand all
64 virtual void OnFatalError(FatalError fatal_error) = 0; 59 virtual void OnFatalError(FatalError fatal_error) = 0;
65 60
66 protected: 61 protected:
67 virtual ~Delegate() {} 62 virtual ~Delegate() {}
68 }; 63 };
69 64
70 // Static factory method. |handle| should be a handle to a 65 // Static factory method. |handle| should be a handle to a
71 // (platform-appropriate) bidirectional communication channel (e.g., a socket 66 // (platform-appropriate) bidirectional communication channel (e.g., a socket
72 // on POSIX, a named pipe on Windows). Does *not* take ownership of |delegate| 67 // on POSIX, a named pipe on Windows). Does *not* take ownership of |delegate|
73 // and |message_loop|, which must remain alive while this object does. 68 // and |message_loop|, which must remain alive while this object does.
74 static RawChannel* Create(ScopedPlatformHandle handle, 69 static RawChannel* Create(embedder::ScopedPlatformHandle handle,
75 Delegate* delegate, 70 Delegate* delegate,
76 base::MessageLoop* message_loop); 71 base::MessageLoop* message_loop);
77 72
78 // This must be called (on the I/O thread) before this object is used. Returns 73 // This must be called (on the I/O thread) before this object is used. Returns
79 // true on success. On failure, |Shutdown()| should *not* be called. 74 // true on success. On failure, |Shutdown()| should *not* be called.
80 virtual bool Init() = 0; 75 virtual bool Init() = 0;
81 76
82 // This must be called (on the I/O thread) before this object is destroyed. 77 // This must be called (on the I/O thread) before this object is destroyed.
83 virtual void Shutdown() = 0; 78 virtual void Shutdown() = 0;
84 79
(...skipping 12 matching lines...) Expand all
97 Delegate* const delegate_; 92 Delegate* const delegate_;
98 base::MessageLoop* const message_loop_; 93 base::MessageLoop* const message_loop_;
99 94
100 DISALLOW_COPY_AND_ASSIGN(RawChannel); 95 DISALLOW_COPY_AND_ASSIGN(RawChannel);
101 }; 96 };
102 97
103 } // namespace system 98 } // namespace system
104 } // namespace mojo 99 } // namespace mojo
105 100
106 #endif // MOJO_SYSTEM_RAW_CHANNEL_H_ 101 #endif // MOJO_SYSTEM_RAW_CHANNEL_H_
OLDNEW
« no previous file with comments | « mojo/system/platform_handle.cc ('k') | mojo/system/raw_channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698