OLD | NEW |
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_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "mojo/public/cpp/bindings/lib/sync_handle_watcher.h" | |
16 #include "mojo/public/cpp/bindings/message.h" | 15 #include "mojo/public/cpp/bindings/message.h" |
| 16 #include "mojo/public/cpp/bindings/sync_handle_watcher.h" |
17 #include "mojo/public/cpp/system/core.h" | 17 #include "mojo/public/cpp/system/core.h" |
18 #include "mojo/public/cpp/system/watcher.h" | 18 #include "mojo/public/cpp/system/watcher.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 class Lock; | 21 class Lock; |
22 } | 22 } |
23 | 23 |
24 namespace mojo { | 24 namespace mojo { |
25 namespace internal { | |
26 | 25 |
27 // The Connector class is responsible for performing read/write operations on a | 26 // The Connector class is responsible for performing read/write operations on a |
28 // MessagePipe. It writes messages it receives through the MessageReceiver | 27 // MessagePipe. It writes messages it receives through the MessageReceiver |
29 // interface that it subclasses, and it forwards messages it reads through the | 28 // interface that it subclasses, and it forwards messages it reads through the |
30 // MessageReceiver interface assigned as its incoming receiver. | 29 // MessageReceiver interface assigned as its incoming receiver. |
31 // | 30 // |
32 // NOTE: | 31 // NOTE: |
33 // - MessagePipe I/O is non-blocking. | 32 // - MessagePipe I/O is non-blocking. |
34 // - Sending messages can be configured to be thread safe (please see comments | 33 // - Sending messages can be configured to be thread safe (please see comments |
35 // of the constructor). Other than that, the object should only be accessed | 34 // of the constructor). Other than that, the object should only be accessed |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 base::ThreadChecker thread_checker_; | 199 base::ThreadChecker thread_checker_; |
201 | 200 |
202 // Create a single weak ptr and use it everywhere, to avoid the malloc/free | 201 // Create a single weak ptr and use it everywhere, to avoid the malloc/free |
203 // cost of creating a new weak ptr whenever it is needed. | 202 // cost of creating a new weak ptr whenever it is needed. |
204 base::WeakPtr<Connector> weak_self_; | 203 base::WeakPtr<Connector> weak_self_; |
205 base::WeakPtrFactory<Connector> weak_factory_; | 204 base::WeakPtrFactory<Connector> weak_factory_; |
206 | 205 |
207 DISALLOW_COPY_AND_ASSIGN(Connector); | 206 DISALLOW_COPY_AND_ASSIGN(Connector); |
208 }; | 207 }; |
209 | 208 |
210 } // namespace internal | |
211 } // namespace mojo | 209 } // namespace mojo |
212 | 210 |
213 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_ | 211 #endif // MOJO_PUBLIC_CPP_BINDINGS_CONNECTOR_H_ |
OLD | NEW |