OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/interests/android/interests_service.h" | 5 #include "chrome/browser/interests/android/interests_service.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.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" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 return j_interests; | 44 return j_interests; |
45 } | 45 } |
46 | 46 |
47 } // namespace | 47 } // namespace |
48 | 48 |
49 InterestsService::InterestsService(Profile* profile) | 49 InterestsService::InterestsService(Profile* profile) |
50 : profile_(profile), weak_ptr_factory_(this) {} | 50 : profile_(profile), weak_ptr_factory_(this) {} |
51 | 51 |
52 InterestsService::~InterestsService() {} | 52 InterestsService::~InterestsService() {} |
53 | 53 |
54 void InterestsService::Destroy(JNIEnv* env, jobject obj) { | 54 void InterestsService::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
Marc Treib
2015/12/10 08:37:17
Don't you need a
using base::android::JavaParamRef
Torne
2015/12/10 11:26:01
All the generated jni/*_jni.h headers already use
Marc Treib
2015/12/10 11:46:02
Thanks for the explanation!
The generated *_jni.h
| |
55 delete this; | 55 delete this; |
56 } | 56 } |
57 | 57 |
58 void InterestsService::GetInterests(JNIEnv* env, | 58 void InterestsService::GetInterests( |
59 jobject obj, | 59 JNIEnv* env, |
60 jobject j_callback_obj) { | 60 const JavaParamRef<jobject>& obj, |
61 const JavaParamRef<jobject>& j_callback_obj) { | |
61 ScopedJavaGlobalRef<jobject> j_callback(env, j_callback_obj); | 62 ScopedJavaGlobalRef<jobject> j_callback(env, j_callback_obj); |
62 | 63 |
63 scoped_ptr<InterestsFetcher> fetcher = | 64 scoped_ptr<InterestsFetcher> fetcher = |
64 InterestsFetcher::CreateFromProfile(profile_); | 65 InterestsFetcher::CreateFromProfile(profile_); |
65 InterestsFetcher* fetcher_raw_ptr = fetcher.get(); | 66 InterestsFetcher* fetcher_raw_ptr = fetcher.get(); |
66 | 67 |
67 InterestsFetcher::InterestsCallback callback = base::Bind( | 68 InterestsFetcher::InterestsCallback callback = base::Bind( |
68 &InterestsService::OnObtainedInterests, | 69 &InterestsService::OnObtainedInterests, |
69 weak_ptr_factory_.GetWeakPtr(), | 70 weak_ptr_factory_.GetWeakPtr(), |
70 base::Passed(fetcher.Pass()), | 71 base::Passed(fetcher.Pass()), |
(...skipping 19 matching lines...) Expand all Loading... | |
90 j_interests.obj()); | 91 j_interests.obj()); |
91 } | 92 } |
92 | 93 |
93 static jlong Init(JNIEnv* env, | 94 static jlong Init(JNIEnv* env, |
94 const JavaParamRef<jobject>& jobj, | 95 const JavaParamRef<jobject>& jobj, |
95 const JavaParamRef<jobject>& jprofile) { | 96 const JavaParamRef<jobject>& jprofile) { |
96 InterestsService* interests_service = | 97 InterestsService* interests_service = |
97 new InterestsService(ProfileAndroid::FromProfileAndroid(jprofile)); | 98 new InterestsService(ProfileAndroid::FromProfileAndroid(jprofile)); |
98 return reinterpret_cast<intptr_t>(interests_service); | 99 return reinterpret_cast<intptr_t>(interests_service); |
99 } | 100 } |
OLD | NEW |