| OLD | NEW | 
|---|
| 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/edk/test/test_utils.h" | 5 #include "mojo/edk/test/test_utils.h" | 
| 6 | 6 | 
| 7 #include <fcntl.h> | 7 #include <fcntl.h> | 
| 8 #include <unistd.h> | 8 #include <unistd.h> | 
| 9 | 9 | 
|  | 10 #include "base/logging.h" | 
| 10 #include "base/posix/eintr_wrapper.h" | 11 #include "base/posix/eintr_wrapper.h" | 
| 11 | 12 | 
| 12 namespace mojo { | 13 namespace mojo { | 
| 13 namespace test { | 14 namespace test { | 
| 14 | 15 | 
| 15 bool BlockingWrite(const embedder::PlatformHandle& handle, | 16 bool BlockingWrite(const embedder::PlatformHandle& handle, | 
| 16                    const void* buffer, | 17                    const void* buffer, | 
| 17                    size_t bytes_to_write, | 18                    size_t bytes_to_write, | 
| 18                    size_t* bytes_written) { | 19                    size_t* bytes_written) { | 
| 19   int original_flags = fcntl(handle.fd, F_GETFL); | 20   int original_flags = fcntl(handle.fd, F_GETFL); | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 65       return false; | 66       return false; | 
| 66 | 67 | 
| 67     *bytes_read = 0; | 68     *bytes_read = 0; | 
| 68   } else { | 69   } else { | 
| 69     *bytes_read = result; | 70     *bytes_read = result; | 
| 70   } | 71   } | 
| 71 | 72 | 
| 72   return true; | 73   return true; | 
| 73 } | 74 } | 
| 74 | 75 | 
| 75 embedder::ScopedPlatformHandle PlatformHandleFromFILE(base::ScopedFILE fp) { | 76 embedder::ScopedPlatformHandle PlatformHandleFromFILE(util::ScopedFILE fp) { | 
| 76   CHECK(fp); | 77   CHECK(fp); | 
| 77   int rv = dup(fileno(fp.get())); | 78   int rv = dup(fileno(fp.get())); | 
| 78   PCHECK(rv != -1) << "dup"; | 79   PCHECK(rv != -1) << "dup"; | 
| 79   return embedder::ScopedPlatformHandle(embedder::PlatformHandle(rv)); | 80   return embedder::ScopedPlatformHandle(embedder::PlatformHandle(rv)); | 
| 80 } | 81 } | 
| 81 | 82 | 
| 82 base::ScopedFILE FILEFromPlatformHandle(embedder::ScopedPlatformHandle h, | 83 util::ScopedFILE FILEFromPlatformHandle(embedder::ScopedPlatformHandle h, | 
| 83                                         const char* mode) { | 84                                         const char* mode) { | 
| 84   CHECK(h.is_valid()); | 85   CHECK(h.is_valid()); | 
| 85   base::ScopedFILE rv(fdopen(h.release().fd, mode)); | 86   util::ScopedFILE rv(fdopen(h.release().fd, mode)); | 
| 86   PCHECK(rv) << "fdopen"; | 87   PCHECK(rv) << "fdopen"; | 
| 87   return rv.Pass(); | 88   return rv.Pass(); | 
| 88 } | 89 } | 
| 89 | 90 | 
| 90 }  // namespace test | 91 }  // namespace test | 
| 91 }  // namespace mojo | 92 }  // namespace mojo | 
| OLD | NEW | 
|---|