summaryrefslogtreecommitdiffstats
path: root/content/browser/mojo/service_registry_android.h
blob: 17d2cb07bdc632333e81bea4d62afe1e7ac85131 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2014 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 CONTENT_BROWSER_MOJO_SERVICE_REGISTRY_ANDROID_H_
#define CONTENT_BROWSER_MOJO_SERVICE_REGISTRY_ANDROID_H_

#include <jni.h>

#include "base/android/scoped_java_ref.h"
#include "base/macros.h"
#include "content/common/content_export.h"

namespace content {

class ServiceRegistryImpl;

// Android wrapper over ServiceRegistryImpl, allowing the browser services in
// Java to register with ServiceRegistry.java (and abstracting away the JNI
// calls).
class CONTENT_EXPORT ServiceRegistryAndroid {
 public:
  static bool Register(JNIEnv* env);

  explicit ServiceRegistryAndroid(ServiceRegistryImpl* service_registry);
  virtual ~ServiceRegistryAndroid();

  // Methods called from Java.
  void AddService(
      JNIEnv* env,
      const base::android::JavaParamRef<jobject>& j_service_registry,
      const base::android::JavaParamRef<jobject>& j_manager,
      const base::android::JavaParamRef<jobject>& j_factory,
      const base::android::JavaParamRef<jstring>& j_name);
  void RemoveService(
      JNIEnv* env,
      const base::android::JavaParamRef<jobject>& j_service_registry,
      const base::android::JavaParamRef<jstring>& j_name);
  void ConnectToRemoteService(
      JNIEnv* env,
      const base::android::JavaParamRef<jobject>& j_service_registry,
      const base::android::JavaParamRef<jstring>& j_name,
      jint handle);

  const base::android::ScopedJavaGlobalRef<jobject>& GetObj() { return obj_; }

 private:
  ServiceRegistryImpl* service_registry_;
  base::android::ScopedJavaGlobalRef<jobject> obj_;

  DISALLOW_COPY_AND_ASSIGN(ServiceRegistryAndroid);
};

}  // namespace content

#endif  // CONTENT_BROWSER_MOJO_SERVICE_REGISTRY_ANDROID_H_