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

Side by Side Diff: third_party/mojo/src/mojo/edk/system/slave_connection_manager.h

Issue 1311043003: Update mojo sdk to rev c02a28868825edfa57ab77947b8cb15e741c5598 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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_SLAVE_CONNECTION_MANAGER_H_ 5 #ifndef MOJO_EDK_SYSTEM_SLAVE_CONNECTION_MANAGER_H_
6 #define MOJO_EDK_SYSTEM_SLAVE_CONNECTION_MANAGER_H_ 6 #define MOJO_EDK_SYSTEM_SLAVE_CONNECTION_MANAGER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/synchronization/lock.h"
11 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
12 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
13 #include "mojo/edk/embedder/scoped_platform_handle.h" 12 #include "mojo/edk/embedder/scoped_platform_handle.h"
14 #include "mojo/edk/embedder/slave_process_delegate.h" 13 #include "mojo/edk/embedder/slave_process_delegate.h"
15 #include "mojo/edk/system/connection_manager.h" 14 #include "mojo/edk/system/connection_manager.h"
15 #include "mojo/edk/system/mutex.h"
16 #include "mojo/edk/system/raw_channel.h" 16 #include "mojo/edk/system/raw_channel.h"
17 #include "mojo/edk/system/system_impl_export.h" 17 #include "mojo/edk/system/system_impl_export.h"
18 #include "mojo/public/cpp/system/macros.h" 18 #include "mojo/public/cpp/system/macros.h"
19 19
20 namespace base { 20 namespace base {
21 class TaskRunner; 21 class TaskRunner;
22 } 22 }
23 23
24 namespace mojo { 24 namespace mojo {
25 25
(...skipping 25 matching lines...) Expand all
51 // thread", on which |slave_process_delegate|'s methods will be called. Both 51 // thread", on which |slave_process_delegate|'s methods will be called. Both
52 // must stay alive at least until after |Shutdown()| has been called. 52 // must stay alive at least until after |Shutdown()| has been called.
53 void Init(scoped_refptr<base::TaskRunner> delegate_thread_task_runner, 53 void Init(scoped_refptr<base::TaskRunner> delegate_thread_task_runner,
54 embedder::SlaveProcessDelegate* slave_process_delegate, 54 embedder::SlaveProcessDelegate* slave_process_delegate,
55 embedder::ScopedPlatformHandle platform_handle); 55 embedder::ScopedPlatformHandle platform_handle);
56 56
57 // |ConnectionManager| methods: 57 // |ConnectionManager| methods:
58 void Shutdown() override; 58 void Shutdown() override;
59 bool AllowConnect(const ConnectionIdentifier& connection_id) override; 59 bool AllowConnect(const ConnectionIdentifier& connection_id) override;
60 bool CancelConnect(const ConnectionIdentifier& connection_id) override; 60 bool CancelConnect(const ConnectionIdentifier& connection_id) override;
61 bool Connect(const ConnectionIdentifier& connection_id, 61 Result Connect(const ConnectionIdentifier& connection_id,
62 ProcessIdentifier* peer_process_identifier, 62 ProcessIdentifier* peer_process_identifier,
63 embedder::ScopedPlatformHandle* platform_handle) override; 63 embedder::ScopedPlatformHandle* platform_handle) override;
64 64
65 private: 65 private:
66 // These should only be called on |private_thread_|: 66 // These should only be called on |private_thread_|:
67 void InitOnPrivateThread(embedder::ScopedPlatformHandle platform_handle); 67 void InitOnPrivateThread(embedder::ScopedPlatformHandle platform_handle);
68 void ShutdownOnPrivateThread(); 68 void ShutdownOnPrivateThread();
69 void AllowConnectOnPrivateThread(const ConnectionIdentifier& connection_id, 69 void AllowConnectOnPrivateThread(const ConnectionIdentifier& connection_id,
70 bool* result); 70 Result* result);
71 void CancelConnectOnPrivateThread(const ConnectionIdentifier& connection_id, 71 void CancelConnectOnPrivateThread(const ConnectionIdentifier& connection_id,
72 bool* result); 72 Result* result);
73 void ConnectOnPrivateThread(const ConnectionIdentifier& connection_id, 73 void ConnectOnPrivateThread(const ConnectionIdentifier& connection_id,
74 bool* result, 74 Result* result,
75 ProcessIdentifier* peer_process_identifier, 75 ProcessIdentifier* peer_process_identifier,
76 embedder::ScopedPlatformHandle* platform_handle); 76 embedder::ScopedPlatformHandle* platform_handle);
77 77
78 // |RawChannel::Delegate| methods (only called on |private_thread_|): 78 // |RawChannel::Delegate| methods (only called on |private_thread_|):
79 void OnReadMessage( 79 void OnReadMessage(
80 const MessageInTransit::View& message_view, 80 const MessageInTransit::View& message_view,
81 embedder::ScopedPlatformHandleVectorPtr platform_handles) override; 81 embedder::ScopedPlatformHandleVectorPtr platform_handles) override;
82 void OnError(Error error) override; 82 void OnError(Error error) override;
83 83
84 // Asserts that the current thread is *not* |private_thread_| (no-op if 84 // Asserts that the current thread is *not* |private_thread_| (no-op if
(...skipping 20 matching lines...) Expand all
105 105
106 // Only accessed on |private_thread_|: 106 // Only accessed on |private_thread_|:
107 scoped_ptr<RawChannel> raw_channel_; 107 scoped_ptr<RawChannel> raw_channel_;
108 enum AwaitingAckType { 108 enum AwaitingAckType {
109 NOT_AWAITING_ACK, 109 NOT_AWAITING_ACK,
110 AWAITING_ACCEPT_CONNECT_ACK, 110 AWAITING_ACCEPT_CONNECT_ACK,
111 AWAITING_CANCEL_CONNECT_ACK, 111 AWAITING_CANCEL_CONNECT_ACK,
112 AWAITING_CONNECT_ACK 112 AWAITING_CONNECT_ACK
113 }; 113 };
114 AwaitingAckType awaiting_ack_type_; 114 AwaitingAckType awaiting_ack_type_;
115 bool* ack_result_; 115 Result* ack_result_;
116 // Used only when waiting for the ack to "connect": 116 // Used only when waiting for the ack to "connect":
117 ProcessIdentifier* ack_peer_process_identifier_; 117 ProcessIdentifier* ack_peer_process_identifier_;
118 embedder::ScopedPlatformHandle* ack_platform_handle_; 118 embedder::ScopedPlatformHandle* ack_platform_handle_;
119 119
120 // The (synchronous) |ConnectionManager| methods are implemented in the 120 // The (synchronous) |ConnectionManager| methods are implemented in the
121 // following way (T is any thread other than |private_thread_|): 121 // following way (T is any thread other than |private_thread_|):
122 // 122 //
123 // On thread T: 123 // On thread T:
124 // 1. |F()| is called, where F is one of the |ConnectionManager| methods. 124 // 1. |F()| is called, where F is one of the |ConnectionManager| methods.
125 // 2. |lock_| is acquired. 125 // 2. |lock_| is acquired.
(...skipping 10 matching lines...) Expand all
136 // 4.4. |*ack_result_| and possibly |*ack_platform_handle_| are written to. 136 // 4.4. |*ack_result_| and possibly |*ack_platform_handle_| are written to.
137 // |awaiting_ack_type_| is "unset". 137 // |awaiting_ack_type_| is "unset".
138 // 4.5. |event_| is triggered. 138 // 4.5. |event_| is triggered.
139 // 139 //
140 // Back on thread T: 140 // Back on thread T:
141 // 6. |lock_| is released. 141 // 6. |lock_| is released.
142 // 7. [Return from |F()|.] 142 // 7. [Return from |F()|.]
143 // 143 //
144 // TODO(vtl): This is all a hack. It'd really suffice to have a version of 144 // TODO(vtl): This is all a hack. It'd really suffice to have a version of
145 // |RawChannel| with fully synchronous reading and writing. 145 // |RawChannel| with fully synchronous reading and writing.
146 base::Lock lock_; 146 Mutex mutex_;
147 base::WaitableEvent event_; 147 base::WaitableEvent event_;
148 148
149 MOJO_DISALLOW_COPY_AND_ASSIGN(SlaveConnectionManager); 149 MOJO_DISALLOW_COPY_AND_ASSIGN(SlaveConnectionManager);
150 }; 150 };
151 151
152 } // namespace system 152 } // namespace system
153 } // namespace mojo 153 } // namespace mojo
154 154
155 #endif // MOJO_EDK_SYSTEM_SLAVE_CONNECTION_MANAGER_H_ 155 #endif // MOJO_EDK_SYSTEM_SLAVE_CONNECTION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698