OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/android/logo_bridge.h" | 5 #include "chrome/browser/android/logo_bridge.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
| 8 #include <stdint.h> |
8 | 9 |
9 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 11 #include "base/android/jni_array.h" |
11 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
12 #include "base/android/scoped_java_ref.h" | 13 #include "base/android/scoped_java_ref.h" |
13 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
14 #include "chrome/browser/android/logo_service.h" | 15 #include "chrome/browser/android/logo_service.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/profiles/profile_android.h" | 17 #include "chrome/browser/profiles/profile_android.h" |
17 #include "components/search_provider_logos/logo_tracker.h" | 18 #include "components/search_provider_logos/logo_tracker.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 152 } |
152 | 153 |
153 UMA_HISTOGRAM_TIMES( | 154 UMA_HISTOGRAM_TIMES( |
154 "NewTabPage.AnimatedLogoDownloadTime", | 155 "NewTabPage.AnimatedLogoDownloadTime", |
155 base::TimeTicks::Now() - animated_logo_download_start_time_); | 156 base::TimeTicks::Now() - animated_logo_download_start_time_); |
156 | 157 |
157 std::string response; | 158 std::string response; |
158 source->GetResponseAsString(&response); | 159 source->GetResponseAsString(&response); |
159 JNIEnv* env = base::android::AttachCurrentThread(); | 160 JNIEnv* env = base::android::AttachCurrentThread(); |
160 | 161 |
161 ScopedJavaLocalRef<jbyteArray> j_bytes = ToJavaByteArray( | 162 ScopedJavaLocalRef<jbyteArray> j_bytes = |
162 env, reinterpret_cast<const uint8*>(response.data()), response.length()); | 163 ToJavaByteArray(env, reinterpret_cast<const uint8_t*>(response.data()), |
| 164 response.length()); |
163 ScopedJavaLocalRef<jobject> j_gif_image = | 165 ScopedJavaLocalRef<jobject> j_gif_image = |
164 Java_LogoBridge_createGifImage(env, j_bytes.obj()); | 166 Java_LogoBridge_createGifImage(env, j_bytes.obj()); |
165 Java_AnimatedLogoCallback_onAnimatedLogoAvailable(env, j_callback_.obj(), | 167 Java_AnimatedLogoCallback_onAnimatedLogoAvailable(env, j_callback_.obj(), |
166 j_gif_image.obj()); | 168 j_gif_image.obj()); |
167 ClearFetcher(); | 169 ClearFetcher(); |
168 } | 170 } |
169 | 171 |
170 void LogoBridge::ClearFetcher() { | 172 void LogoBridge::ClearFetcher() { |
171 fetcher_.reset(); | 173 fetcher_.reset(); |
172 j_callback_.Reset(); | 174 j_callback_.Reset(); |
173 } | 175 } |
174 | 176 |
175 // static | 177 // static |
176 bool RegisterLogoBridge(JNIEnv* env) { | 178 bool RegisterLogoBridge(JNIEnv* env) { |
177 return RegisterNativesImpl(env); | 179 return RegisterNativesImpl(env); |
178 } | 180 } |
OLD | NEW |