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 #include "components/nacl/loader/nacl_ipc_adapter.h" | 5 #include "components/nacl/loader/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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 // handler. This should wake up any waiting threads and immediately return | 272 // handler. This should wake up any waiting threads and immediately return |
273 // -1. There is an inherent race condition in that we can't be sure if the | 273 // -1. There is an inherent race condition in that we can't be sure if the |
274 // other thread is actually waiting when this happens. This is OK, since the | 274 // other thread is actually waiting when this happens. This is OK, since the |
275 // behavior (which we also explicitly test later) is to return -1 if the | 275 // behavior (which we also explicitly test later) is to return -1 if the |
276 // channel has already had an error when you start waiting. | 276 // channel has already had an error when you start waiting. |
277 class MyThread : public base::SimpleThread { | 277 class MyThread : public base::SimpleThread { |
278 public: | 278 public: |
279 explicit MyThread(NaClIPCAdapter* adapter) | 279 explicit MyThread(NaClIPCAdapter* adapter) |
280 : SimpleThread("NaClIPCAdapterThread"), | 280 : SimpleThread("NaClIPCAdapterThread"), |
281 adapter_(adapter) {} | 281 adapter_(adapter) {} |
282 virtual void Run() override { | 282 void Run() override { |
283 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); | 283 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
284 adapter_->OnChannelError(); | 284 adapter_->OnChannelError(); |
285 } | 285 } |
286 private: | 286 private: |
287 scoped_refptr<NaClIPCAdapter> adapter_; | 287 scoped_refptr<NaClIPCAdapter> adapter_; |
288 }; | 288 }; |
289 MyThread thread(adapter_.get()); | 289 MyThread thread(adapter_.get()); |
290 | 290 |
291 // IMPORTANT: do not return early from here down (including ASSERT_*) because | 291 // IMPORTANT: do not return early from here down (including ASSERT_*) because |
292 // the thread needs to joined or it will assert. | 292 // the thread needs to joined or it will assert. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 EXPECT_EQ(NACL_ABI_O_RDONLY, | 348 EXPECT_EQ(NACL_ABI_O_RDONLY, |
349 TranslatePepperFileReadWriteOpenFlagsForTesting( | 349 TranslatePepperFileReadWriteOpenFlagsForTesting( |
350 PP_FILEOPENFLAG_CREATE)); | 350 PP_FILEOPENFLAG_CREATE)); |
351 EXPECT_EQ(NACL_ABI_O_RDONLY, | 351 EXPECT_EQ(NACL_ABI_O_RDONLY, |
352 TranslatePepperFileReadWriteOpenFlagsForTesting( | 352 TranslatePepperFileReadWriteOpenFlagsForTesting( |
353 PP_FILEOPENFLAG_TRUNCATE)); | 353 PP_FILEOPENFLAG_TRUNCATE)); |
354 EXPECT_EQ(NACL_ABI_O_RDONLY, | 354 EXPECT_EQ(NACL_ABI_O_RDONLY, |
355 TranslatePepperFileReadWriteOpenFlagsForTesting( | 355 TranslatePepperFileReadWriteOpenFlagsForTesting( |
356 PP_FILEOPENFLAG_EXCLUSIVE)); | 356 PP_FILEOPENFLAG_EXCLUSIVE)); |
357 } | 357 } |
OLD | NEW |