| 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 "blimp/client/app/android/blimp_client_session_android.h" | 5 #include "blimp/client/app/android/blimp_client_session_android.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 GetOSVersionInfoForUserAgent()); | 86 GetOSVersionInfoForUserAgent()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void BlimpClientSessionAndroid::OnDisconnected(int result) { | 89 void BlimpClientSessionAndroid::OnDisconnected(int result) { |
| 90 JNIEnv* env = base::android::AttachCurrentThread(); | 90 JNIEnv* env = base::android::AttachCurrentThread(); |
| 91 Java_BlimpClientSession_onDisconnected( | 91 Java_BlimpClientSession_onDisconnected( |
| 92 env, java_obj_.obj(), base::android::ConvertUTF8ToJavaString( | 92 env, java_obj_.obj(), base::android::ConvertUTF8ToJavaString( |
| 93 env, net::ErrorToShortString(result)).obj()); | 93 env, net::ErrorToShortString(result)).obj()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void BlimpClientSessionAndroid::OnPacketReceived(int bytes) { |
| 97 JNIEnv* env = base::android::AttachCurrentThread(); |
| 98 Java_BlimpClientSession_onPacketReceived(env, java_obj_.obj(), bytes); |
| 99 } |
| 100 |
| 101 void BlimpClientSessionAndroid::OnPacketSent(int bytes) { |
| 102 JNIEnv* env = base::android::AttachCurrentThread(); |
| 103 Java_BlimpClientSession_onPacketSent(env, java_obj_.obj(), bytes); |
| 104 } |
| 105 |
| 96 void BlimpClientSessionAndroid::Destroy(JNIEnv* env, | 106 void BlimpClientSessionAndroid::Destroy(JNIEnv* env, |
| 97 const JavaParamRef<jobject>& jobj) { | 107 const JavaParamRef<jobject>& jobj) { |
| 98 delete this; | 108 delete this; |
| 99 } | 109 } |
| 100 | 110 |
| 101 void BlimpClientSessionAndroid::OnAssignmentConnectionAttempted( | 111 void BlimpClientSessionAndroid::OnAssignmentConnectionAttempted( |
| 102 AssignmentSource::Result result, | 112 AssignmentSource::Result result, |
| 103 const Assignment& assignment) { | 113 const Assignment& assignment) { |
| 104 // Notify the front end of the assignment result. | 114 // Notify the front end of the assignment result. |
| 105 std::string engine_ip = IPAddressToStringWithPort( | 115 std::string engine_ip = IPAddressToStringWithPort( |
| 106 assignment.engine_endpoint.address(), assignment.engine_endpoint.port()); | 116 assignment.engine_endpoint.address(), assignment.engine_endpoint.port()); |
| 107 JNIEnv* env = base::android::AttachCurrentThread(); | 117 JNIEnv* env = base::android::AttachCurrentThread(); |
| 108 Java_BlimpClientSession_onAssignmentReceived( | 118 Java_BlimpClientSession_onAssignmentReceived( |
| 109 env, java_obj_.obj(), static_cast<jint>(result), | 119 env, java_obj_.obj(), static_cast<jint>(result), |
| 110 base::android::ConvertUTF8ToJavaString(env, engine_ip).obj(), | 120 base::android::ConvertUTF8ToJavaString(env, engine_ip).obj(), |
| 111 base::android::ConvertUTF8ToJavaString(env, blimp::kEngineVersion).obj()); | 121 base::android::ConvertUTF8ToJavaString(env, blimp::kEngineVersion).obj()); |
| 112 | 122 |
| 113 BlimpClientSession::OnAssignmentConnectionAttempted(result, assignment); | 123 BlimpClientSession::OnAssignmentConnectionAttempted(result, assignment); |
| 114 } | 124 } |
| 115 | 125 |
| 116 } // namespace client | 126 } // namespace client |
| 117 } // namespace blimp | 127 } // namespace blimp |
| OLD | NEW |