| OLD | NEW |
| 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 "remoting/base/util.h" | 5 #include "remoting/base/util.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "media/base/video_frame.h" | 12 #include "media/base/video_frame.h" |
| 13 #include "media/base/yuv_convert.h" | 13 #include "media/base/yuv_convert.h" |
| 14 #include "third_party/skia/include/core/SkRegion.h" | 14 #include "third_party/skia/include/core/SkRegion.h" |
| 15 | 15 |
| 16 #if defined(OS_POSIX) |
| 17 #include <pwd.h> |
| 18 #include <sys/types.h> |
| 19 #include <unistd.h> |
| 20 #endif // defined(OS_POSIX) |
| 21 |
| 16 using media::VideoFrame; | 22 using media::VideoFrame; |
| 17 | 23 |
| 18 namespace remoting { | 24 namespace remoting { |
| 19 | 25 |
| 20 enum { kBytesPerPixelRGB32 = 4 }; | 26 enum { kBytesPerPixelRGB32 = 4 }; |
| 21 | 27 |
| 22 // Do not write LOG messages in this routine since it is called from within | 28 // Do not write LOG messages in this routine since it is called from within |
| 23 // our LOG message handler. Bad things will happen. | 29 // our LOG message handler. Bad things will happen. |
| 24 std::string GetTimestampString() { | 30 std::string GetTimestampString() { |
| 25 base::Time t = base::Time::NowFromSystemTime(); | 31 base::Time t = base::Time::NowFromSystemTime(); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 return false; | 310 return false; |
| 305 } | 311 } |
| 306 | 312 |
| 307 ++ptr; | 313 ++ptr; |
| 308 } | 314 } |
| 309 } | 315 } |
| 310 | 316 |
| 311 return true; | 317 return true; |
| 312 } | 318 } |
| 313 | 319 |
| 320 std::string GetUsername() { |
| 321 #if defined(OS_POSIX) |
| 322 long buf_size = sysconf(_SC_GETPW_R_SIZE_MAX); |
| 323 if (buf_size <= 0) |
| 324 return std::string(); |
| 325 scoped_array<char> buf(new char[buf_size]); |
| 326 struct passwd passwd; |
| 327 struct passwd* passwd_result = NULL; |
| 328 getpwuid_r(getuid(), &passwd, buf.get(), buf_size, &passwd_result); |
| 329 if (!passwd_result) |
| 330 return std::string(); |
| 331 return std::string(passwd_result->pw_name); |
| 332 #else // !defined(OS_POSIX) |
| 333 return std::string(); |
| 334 #endif // defined(OS_POSIX) |
| 335 } |
| 336 |
| 314 } // namespace remoting | 337 } // namespace remoting |
| OLD | NEW |