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

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

Issue 251483007: Mojo: Start writing some unit tests for mojo::system::Channel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing export macros Created 6 years, 8 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/raw_channel.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "mojo/system/raw_channel.h" 5 #include "mojo/system/raw_channel.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 DCHECK(!message_loop_for_io_); 119 DCHECK(!message_loop_for_io_);
120 message_loop_for_io_ = 120 message_loop_for_io_ =
121 static_cast<base::MessageLoopForIO*>(base::MessageLoop::current()); 121 static_cast<base::MessageLoopForIO*>(base::MessageLoop::current());
122 122
123 // No need to take the lock. No one should be using us yet. 123 // No need to take the lock. No one should be using us yet.
124 DCHECK(!read_buffer_); 124 DCHECK(!read_buffer_);
125 read_buffer_.reset(new ReadBuffer); 125 read_buffer_.reset(new ReadBuffer);
126 DCHECK(!write_buffer_); 126 DCHECK(!write_buffer_);
127 write_buffer_.reset(new WriteBuffer); 127 write_buffer_.reset(new WriteBuffer);
128 128
129 if (!OnInit()) 129 if (!OnInit()) {
130 delegate_ = NULL;
131 message_loop_for_io_ = NULL;
132 read_buffer_.reset();
133 write_buffer_.reset();
130 return false; 134 return false;
135 }
131 136
132 return ScheduleRead() == IO_PENDING; 137 return ScheduleRead() == IO_PENDING;
133 } 138 }
134 139
135 void RawChannel::Shutdown() { 140 void RawChannel::Shutdown() {
136 DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io_); 141 DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io_);
137 142
138 base::AutoLock locker(write_lock_); 143 base::AutoLock locker(write_lock_);
139 144
140 LOG_IF(WARNING, !write_buffer_->message_queue_.empty()) 145 LOG_IF(WARNING, !write_buffer_->message_queue_.empty())
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 } 366 }
362 367
363 write_stopped_ = true; 368 write_stopped_ = true;
364 STLDeleteElements(&write_buffer_->message_queue_); 369 STLDeleteElements(&write_buffer_->message_queue_);
365 write_buffer_->offset_ = 0; 370 write_buffer_->offset_ = 0;
366 return false; 371 return false;
367 } 372 }
368 373
369 } // namespace system 374 } // namespace system
370 } // namespace mojo 375 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/raw_channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698