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

Side by Side Diff: base/base_paths_android.cc

Issue 10914279: Cleanup: Add a const variable for /proc/self/exe. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/base_paths_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/base_paths.h" 5 #include "base/base_paths.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/path_utils.h" 10 #include "base/android/path_utils.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 14 #include "base/process_util.h"
15 namespace {
16
17 const char kSelfExe[] = "/proc/self/exe";
18
19 } // namespace
20 15
21 namespace base { 16 namespace base {
22 17
23 bool PathProviderAndroid(int key, FilePath* result) { 18 bool PathProviderAndroid(int key, FilePath* result) {
24 switch (key) { 19 switch (key) {
25 case base::FILE_EXE: { 20 case base::FILE_EXE: {
26 char bin_dir[PATH_MAX + 1]; 21 char bin_dir[PATH_MAX + 1];
27 int bin_dir_size = readlink(kSelfExe, bin_dir, PATH_MAX); 22 int bin_dir_size = readlink(kProcSelfExe, bin_dir, PATH_MAX);
28 if (bin_dir_size < 0 || bin_dir_size > PATH_MAX) { 23 if (bin_dir_size < 0 || bin_dir_size > PATH_MAX) {
29 NOTREACHED() << "Unable to resolve " << kSelfExe << "."; 24 NOTREACHED() << "Unable to resolve " << kProcSelfExe << ".";
30 return false; 25 return false;
31 } 26 }
32 bin_dir[bin_dir_size] = 0; 27 bin_dir[bin_dir_size] = 0;
33 *result = FilePath(bin_dir); 28 *result = FilePath(bin_dir);
34 return true; 29 return true;
35 } 30 }
36 case base::FILE_MODULE: { 31 case base::FILE_MODULE: {
37 // dladdr didn't work in Android as only the file name was returned. 32 // dladdr didn't work in Android as only the file name was returned.
38 NOTIMPLEMENTED(); 33 NOTIMPLEMENTED();
39 return false; 34 return false;
(...skipping 26 matching lines...) Expand all
66 default: { 61 default: {
67 // Note: the path system expects this function to override the default 62 // Note: the path system expects this function to override the default
68 // behavior. So no need to log an error if we don't support a given 63 // behavior. So no need to log an error if we don't support a given
69 // path. The system will just use the default. 64 // path. The system will just use the default.
70 return false; 65 return false;
71 } 66 }
72 } 67 }
73 } 68 }
74 69
75 } // namespace base 70 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/base_paths_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698