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

Unified Diff: chrome/browser/android/interests_service.h

Issue 1396443002: Add the JNI code in order to let Java use the InterestsFetcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/interests_service.h
diff --git a/chrome/browser/android/interests_service.h b/chrome/browser/android/interests_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..cf4dd138fcc8c2e85138a3546d76e82ac53d26c8
--- /dev/null
+++ b/chrome/browser/android/interests_service.h
@@ -0,0 +1,42 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_ANDROID_INTERESTS_SERVICE_H_
Bernhard Bauer 2015/10/07 15:26:37 Can we move this file to chrome/browser/interests/
+#define CHROME_BROWSER_ANDROID_INTERESTS_SERVICE_H_
+
+#include <jni.h>
+
+#include "base/android/scoped_java_ref.h"
+#include "chrome/browser/interests/interests_fetcher.h"
Bernhard Bauer 2015/10/07 15:26:37 You can forward-declare this and Profile. OTOH, y
PEConn 2015/10/07 18:27:20 Done. I forward declared Profile and ScopedJavaGlo
+#include "chrome/browser/profiles/profile.h"
+
+// Provides a list of user interests to Java
+class InterestsService {
+ public:
+ explicit InterestsService(Profile* profile);
+ virtual ~InterestsService();
+
+ void Destroy(JNIEnv* env, jobject obj);
+ static bool Register(JNIEnv* env);
+ void GetInterests(JNIEnv* env,
+ jobject obj,
+ jobject j_callback);
+
+ private:
+ void OnObtainedInterests(
+ InterestsFetcher* fetcher,
+ const base::android::ScopedJavaGlobalRef<jobject>& j_callback,
+ scoped_ptr<std::vector<InterestsFetcher::Interest>> interests);
+
+ static jobjectArray ConvertInterestsToJava(
+ scoped_ptr<std::vector<InterestsFetcher::Interest>> interests);
+
+ Profile* profile_;
+
+ base::WeakPtrFactory<InterestsService> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(InterestsService);
+};
+
+#endif // CHROME_BROWSER_ANDROID_INTERESTS_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698