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

Side by Side Diff: base/base_paths_android.cc

Issue 1914983002: Add CHECK in case PathProviderAndroid is failing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: PCHECK 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
« no previous file with comments | « no previous file | no next file » | 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 // Defines base::PathProviderAndroid which replaces base::PathProviderPosix for 5 // Defines base::PathProviderAndroid which replaces base::PathProviderPosix for
6 // Android in base/path_service.cc. 6 // Android in base/path_service.cc.
7 7
8 #include <limits.h> 8 #include <limits.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
11 #include "base/android/jni_android.h" 11 #include "base/android/jni_android.h"
12 #include "base/android/path_utils.h" 12 #include "base/android/path_utils.h"
13 #include "base/base_paths.h" 13 #include "base/base_paths.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/process/process_metrics.h" 17 #include "base/process/process_metrics.h"
18 18
19 namespace base { 19 namespace base {
20 20
21 bool PathProviderAndroid(int key, FilePath* result) { 21 bool PathProviderAndroid(int key, FilePath* result) {
22 switch (key) { 22 switch (key) {
23 case base::FILE_EXE: { 23 case base::FILE_EXE: {
24 char bin_dir[PATH_MAX + 1]; 24 char bin_dir[PATH_MAX + 1];
25 int bin_dir_size = readlink(kProcSelfExe, bin_dir, PATH_MAX); 25 int bin_dir_size = readlink(kProcSelfExe, bin_dir, PATH_MAX);
26 if (bin_dir_size < 0 || bin_dir_size > PATH_MAX) { 26 // TODO(falken): This PCHECK is for debugging crbug.com/600226.
27 NOTREACHED() << "Unable to resolve " << kProcSelfExe << "."; 27 // Revert to NOTREACHED when the cause of the bug is understood.
28 return false; 28 PCHECK(bin_dir_size > 0 && bin_dir_size <= PATH_MAX)
29 } 29 << "Unable to resolve " << kProcSelfExe
30 << ". bin_dir_size=" << bin_dir_size;
30 bin_dir[bin_dir_size] = 0; 31 bin_dir[bin_dir_size] = 0;
31 *result = FilePath(bin_dir); 32 *result = FilePath(bin_dir);
32 return true; 33 return true;
33 } 34 }
34 case base::FILE_MODULE: 35 case base::FILE_MODULE:
35 // dladdr didn't work in Android as only the file name was returned. 36 // dladdr didn't work in Android as only the file name was returned.
36 NOTIMPLEMENTED(); 37 NOTIMPLEMENTED();
37 return false; 38 return false;
38 case base::DIR_MODULE: 39 case base::DIR_MODULE:
39 return base::android::GetNativeLibraryDirectory(result); 40 return base::android::GetNativeLibraryDirectory(result);
(...skipping 12 matching lines...) Expand all
52 return base::android::GetExternalStorageDirectory(result); 53 return base::android::GetExternalStorageDirectory(result);
53 default: 54 default:
54 // Note: the path system expects this function to override the default 55 // Note: the path system expects this function to override the default
55 // behavior. So no need to log an error if we don't support a given 56 // behavior. So no need to log an error if we don't support a given
56 // path. The system will just use the default. 57 // path. The system will just use the default.
57 return false; 58 return false;
58 } 59 }
59 } 60 }
60 61
61 } // namespace base 62 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698