OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/browser/chromeos/pipe_reader.h" | 5 #include "chrome/browser/chromeos/pipe_reader.h" |
6 | 6 |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
8 | 8 |
| 9 namespace chromeos { |
| 10 |
9 std::string PipeReader::Read(const uint32 bytes_to_read) { | 11 std::string PipeReader::Read(const uint32 bytes_to_read) { |
10 scoped_array<char> buffer(new char[bytes_to_read]); | 12 scoped_array<char> buffer(new char[bytes_to_read]); |
11 if (pipe_ || (pipe_ = fopen(pipe_name_.c_str(), "r"))) { | 13 if (pipe_ || (pipe_ = fopen(pipe_name_.c_str(), "r"))) { |
12 const char* to_return = fgets(buffer.get(), bytes_to_read, pipe_); | 14 const char* to_return = fgets(buffer.get(), bytes_to_read, pipe_); |
13 if (to_return) | 15 if (to_return) |
14 return to_return; // auto-coerced to a std::string. | 16 return to_return; // auto-coerced to a std::string. |
15 } | 17 } |
16 return std::string(); | 18 return std::string(); |
17 } | 19 } |
| 20 |
| 21 } // namespace chromeos |
OLD | NEW |