Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/webapk/webapk_update_manager.h" | 5 #include "chrome/browser/android/webapk/webapk_update_manager.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 | 22 |
| 23 using base::android::JavaParamRef; | 23 using base::android::JavaParamRef; |
| 24 | 24 |
| 25 // static | 25 // static |
| 26 bool WebApkUpdateManager::Register(JNIEnv* env) { | 26 bool WebApkUpdateManager::Register(JNIEnv* env) { |
| 27 return RegisterNativesImpl(env); | 27 return RegisterNativesImpl(env); |
| 28 } | 28 } |
| 29 | 29 |
| 30 // static | 30 // static |
| 31 void WebApkUpdateManager::OnBuiltWebApk(const std::string& id, | 31 void WebApkUpdateManager::OnBuiltWebApk(const std::string& id, |
| 32 bool success, | 32 WebApkInstallResult result, |
| 33 const std::string& webapk_package) { | 33 const std::string& webapk_package) { |
| 34 JNIEnv* env = base::android::AttachCurrentThread(); | 34 JNIEnv* env = base::android::AttachCurrentThread(); |
| 35 | 35 |
| 36 bool success = (result == WebApkInstallResult::INSTALLED); | |
|
dominickn
2017/03/05 23:52:40
Can we get rid of the logging here now?
That make
pkotwicz
2017/03/12 21:11:48
Done.
| |
| 36 if (success) { | 37 if (success) { |
| 37 DVLOG(1) | 38 DVLOG(1) |
| 38 << "Sent request to update WebAPK to server. Seems to have worked."; | 39 << "Sent request to update WebAPK to server. Seems to have worked."; |
| 39 } else { | 40 } else { |
| 40 LOG(WARNING) << "Server request to update WebAPK failed."; | 41 LOG(WARNING) << "Server request to update WebAPK failed."; |
| 41 } | 42 } |
| 42 | 43 |
| 43 base::android::ScopedJavaLocalRef<jstring> java_id = | 44 base::android::ScopedJavaLocalRef<jstring> java_id = |
| 44 base::android::ConvertUTF8ToJavaString(env, id); | 45 base::android::ConvertUTF8ToJavaString(env, id); |
| 45 Java_WebApkUpdateManager_onBuiltWebApk(env, java_id.obj(), success); | 46 Java_WebApkUpdateManager_onBuiltWebApk(env, java_id.obj(), success); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 SkBitmap best_primary_icon_bitmap = | 109 SkBitmap best_primary_icon_bitmap = |
| 109 gfx::CreateSkBitmapFromJavaBitmap(java_bitmap_lock); | 110 gfx::CreateSkBitmapFromJavaBitmap(java_bitmap_lock); |
| 110 best_primary_icon_bitmap.setImmutable(); | 111 best_primary_icon_bitmap.setImmutable(); |
| 111 | 112 |
| 112 std::string webapk_package; | 113 std::string webapk_package; |
| 113 ConvertJavaStringToUTF8(env, java_webapk_package, &webapk_package); | 114 ConvertJavaStringToUTF8(env, java_webapk_package, &webapk_package); |
| 114 | 115 |
| 115 WebApkInstallService* install_service = WebApkInstallService::Get(profile); | 116 WebApkInstallService* install_service = WebApkInstallService::Get(profile); |
| 116 if (install_service->IsInstallInProgress(info.manifest_url)) { | 117 if (install_service->IsInstallInProgress(info.manifest_url)) { |
| 117 base::ThreadTaskRunnerHandle::Get()->PostTask( | 118 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 118 FROM_HERE, | 119 FROM_HERE, base::Bind(&WebApkUpdateManager::OnBuiltWebApk, id, |
| 119 base::Bind(&WebApkUpdateManager::OnBuiltWebApk, id, false, "")); | 120 WebApkInstallResult::INSTALL_FAILED, "")); |
|
dominickn
2017/03/05 23:52:40
Is it worth having a separate result case here to
pkotwicz
2017/03/12 21:11:48
I don't think so. An update being already in progr
| |
| 120 return; | 121 return; |
| 121 } | 122 } |
| 122 install_service->UpdateAsync( | 123 install_service->UpdateAsync( |
| 123 info, best_primary_icon_bitmap, webapk_package, java_webapk_version, | 124 info, best_primary_icon_bitmap, webapk_package, java_webapk_version, |
| 124 icon_url_to_murmur2_hash, java_is_manifest_stale, | 125 icon_url_to_murmur2_hash, java_is_manifest_stale, |
| 125 base::Bind(&WebApkUpdateManager::OnBuiltWebApk, id)); | 126 base::Bind(&WebApkUpdateManager::OnBuiltWebApk, id)); |
| 126 } | 127 } |
| OLD | NEW |