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

Issue 1334233003: Add the JNI code in order to let Java use the InterestsFetcher. (Closed)

Created:
5 years, 3 months ago by tache
Modified:
3 years, 10 months ago
CC:
chromium-reviews, Sergiu
Base URL:
https://chromium.googlesource.com/chromium/src.git@ntp-interests-retriever
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Add the JNI code in order to let Java use the InterestsFetcher. Depends on https://codereview.chromium.org/1317513004/ BUG=537145

Patch Set 1 #

Total comments: 22

Patch Set 2 : #

Patch Set 3 : #

Total comments: 6

Patch Set 4 : #

Patch Set 5 : The access_token is obtained in the native code. #

Total comments: 36

Patch Set 6 : Fix some of the comments #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+294 lines, -0 lines) Patch
A chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java View 1 2 3 4 5 1 chunk +100 lines, -0 lines 0 comments Download
M chrome/browser/android/chrome_jni_registrar.cc View 1 2 3 4 5 2 chunks +2 lines, -0 lines 0 comments Download
A chrome/browser/android/interests_service.h View 1 2 3 4 5 1 chunk +45 lines, -0 lines 0 comments Download
A chrome/browser/android/interests_service.cc View 1 2 3 4 5 1 chunk +97 lines, -0 lines 1 comment Download
A chrome/browser/android/interests_service_unittest.cc View 1 2 3 4 5 1 chunk +46 lines, -0 lines 0 comments Download
M chrome/chrome_browser.gypi View 1 2 3 4 5 2 chunks +3 lines, -0 lines 0 comments Download
M chrome/chrome_tests_unit.gypi View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 12 (3 generated)
tache
Added the JNI code in order to let Java use the InterestsFetcher.
5 years, 3 months ago (2015-09-11 13:33:51 UTC) #2
Marc Treib
Please run "git cl format", there's a few formatting issues it should be able to ...
5 years, 3 months ago (2015-09-11 14:54:26 UTC) #3
tache
https://codereview.chromium.org/1334233003/diff/1/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java File chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java (right): https://codereview.chromium.org/1334233003/diff/1/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java#newcode18 chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java:18: * POJO representing an interest. On 2015/09/11 14:54:25, Marc ...
5 years, 3 months ago (2015-09-11 15:45:09 UTC) #4
Marc Treib
https://codereview.chromium.org/1334233003/diff/40001/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java File chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java (right): https://codereview.chromium.org/1334233003/diff/40001/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java#newcode5 chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java:5: package org.chromium.chrome.browser.ntp; All the other code in that folder ...
5 years, 3 months ago (2015-09-11 16:02:14 UTC) #5
tache
https://codereview.chromium.org/1334233003/diff/40001/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java File chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java (right): https://codereview.chromium.org/1334233003/diff/40001/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java#newcode5 chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java:5: package org.chromium.chrome.browser.ntp; On 2015/09/11 16:02:14, Marc Treib wrote: > ...
5 years, 3 months ago (2015-09-18 09:41:21 UTC) #6
tache
5 years, 2 months ago (2015-09-29 13:20:14 UTC) #8
Bernhard Bauer
It might be helpful to mention that your CL is based on https://codereview.chromium.org/1317513004/. https://codereview.chromium.org/1334233003/diff/80001/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java File ...
5 years, 2 months ago (2015-09-29 14:04:05 UTC) #9
Marc Treib
https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/interests_service_unittest.cc File chrome/browser/android/interests_service_unittest.cc (right): https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/interests_service_unittest.cc#newcode31 chrome/browser/android/interests_service_unittest.cc:31: InterestsServiceTest() {} On 2015/09/29 14:04:05, Bernhard Bauer wrote: > ...
5 years, 2 months ago (2015-10-06 13:33:57 UTC) #10
PEConn
5 years, 2 months ago (2015-10-07 13:55:21 UTC) #12
I've moved this CL over:
https://codereview.chromium.org/1396443002

https://codereview.chromium.org/1334233003/diff/80001/chrome/android/java/src...
File
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java
(right):

https://codereview.chromium.org/1334233003/diff/80001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java:22:
private double mRelevance;
On 2015/09/29 14:04:04, Bernhard Bauer wrote:
> Make these final?

Done.

https://codereview.chromium.org/1334233003/diff/80001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java:39:
return this.mRelevance;
On 2015/09/29 14:04:04, Bernhard Bauer wrote:
> You can remove the `this.`.

Done.

