• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "sync/test/fake_server/android/fake_server_helper_android.h"
6 
7 #include <jni.h>
8 
9 #include "base/basictypes.h"
10 #include "jni/FakeServerHelper_jni.h"
11 #include "sync/internal_api/public/network_resources.h"
12 #include "sync/test/fake_server/fake_server.h"
13 #include "sync/test/fake_server/fake_server_network_resources.h"
14 
FakeServerHelperAndroid(JNIEnv * env,jobject obj)15 FakeServerHelperAndroid::FakeServerHelperAndroid(JNIEnv* env, jobject obj) {
16 }
17 
~FakeServerHelperAndroid()18 FakeServerHelperAndroid::~FakeServerHelperAndroid() { }
19 
Init(JNIEnv * env,jobject obj)20 static jlong Init(JNIEnv* env, jobject obj) {
21   FakeServerHelperAndroid* fake_server_android =
22       new FakeServerHelperAndroid(env, obj);
23   return reinterpret_cast<intptr_t>(fake_server_android);
24 }
25 
CreateFakeServer(JNIEnv * env,jobject obj)26 jlong FakeServerHelperAndroid::CreateFakeServer(JNIEnv* env, jobject obj) {
27   fake_server::FakeServer* fake_server = new fake_server::FakeServer();
28   return reinterpret_cast<intptr_t>(fake_server);
29 }
30 
CreateNetworkResources(JNIEnv * env,jobject obj,jlong fake_server)31 jlong FakeServerHelperAndroid::CreateNetworkResources(JNIEnv* env,
32                                                       jobject obj,
33                                                       jlong fake_server) {
34   fake_server::FakeServer* fake_server_ptr =
35       reinterpret_cast<fake_server::FakeServer*>(fake_server);
36   syncer::NetworkResources* resources =
37       new fake_server::FakeServerNetworkResources(fake_server_ptr);
38   return reinterpret_cast<intptr_t>(resources);
39 }
40 
DeleteFakeServer(JNIEnv * env,jobject obj,jlong fake_server)41 void FakeServerHelperAndroid::DeleteFakeServer(JNIEnv* env,
42                                                jobject obj,
43                                                jlong fake_server) {
44   fake_server::FakeServer* fake_server_ptr =
45       reinterpret_cast<fake_server::FakeServer*>(fake_server);
46   delete fake_server_ptr;
47 }
48 
49 // static
Register(JNIEnv * env)50 bool FakeServerHelperAndroid::Register(JNIEnv* env) {
51   return RegisterNativesImpl(env);
52 }
53