Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/android/webapps/webapp_registry.h" | |
| 6 | |
| 7 #include <jni.h> | |
| 8 | |
| 9 #include "base/android/jni_android.h" | |
| 10 #include "base/callback.h" | |
| 11 #include "chrome/browser/io_thread.h" | |
| 12 #include "content/public/browser/browser_thread.h" | |
| 13 #include "jni/WebappRegistry_jni.h" | |
| 14 | |
| 15 // static | |
| 16 void WebappRegistry::UnregisterWebapps( | |
| 17 const base::Closure& callback) { | |
| 18 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 19 uintptr_t callback_pointer = reinterpret_cast<uintptr_t>( | |
| 20 new base::Closure(callback)); | |
| 21 | |
| 22 Java_WebappRegistry_unregisterAllWebapps( | |
| 23 env, | |
| 24 base::android::GetApplicationContext(), | |
| 25 callback_pointer); | |
| 26 } | |
| 27 | |
| 28 // Callback used by Java when all webapps have been unregistered. | |
| 29 // Declared in JNI header file. | |
|
gone
2015/09/09 23:30:40
nit: remove unhelpful "Declared in JNI header" com
Lalit Maganti
2015/09/10 09:41:58
Done.
| |
| 30 void OnWebappsUnregistered(JNIEnv* env, | |
| 31 const JavaParamRef<jclass>& klass, | |
| 32 jlong jcallback) { | |
| 33 base::Closure* callback = reinterpret_cast<base::Closure*>(jcallback); | |
|
gone
2015/09/09 23:30:40
again, my familiarity with native code is lacking,
Lalit Maganti
2015/09/10 09:41:57
AFAIK: no the pointer cannot be invalid until dele
| |
| 34 callback->Run(); | |
| 35 delete callback; | |
| 36 } | |
| 37 | |
| 38 // static | |
| 39 bool WebappRegistry::RegisterWebappRegistry(JNIEnv* env) { | |
| 40 return RegisterNativesImpl(env); | |
| 41 } | |
| OLD | NEW |