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

Side by Side Diff: remoting/host/username.cc

Issue 1863933002: [remoting android] Add and build host code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@android-host-add-native
Patch Set: Created 4 years, 8 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 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 "remoting/host/username.h" 5 #include "remoting/host/username.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 11
12 #if defined(OS_POSIX) 12 #if defined(OS_POSIX)
13 #include <pwd.h> 13 #include <pwd.h>
14 #include <sys/types.h> 14 #include <sys/types.h>
15 #include <unistd.h> 15 #include <unistd.h>
16 #endif // defined(OS_POSIX) 16 #endif // defined(OS_POSIX)
17 17
18 namespace remoting { 18 namespace remoting {
19 19
20 std::string GetUsername() { 20 std::string GetUsername() {
21 #if defined(OS_POSIX) 21 #if defined(OS_ANDROID)
22 return std::string();
Sergey Ulanov 2016/04/07 00:56:14 I don't think you need to separate this from the c
Lambros 2016/04/12 21:58:04 Done.
23 #elif defined(OS_POSIX)
22 long buf_size = sysconf(_SC_GETPW_R_SIZE_MAX); 24 long buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
23 if (buf_size <= 0) 25 if (buf_size <= 0)
24 return std::string(); 26 return std::string();
25 27
26 std::vector<char> buf(buf_size); 28 std::vector<char> buf(buf_size);
27 struct passwd passwd; 29 struct passwd passwd;
28 struct passwd* passwd_result = nullptr; 30 struct passwd* passwd_result = nullptr;
29 getpwuid_r(getuid(), &passwd, &(buf[0]), buf_size, &passwd_result); 31 getpwuid_r(getuid(), &passwd, &(buf[0]), buf_size, &passwd_result);
30 return passwd_result ? passwd_result->pw_name : std::string(); 32 return passwd_result ? passwd_result->pw_name : std::string();
31 #else // !defined(OS_POSIX) 33 #else // !defined(OS_POSIX)
32 NOTIMPLEMENTED(); 34 NOTIMPLEMENTED();
33 return std::string(); 35 return std::string();
34 #endif // defined(OS_POSIX) 36 #endif // defined(OS_POSIX)
35 } 37 }
36 38
37 } // namespace remoting 39 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698