Mojo multiple command buffer support and sample
[chromium-blink-merge.git] / base / base_paths_android.cc
blob56c6cc70f474bd6a7a2575f2ec90ee6cc0ee6686
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
3 // found in the LICENSE file.
5 // Defines base::PathProviderAndroid which replaces base::PathProviderPosix for
6 // Android in base/path_service.cc.
8 #include <unistd.h>
10 #include "base/android/jni_android.h"
11 #include "base/android/path_utils.h"
12 #include "base/base_paths.h"
13 #include "base/files/file_path.h"
14 #include "base/files/file_util.h"
15 #include "base/logging.h"
16 #include "base/process/process_metrics.h"
18 namespace base {
20 bool PathProviderAndroid(int key, FilePath* result) {
21 switch (key) {
22 case base::FILE_EXE: {
23 char bin_dir[PATH_MAX + 1];
24 int bin_dir_size = readlink(kProcSelfExe, bin_dir, PATH_MAX);
25 if (bin_dir_size < 0 || bin_dir_size > PATH_MAX) {
26 NOTREACHED() << "Unable to resolve " << kProcSelfExe << ".";
27 return false;
29 bin_dir[bin_dir_size] = 0;
30 *result = FilePath(bin_dir);
31 return true;
33 case base::FILE_MODULE:
34 // dladdr didn't work in Android as only the file name was returned.
35 NOTIMPLEMENTED();
36 return false;
37 case base::DIR_MODULE:
38 return base::android::GetNativeLibraryDirectory(result);
39 case base::DIR_SOURCE_ROOT:
40 // This const is only used for tests.
41 return base::android::GetExternalStorageDirectory(result);
42 case base::DIR_USER_DESKTOP:
43 // Android doesn't support GetUserDesktop.
44 NOTIMPLEMENTED();
45 return false;
46 case base::DIR_CACHE:
47 return base::android::GetCacheDirectory(result);
48 case base::DIR_ANDROID_APP_DATA:
49 return base::android::GetDataDirectory(result);
50 case base::DIR_ANDROID_EXTERNAL_STORAGE:
51 return base::android::GetExternalStorageDirectory(result);
52 default:
53 // Note: the path system expects this function to override the default
54 // behavior. So no need to log an error if we don't support a given
55 // path. The system will just use the default.
56 return false;
60 } // namespace base