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

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

Issue 1426343002: EDK: Move mutex.*, cond_var.*, and thread_annotations.h to //mojo/edk/util. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: oops Created 5 years, 1 month 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/edk/system/platform_handle_dispatcher.cc ('k') | mojo/edk/system/raw_channel.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_EDK_SYSTEM_RAW_CHANNEL_H_ 5 #ifndef MOJO_EDK_SYSTEM_RAW_CHANNEL_H_
6 #define MOJO_EDK_SYSTEM_RAW_CHANNEL_H_ 6 #define MOJO_EDK_SYSTEM_RAW_CHANNEL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "mojo/edk/embedder/platform_handle_vector.h" 12 #include "mojo/edk/embedder/platform_handle_vector.h"
13 #include "mojo/edk/embedder/scoped_platform_handle.h" 13 #include "mojo/edk/embedder/scoped_platform_handle.h"
14 #include "mojo/edk/system/message_in_transit.h" 14 #include "mojo/edk/system/message_in_transit.h"
15 #include "mojo/edk/system/message_in_transit_queue.h" 15 #include "mojo/edk/system/message_in_transit_queue.h"
16 #include "mojo/edk/system/mutex.h" 16 #include "mojo/edk/util/mutex.h"
17 #include "mojo/edk/system/thread_annotations.h" 17 #include "mojo/edk/util/thread_annotations.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 MessageLoopForIO; 21 class MessageLoopForIO;
22 } 22 }
23 23
24 namespace mojo { 24 namespace mojo {
25 namespace system { 25 namespace system {
26 26
27 // |RawChannel| is an interface and base class for objects that wrap an OS 27 // |RawChannel| is an interface and base class for objects that wrap an OS
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // object may be destroyed by this call. 204 // object may be destroyed by this call.
205 void OnReadCompleted(IOResult io_result, size_t bytes_read) 205 void OnReadCompleted(IOResult io_result, size_t bytes_read)
206 MOJO_LOCKS_EXCLUDED(write_mutex_); 206 MOJO_LOCKS_EXCLUDED(write_mutex_);
207 // |result| must not be |IO_PENDING|. Must be called on the I/O thread. This 207 // |result| must not be |IO_PENDING|. Must be called on the I/O thread. This
208 // object may be destroyed by this call. 208 // object may be destroyed by this call.
209 void OnWriteCompleted(IOResult io_result, 209 void OnWriteCompleted(IOResult io_result,
210 size_t platform_handles_written, 210 size_t platform_handles_written,
211 size_t bytes_written) MOJO_LOCKS_EXCLUDED(write_mutex_); 211 size_t bytes_written) MOJO_LOCKS_EXCLUDED(write_mutex_);
212 212
213 base::MessageLoopForIO* message_loop_for_io() { return message_loop_for_io_; } 213 base::MessageLoopForIO* message_loop_for_io() { return message_loop_for_io_; }
214 Mutex& write_mutex() MOJO_LOCK_RETURNED(write_mutex_) { return write_mutex_; } 214 util::Mutex& write_mutex() MOJO_LOCK_RETURNED(write_mutex_) {
215 return write_mutex_;
216 }
215 217
216 // Should only be called on the I/O thread. 218 // Should only be called on the I/O thread.
217 ReadBuffer* read_buffer() { return read_buffer_.get(); } 219 ReadBuffer* read_buffer() { return read_buffer_.get(); }
218 220
219 WriteBuffer* write_buffer_no_lock() 221 WriteBuffer* write_buffer_no_lock()
220 MOJO_EXCLUSIVE_LOCKS_REQUIRED(write_mutex_) { 222 MOJO_EXCLUSIVE_LOCKS_REQUIRED(write_mutex_) {
221 return write_buffer_.get(); 223 return write_buffer_.get();
222 } 224 }
223 225
224 // Adds |message| to the write message queue. Implementation subclasses may 226 // Adds |message| to the write message queue. Implementation subclasses may
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 314
313 // Set in |Init()| and never changed (hence usable on any thread without 315 // Set in |Init()| and never changed (hence usable on any thread without
314 // locking): 316 // locking):
315 base::MessageLoopForIO* message_loop_for_io_; 317 base::MessageLoopForIO* message_loop_for_io_;
316 318
317 // Only used on the I/O thread: 319 // Only used on the I/O thread:
318 Delegate* delegate_; 320 Delegate* delegate_;
319 bool* set_on_shutdown_; 321 bool* set_on_shutdown_;
320 std::unique_ptr<ReadBuffer> read_buffer_; 322 std::unique_ptr<ReadBuffer> read_buffer_;
321 323
322 Mutex write_mutex_; // Protects the following members. 324 util::Mutex write_mutex_; // Protects the following members.
323 bool write_stopped_ MOJO_GUARDED_BY(write_mutex_); 325 bool write_stopped_ MOJO_GUARDED_BY(write_mutex_);
324 std::unique_ptr<WriteBuffer> write_buffer_ MOJO_GUARDED_BY(write_mutex_); 326 std::unique_ptr<WriteBuffer> write_buffer_ MOJO_GUARDED_BY(write_mutex_);
325 327
326 // This is used for posting tasks from write threads to the I/O thread. The 328 // This is used for posting tasks from write threads to the I/O thread. The
327 // weak pointers it produces are only used/invalidated on the I/O thread. 329 // weak pointers it produces are only used/invalidated on the I/O thread.
328 base::WeakPtrFactory<RawChannel> weak_ptr_factory_ 330 base::WeakPtrFactory<RawChannel> weak_ptr_factory_
329 MOJO_GUARDED_BY(write_mutex_); 331 MOJO_GUARDED_BY(write_mutex_);
330 332
331 MOJO_DISALLOW_COPY_AND_ASSIGN(RawChannel); 333 MOJO_DISALLOW_COPY_AND_ASSIGN(RawChannel);
332 }; 334 };
333 335
334 } // namespace system 336 } // namespace system
335 } // namespace mojo 337 } // namespace mojo
336 338
337 #endif // MOJO_EDK_SYSTEM_RAW_CHANNEL_H_ 339 #endif // MOJO_EDK_SYSTEM_RAW_CHANNEL_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/platform_handle_dispatcher.cc ('k') | mojo/edk/system/raw_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698