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

Side by Side Diff: chrome/nacl/nacl_ipc_adapter_unittest.cc

Issue 12226045: Linux/ChromeOS Chromium style checker cleanup, chrome/ edition part 1. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 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 | « chrome/common/worker_thread_ticker_unittest.cc ('k') | chrome/nacl/nacl_listener.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/nacl/nacl_ipc_adapter.h" 5 #include "chrome/nacl/nacl_ipc_adapter.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // handler. This should wake up any waiting threads and immediately return 270 // handler. This should wake up any waiting threads and immediately return
271 // -1. There is an inherent race condition in that we can't be sure if the 271 // -1. There is an inherent race condition in that we can't be sure if the
272 // other thread is actually waiting when this happens. This is OK, since the 272 // other thread is actually waiting when this happens. This is OK, since the
273 // behavior (which we also explicitly test later) is to return -1 if the 273 // behavior (which we also explicitly test later) is to return -1 if the
274 // channel has already had an error when you start waiting. 274 // channel has already had an error when you start waiting.
275 class MyThread : public base::SimpleThread { 275 class MyThread : public base::SimpleThread {
276 public: 276 public:
277 explicit MyThread(NaClIPCAdapter* adapter) 277 explicit MyThread(NaClIPCAdapter* adapter)
278 : SimpleThread("NaClIPCAdapterThread"), 278 : SimpleThread("NaClIPCAdapterThread"),
279 adapter_(adapter) {} 279 adapter_(adapter) {}
280 virtual void Run() { 280 virtual void Run() OVERRIDE {
281 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); 281 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
282 adapter_->OnChannelError(); 282 adapter_->OnChannelError();
283 } 283 }
284 private: 284 private:
285 scoped_refptr<NaClIPCAdapter> adapter_; 285 scoped_refptr<NaClIPCAdapter> adapter_;
286 }; 286 };
287 MyThread thread(adapter_); 287 MyThread thread(adapter_);
288 288
289 // IMPORTANT: do not return early from here down (including ASSERT_*) because 289 // IMPORTANT: do not return early from here down (including ASSERT_*) because
290 // the thread needs to joined or it will assert. 290 // the thread needs to joined or it will assert.
291 thread.Start(); 291 thread.Start();
292 292
293 // Request data. This will normally (modulo races) block until data is 293 // Request data. This will normally (modulo races) block until data is
294 // received or there is an error, and the thread above will wake us up 294 // received or there is an error, and the thread above will wake us up
295 // after 1s. 295 // after 1s.
296 const int kBufSize = 64; 296 const int kBufSize = 64;
297 char buf[kBufSize]; 297 char buf[kBufSize];
298 int result = BlockingReceive(buf, kBufSize); 298 int result = BlockingReceive(buf, kBufSize);
299 EXPECT_EQ(-1, result); 299 EXPECT_EQ(-1, result);
300 300
301 // Test the "previously had an error" case. BlockingReceive should return 301 // Test the "previously had an error" case. BlockingReceive should return
302 // immediately if there was an error. 302 // immediately if there was an error.
303 result = BlockingReceive(buf, kBufSize); 303 result = BlockingReceive(buf, kBufSize);
304 EXPECT_EQ(-1, result); 304 EXPECT_EQ(-1, result);
305 305
306 thread.Join(); 306 thread.Join();
307 } 307 }
308 308
OLDNEW
« no previous file with comments | « chrome/common/worker_thread_ticker_unittest.cc ('k') | chrome/nacl/nacl_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698