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

Side by Side Diff: base/android/path_utils.cc

Issue 2262453002: Cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix stuff. Created 4 years, 4 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 (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/android/path_utils.h" 5 #include "base/android/path_utils.h"
6 6
7 #include "base/android/context_utils.h" 7 #include "base/android/context_utils.h"
8 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 12
13 #include "jni/PathUtils_jni.h" 13 #include "jni/PathUtils_jni.h"
14 14
15 namespace base { 15 namespace base {
16 namespace android { 16 namespace android {
17 17
18 bool GetDataDirectory(FilePath* result) { 18 bool GetDataDirectory(FilePath* result) {
19 JNIEnv* env = AttachCurrentThread(); 19 JNIEnv* env = AttachCurrentThread();
20 ScopedJavaLocalRef<jstring> path = 20 ScopedJavaLocalRef<jstring> path = Java_PathUtils_getDataDirectory(env);
21 Java_PathUtils_getDataDirectory(env, GetApplicationContext());
22 FilePath data_path(ConvertJavaStringToUTF8(path)); 21 FilePath data_path(ConvertJavaStringToUTF8(path));
23 *result = data_path; 22 *result = data_path;
24 return true; 23 return true;
25 } 24 }
26 25
27 bool GetDatabaseDirectory(FilePath* result) { 26 bool GetDatabaseDirectory(FilePath* result) {
28 JNIEnv* env = AttachCurrentThread(); 27 JNIEnv* env = AttachCurrentThread();
29 ScopedJavaLocalRef<jstring> path = 28 ScopedJavaLocalRef<jstring> path = Java_PathUtils_getDatabaseDirectory(env);
30 Java_PathUtils_getDatabaseDirectory(env, GetApplicationContext());
31 FilePath data_path(ConvertJavaStringToUTF8(path)); 29 FilePath data_path(ConvertJavaStringToUTF8(path));
32 *result = data_path; 30 *result = data_path;
33 return true; 31 return true;
34 } 32 }
35 33
36 bool GetCacheDirectory(FilePath* result) { 34 bool GetCacheDirectory(FilePath* result) {
37 JNIEnv* env = AttachCurrentThread(); 35 JNIEnv* env = AttachCurrentThread();
38 ScopedJavaLocalRef<jstring> path = 36 ScopedJavaLocalRef<jstring> path = Java_PathUtils_getCacheDirectory(env);
39 Java_PathUtils_getCacheDirectory(env, GetApplicationContext());
40 FilePath cache_path(ConvertJavaStringToUTF8(path)); 37 FilePath cache_path(ConvertJavaStringToUTF8(path));
41 *result = cache_path; 38 *result = cache_path;
42 return true; 39 return true;
43 } 40 }
44 41
45 bool GetThumbnailCacheDirectory(FilePath* result) { 42 bool GetThumbnailCacheDirectory(FilePath* result) {
46 JNIEnv* env = AttachCurrentThread(); 43 JNIEnv* env = AttachCurrentThread();
47 ScopedJavaLocalRef<jstring> path = 44 ScopedJavaLocalRef<jstring> path =
48 Java_PathUtils_getThumbnailCacheDirectory(env, GetApplicationContext()); 45 Java_PathUtils_getThumbnailCacheDirectory(env);
49 FilePath thumbnail_cache_path(ConvertJavaStringToUTF8(path)); 46 FilePath thumbnail_cache_path(ConvertJavaStringToUTF8(path));
50 *result = thumbnail_cache_path; 47 *result = thumbnail_cache_path;
51 return true; 48 return true;
52 } 49 }
53 50
54 bool GetDownloadsDirectory(FilePath* result) { 51 bool GetDownloadsDirectory(FilePath* result) {
55 JNIEnv* env = AttachCurrentThread(); 52 JNIEnv* env = AttachCurrentThread();
56 ScopedJavaLocalRef<jstring> path = 53 ScopedJavaLocalRef<jstring> path = Java_PathUtils_getDownloadsDirectory(env);
57 Java_PathUtils_getDownloadsDirectory(env, GetApplicationContext());
58 FilePath downloads_path(ConvertJavaStringToUTF8(path)); 54 FilePath downloads_path(ConvertJavaStringToUTF8(path));
59 *result = downloads_path; 55 *result = downloads_path;
60 return true; 56 return true;
61 } 57 }
62 58
63 bool GetNativeLibraryDirectory(FilePath* result) { 59 bool GetNativeLibraryDirectory(FilePath* result) {
64 JNIEnv* env = AttachCurrentThread(); 60 JNIEnv* env = AttachCurrentThread();
65 ScopedJavaLocalRef<jstring> path = 61 ScopedJavaLocalRef<jstring> path =
66 Java_PathUtils_getNativeLibraryDirectory(env, GetApplicationContext()); 62 Java_PathUtils_getNativeLibraryDirectory(env);
67 FilePath library_path(ConvertJavaStringToUTF8(path)); 63 FilePath library_path(ConvertJavaStringToUTF8(path));
68 *result = library_path; 64 *result = library_path;
69 return true; 65 return true;
70 } 66 }
71 67
72 bool GetExternalStorageDirectory(FilePath* result) { 68 bool GetExternalStorageDirectory(FilePath* result) {
73 JNIEnv* env = AttachCurrentThread(); 69 JNIEnv* env = AttachCurrentThread();
74 ScopedJavaLocalRef<jstring> path = 70 ScopedJavaLocalRef<jstring> path =
75 Java_PathUtils_getExternalStorageDirectory(env); 71 Java_PathUtils_getExternalStorageDirectory(env);
76 FilePath storage_path(ConvertJavaStringToUTF8(path)); 72 FilePath storage_path(ConvertJavaStringToUTF8(path));
77 *result = storage_path; 73 *result = storage_path;
78 return true; 74 return true;
79 } 75 }
80 76
81 } // namespace android 77 } // namespace android
82 } // namespace base 78 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698