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

Side by Side Diff: mojo/edk/test/test_utils_posix.cc

Issue 1347783002: Add our own (mojo::util::)ScopedFILE and replace uses of base::ScopedFILE with it. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 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
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/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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698