https://codereview.chromium.org/1334233003/diff/80001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java:48:
* In case of an error an empty array will be returned.
On 2015/09/29 14:04:04, Bernhard Bauer wrote:
> Generally, it's useful to be able to distinguish between an actual empty array
> and an error condition. Would returning null work?

Done.

https://codereview.chromium.org/1334233003/diff/80001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java:78:
// Don't notify callback if we've already been destroyed.
On 2015/09/29 14:04:04, Bernhard Bauer wrote:
> Is this actually going to be necessary? The native part uses weak pointers, so
> we know that this callback will never be called when it's destroyed.

Done.

https://codereview.chromium.org/1334233003/diff/80001/chrome/android/java/src...
chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsService.java:92:
public static Interest createInterest(String name, String imageUrl, double
relevance) {
On 2015/09/29 14:04:04, Bernhard Bauer wrote:
> If this method is only meant to be called from native, you can make it private
> (JNI don't care about that).

Done.

https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/...
File chrome/browser/android/interests_service.cc (right):

https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/...
chrome/browser/android/interests_service.cc:24: const char kInterestJavaClass[]
=
On 2015/09/29 14:04:04, Bernhard Bauer wrote:
> Const variables actually get internal linkage automatically, so the anonymous
> namespace isn't really necessary if there is nothing else in there.

Done.

https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/...
chrome/browser/android/interests_service.cc:27: }  // end namespace
On 2015/09/29 14:04:04, Bernhard Bauer wrote:
> If you do keep the namespace, remove the "end ".

Done.

https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/...
chrome/browser/android/interests_service.cc:41:
scoped_ptr<ScopedJavaGlobalRef<jobject>> j_callback(
On 2015/09/29 14:04:05, Bernhard Bauer wrote:
> You don't actually need a scoped_ptr for a ScopedJavaGlobalRef: It's totally
> fine to copy it around.

Done.

https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/...
chrome/browser/android/interests_service.cc:46: InterestsFetcher* fetcher =
On 2015/09/29 14:04:04, Bernhard Bauer wrote:
> I would make this a scoped_ptr and only release() it below, so it's clearer
> you're not leaking the pointer.

Done.

https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/...
chrome/browser/android/interests_service.cc:64: jclass interest_class =
env->FindClass(kInterestJavaClass);
On 2015/09/29 14:04:05, Bernhard Bauer wrote:
> It's not great to have to manually resolve this class (for example, it makes
it
> difficult to find references to the class when renaming it) -- Could you maybe
> add a static Java method that will do this instead?

Done.

https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/...
chrome/browser/android/interests_service.cc:67:
env->NewObjectArray(interests.size(), interest_class, 0);
On 2015/09/29 14:04:04, Bernhard Bauer wrote:
> I would use nullptr rather than 0.

Done.

https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/...
chrome/browser/android/interests_service.cc:72: env,
env->NewStringUTF(interests[i].name.c_str()),
On 2015/09/29 14:04:05, Bernhard Bauer wrote:
> Please use base::android::ConvertUTF8ToJavaString() rather than doing your own
> thing.

Done.

https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/...
chrome/browser/android/interests_service.cc:89:
InterestsService::ConvertInterestsToJava(interests);
On 2015/09/29 14:04:05, Bernhard Bauer wrote:
> You could pass the JNIEnv to this method. Also, you are already inside the
> InterestsService class, so you don't need the InterestsService:: prefix.

Not Done. This would require passing the JNIEnv through a callback.

https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/...
File chrome/browser/android/interests_service.h (right):

https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/...
chrome/browser/android/interests_service.h:18: void Destroy(JNIEnv* env, jobject
obj);
On 2015/09/29 14:04:05, Bernhard Bauer wrote:
> I would group methods that are called from Java together and add a comment
> before the group starts.

Done.

https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/...
chrome/browser/android/interests_service.h:28: virtual ~InterestsService();
On 2015/09/29 14:04:05, Bernhard Bauer wrote:
> Destructors should come before other methods.

Done.

https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/...
File chrome/browser/android/interests_service_unittest.cc (right):

https://codereview.chromium.org/1334233003/diff/80001/chrome/browser/android/...
chrome/browser/android/interests_service_unittest.cc:14:
std::vector<InterestsFetcher::Interest> GetEmptyResponse() {
On 2015/09/29 14:04:05, Bernhard Bauer wrote:
> Add an empty line before this one.

Done.

Powered by Google App Engine
This is Rietveld 408576698