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

Side by Side Diff: mojo/edk/system/child_broker_host.h

Issue 1555273002: [mojo] Add CreateSharedBuffer method to Broker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 MOJO_EDK_SYSTEM_CHILD_BROKER_HOST_H_ 5 #ifndef MOJO_EDK_SYSTEM_CHILD_BROKER_HOST_H_
6 #define MOJO_EDK_SYSTEM_CHILD_BROKER_HOST_H_ 6 #define MOJO_EDK_SYSTEM_CHILD_BROKER_HOST_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/process/process.h" 15 #include "base/process/process.h"
16 #include "mojo/edk/embedder/scoped_platform_handle.h" 16 #include "mojo/edk/embedder/scoped_platform_handle.h"
17 #include "mojo/edk/system/routed_raw_channel.h" 17 #include "mojo/edk/system/routed_raw_channel.h"
18 #include "mojo/edk/system/system_impl_export.h" 18 #include "mojo/edk/system/system_impl_export.h"
19 19
20 namespace mojo { 20 namespace mojo {
21 namespace edk { 21 namespace edk {
22 22
23 // Responds to requests from ChildBroker. This is used to handle message pipe 23 // Responds to requests from ChildBroker. This is used to handle message pipe
24 // multiplexing and Windows sandbox messages. There is one object of this class 24 // multiplexing and sandbox messages. There is one object of this class
25 // per child process host object. 25 // per child process host object.
26 // This object will delete itself when it notices that the pipe is broken. 26 // This object will delete itself when it notices that the pipe is broken.
27 class MOJO_SYSTEM_IMPL_EXPORT ChildBrokerHost 27 class MOJO_SYSTEM_IMPL_EXPORT ChildBrokerHost
28 : public RawChannel::Delegate 28 : public RawChannel::Delegate
29 #if defined(OS_WIN) 29 #if defined(OS_WIN)
30 , NON_EXPORTED_BASE(public base::MessageLoopForIO::IOHandler) { 30 , NON_EXPORTED_BASE(public base::MessageLoopForIO::IOHandler) {
31 #else 31 #else
32 { 32 , public base::MessageLoopForIO::Watcher {
jam 2016/01/06 02:58:16 nit: you can now move the comma to line 28
Eliot Courtney 2016/01/07 02:26:09 Done.
33 #endif 33 #endif
34 public: 34 public:
35 // |child_process| is a handle to the child process. It will be duplicated by 35 // |child_process| is a handle to the child process. It will be duplicated by
36 // this object. |pipe| is a handle to the communication pipe to the child 36 // this object. |pipe| is a handle to the communication pipe to the child
37 // process, which is generated inside mojo::edk::ChildProcessLaunched. It is 37 // process, which is generated inside mojo::edk::ChildProcessLaunched. It is
38 // owned by this class. 38 // owned by this class.
39 ChildBrokerHost(base::ProcessHandle child_process, ScopedPlatformHandle pipe); 39 ChildBrokerHost(base::ProcessHandle child_process, ScopedPlatformHandle pipe);
40 40
41 base::ProcessId GetProcessId(); 41 base::ProcessId GetProcessId();
42 42
(...skipping 16 matching lines...) Expand all
59 void OnReadMessage( 59 void OnReadMessage(
60 const MessageInTransit::View& message_view, 60 const MessageInTransit::View& message_view,
61 ScopedPlatformHandleVectorPtr platform_handles) override; 61 ScopedPlatformHandleVectorPtr platform_handles) override;
62 void OnError(Error error) override; 62 void OnError(Error error) override;
63 63
64 // Callback for when child_channel_ is destroyed. 64 // Callback for when child_channel_ is destroyed.
65 void ChannelDestructed(RoutedRawChannel* channel); 65 void ChannelDestructed(RoutedRawChannel* channel);
66 66
67 #if defined(OS_WIN) 67 #if defined(OS_WIN)
68 void BeginRead(); 68 void BeginRead();
69
jam 2016/01/06 02:58:16 nit: undo
Eliot Courtney 2016/01/07 02:26:09 Done.
70 // base::MessageLoopForIO::IOHandler implementation: 69 // base::MessageLoopForIO::IOHandler implementation:
71 void OnIOCompleted(base::MessageLoopForIO::IOContext* context, 70 void OnIOCompleted(base::MessageLoopForIO::IOContext* context,
72 DWORD bytes_transferred, 71 DWORD bytes_transferred,
73 DWORD error) override; 72 DWORD error) override;
74 73
75 // Helper wrappers around DuplicateHandle. 74 // Helper wrappers around DuplicateHandle.
76 HANDLE DuplicateToChild(HANDLE handle); 75 HANDLE DuplicateToChild(HANDLE handle);
77 HANDLE DuplicateFromChild(HANDLE handle); 76 HANDLE DuplicateFromChild(HANDLE handle);
77 #else
78 void DoRead();
79 void DoWrite();
80
81 // base::MessageLoopForIO::Watcher implementation:
82 void OnFileCanReadWithoutBlocking(int fd) override;
83 void OnFileCanWriteWithoutBlocking(int fd) override;
78 #endif 84 #endif
79 85
80 base::ProcessId process_id_; 86 base::ProcessId process_id_;
81 87
82 // Channel used to receive and send multiplexing related messages. 88 // Channel used to receive and send multiplexing related messages.
83 RoutedRawChannel* child_channel_; 89 RoutedRawChannel* child_channel_;
84 90
85 #if defined(OS_WIN)
86 // Handle to the child process, used for duplication of handles.
87 base::Process child_process_;
88
89 // Pipe used for synchronous messages from the child. Responses are written to 91 // Pipe used for synchronous messages from the child. Responses are written to
90 // it as well. 92 // it as well.
91 ScopedPlatformHandle sync_channel_; 93 ScopedPlatformHandle sync_channel_;
92 94
95 #if defined(OS_WIN)
96 // Handle to the child process, used for duplication of handles.
97 base::Process child_process_;
98 std::vector<char> write_data_;
93 base::MessageLoopForIO::IOContext read_context_; 99 base::MessageLoopForIO::IOContext read_context_;
94 base::MessageLoopForIO::IOContext write_context_; 100 base::MessageLoopForIO::IOContext write_context_;
101 #else
102 std::deque<PlatformHandle> write_handles_;
103 base::MessageLoopForIO::FileDescriptorWatcher fd_controller_;
104 #endif
95 105
96 std::vector<char> read_data_; 106 std::vector<char> read_data_;
97 // How many bytes in read_data_ we already read. 107 // How many bytes in read_data_ we already read.
98 uint32_t num_bytes_read_; 108 uint32_t num_bytes_read_;
99 std::vector<char> write_data_;
100 #endif
101 109
102 DISALLOW_COPY_AND_ASSIGN(ChildBrokerHost); 110 DISALLOW_COPY_AND_ASSIGN(ChildBrokerHost);
103 }; 111 };
104 112
105 } // namespace edk 113 } // namespace edk
106 } // namespace mojo 114 } // namespace mojo
107 115
108 #endif // MOJO_EDK_SYSTEM_CHILD_BROKER_HOST_H_ 116 #endif // MOJO_EDK_SYSTEM_CHILD_BROKER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698