| 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" |
| 11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 12 #include "blimp/client/app/user_agent.h" | 12 #include "blimp/client/app/user_agent.h" |
| 13 #include "blimp/client/feature/settings_feature.h" | 13 #include "blimp/client/feature/settings_feature.h" |
| 14 #include "blimp/client/feature/tab_control_feature.h" | 14 #include "blimp/client/feature/tab_control_feature.h" |
| 15 #include "blimp/client/session/assignment_source.h" | 15 #include "blimp/client/session/assignment_source.h" |
| 16 #include "blimp/common/protocol_version.h" |
| 16 #include "jni/BlimpClientSession_jni.h" | 17 #include "jni/BlimpClientSession_jni.h" |
| 17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 18 | 19 |
| 19 namespace blimp { | 20 namespace blimp { |
| 20 namespace client { | 21 namespace client { |
| 21 namespace { | 22 namespace { |
| 22 const int kDummyTabId = 0; | 23 const int kDummyTabId = 0; |
| 23 | 24 |
| 24 GURL CreateAssignerGURL(const std::string& assigner_url) { | 25 GURL CreateAssignerGURL(const std::string& assigner_url) { |
| 25 GURL parsed_url(assigner_url); | 26 GURL parsed_url(assigner_url); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 env, java_obj_.obj(), base::android::ConvertUTF8ToJavaString( | 92 env, java_obj_.obj(), base::android::ConvertUTF8ToJavaString( |
| 92 env, net::ErrorToShortString(result)).obj()); | 93 env, net::ErrorToShortString(result)).obj()); |
| 93 } | 94 } |
| 94 | 95 |
| 95 void BlimpClientSessionAndroid::Destroy(JNIEnv* env, | 96 void BlimpClientSessionAndroid::Destroy(JNIEnv* env, |
| 96 const JavaParamRef<jobject>& jobj) { | 97 const JavaParamRef<jobject>& jobj) { |
| 97 delete this; | 98 delete this; |
| 98 } | 99 } |
| 99 | 100 |
| 100 void BlimpClientSessionAndroid::OnAssignmentConnectionAttempted( | 101 void BlimpClientSessionAndroid::OnAssignmentConnectionAttempted( |
| 101 AssignmentSource::Result result) { | 102 AssignmentSource::Result result, |
| 103 const Assignment& assignment) { |
| 102 // Notify the front end of the assignment result. | 104 // Notify the front end of the assignment result. |
| 105 std::string engine_ip = IPAddressToStringWithPort( |
| 106 assignment.engine_endpoint.address(), assignment.engine_endpoint.port()); |
| 103 JNIEnv* env = base::android::AttachCurrentThread(); | 107 JNIEnv* env = base::android::AttachCurrentThread(); |
| 104 Java_BlimpClientSession_onAssignmentReceived(env, java_obj_.obj(), | 108 Java_BlimpClientSession_onAssignmentReceived( |
| 105 static_cast<jint>(result)); | 109 env, java_obj_.obj(), static_cast<jint>(result), |
| 110 base::android::ConvertUTF8ToJavaString(env, engine_ip).obj(), |
| 111 base::android::ConvertUTF8ToJavaString(env, blimp::kEngineVersion).obj()); |
| 106 | 112 |
| 107 BlimpClientSession::OnAssignmentConnectionAttempted(result); | 113 BlimpClientSession::OnAssignmentConnectionAttempted(result, assignment); |
| 108 } | 114 } |
| 109 | 115 |
| 110 } // namespace client | 116 } // namespace client |
| 111 } // namespace blimp | 117 } // namespace blimp |
| OLD | NEW |