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

Side by Side Diff: blimp/client/app/android/blimp_client_session_android.cc

Issue 2211613002: Add AssignmentSource to BlimpClientContextImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge origin/master Created 4 years, 4 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 unified diff | Download patch
OLDNEW
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 env, java_obj_.obj(), base::android::ConvertUTF8ToJavaString( 95 env, java_obj_.obj(), base::android::ConvertUTF8ToJavaString(
96 env, net::ErrorToShortString(result)).obj()); 96 env, net::ErrorToShortString(result)).obj());
97 } 97 }
98 98
99 void BlimpClientSessionAndroid::Destroy(JNIEnv* env, 99 void BlimpClientSessionAndroid::Destroy(JNIEnv* env,
100 const JavaParamRef<jobject>& jobj) { 100 const JavaParamRef<jobject>& jobj) {
101 delete this; 101 delete this;
102 } 102 }
103 103
104 void BlimpClientSessionAndroid::OnAssignmentConnectionAttempted( 104 void BlimpClientSessionAndroid::OnAssignmentConnectionAttempted(
105 AssignmentSource::Result result, 105 AssignmentRequestResult result,
106 const Assignment& assignment) { 106 const Assignment& assignment) {
107 // Notify the front end of the assignment result. 107 // Notify the front end of the assignment result.
108 std::string engine_ip = IPAddressToStringWithPort( 108 std::string engine_ip = IPAddressToStringWithPort(
109 assignment.engine_endpoint.address(), assignment.engine_endpoint.port()); 109 assignment.engine_endpoint.address(), assignment.engine_endpoint.port());
110 JNIEnv* env = base::android::AttachCurrentThread(); 110 JNIEnv* env = base::android::AttachCurrentThread();
111 Java_BlimpClientSession_onAssignmentReceived( 111 Java_BlimpClientSession_onAssignmentReceived(
112 env, java_obj_.obj(), static_cast<jint>(result), 112 env, java_obj_.obj(), static_cast<jint>(result),
113 base::android::ConvertUTF8ToJavaString(env, engine_ip).obj(), 113 base::android::ConvertUTF8ToJavaString(env, engine_ip).obj(),
114 base::android::ConvertUTF8ToJavaString(env, 114 base::android::ConvertUTF8ToJavaString(env,
115 version_info::GetVersionNumber()) 115 version_info::GetVersionNumber())
116 .obj()); 116 .obj());
117 117
118 BlimpClientSession::OnAssignmentConnectionAttempted(result, assignment); 118 BlimpClientSession::OnAssignmentConnectionAttempted(result, assignment);
119 } 119 }
120 120
121 base::android::ScopedJavaLocalRef<jintArray> 121 base::android::ScopedJavaLocalRef<jintArray>
122 BlimpClientSessionAndroid::GetDebugInfo( 122 BlimpClientSessionAndroid::GetDebugInfo(
123 JNIEnv* env, 123 JNIEnv* env,
124 const base::android::JavaParamRef<jobject>& jobj) { 124 const base::android::JavaParamRef<jobject>& jobj) {
125 BlimpConnectionStatistics* stats = 125 BlimpConnectionStatistics* stats =
126 BlimpClientSession::GetBlimpConnectionStatistics(); 126 BlimpClientSession::GetBlimpConnectionStatistics();
127 int metrics[] = {stats->Get(BlimpConnectionStatistics::BYTES_RECEIVED), 127 int metrics[] = {stats->Get(BlimpConnectionStatistics::BYTES_RECEIVED),
128 stats->Get(BlimpConnectionStatistics::BYTES_SENT), 128 stats->Get(BlimpConnectionStatistics::BYTES_SENT),
129 stats->Get(BlimpConnectionStatistics::COMMIT)}; 129 stats->Get(BlimpConnectionStatistics::COMMIT)};
130 return base::android::ToJavaIntArray(env, metrics, arraysize(metrics)); 130 return base::android::ToJavaIntArray(env, metrics, arraysize(metrics));
131 } 131 }
132 132
133 } // namespace client 133 } // namespace client
134 } // namespace blimp 134 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698