| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/history/android/sqlite_cursor.h" | 5 #include "chrome/browser/history/android/sqlite_cursor.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 JNIEnv* env, | 53 JNIEnv* env, |
| 54 const std::vector<std::string>& column_names, | 54 const std::vector<std::string>& column_names, |
| 55 history::AndroidStatement* statement, | 55 history::AndroidStatement* statement, |
| 56 AndroidHistoryProviderService* service, | 56 AndroidHistoryProviderService* service, |
| 57 FaviconService* favicon_service) { | 57 FaviconService* favicon_service) { |
| 58 if (!HasClass(env, kSQLiteCursorClassPath)) { | 58 if (!HasClass(env, kSQLiteCursorClassPath)) { |
| 59 LOG(ERROR) << "Can not find " << kSQLiteCursorClassPath; | 59 LOG(ERROR) << "Can not find " << kSQLiteCursorClassPath; |
| 60 return ScopedJavaLocalRef<jobject>(); | 60 return ScopedJavaLocalRef<jobject>(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 ScopedJavaLocalRef<jclass> sclass = GetClass(env, kSQLiteCursorClassPath); | |
| 64 jmethodID method_id = MethodID::Get<MethodID::TYPE_INSTANCE>( | 63 jmethodID method_id = MethodID::Get<MethodID::TYPE_INSTANCE>( |
| 65 env, sclass.obj(), "<init>", "(I)V"); | 64 env, g_SQLiteCursor_clazz, "<init>", "(I)V"); |
| 66 | 65 |
| 67 SQLiteCursor* cursor = new SQLiteCursor(column_names, statement, service, | 66 SQLiteCursor* cursor = new SQLiteCursor(column_names, statement, service, |
| 68 favicon_service); | 67 favicon_service); |
| 69 ScopedJavaLocalRef<jobject> obj(env, | 68 ScopedJavaLocalRef<jobject> obj(env, |
| 70 env->NewObject(sclass.obj(), method_id, reinterpret_cast<jint>(cursor))); | 69 env->NewObject(g_SQLiteCursor_clazz, method_id, |
| 70 reinterpret_cast<jint>(cursor))); |
| 71 if (obj.is_null()) { | 71 if (obj.is_null()) { |
| 72 delete cursor; | 72 delete cursor; |
| 73 return ScopedJavaLocalRef<jobject>(); | 73 return ScopedJavaLocalRef<jobject>(); |
| 74 } | 74 } |
| 75 return obj; | 75 return obj; |
| 76 } | 76 } |
| 77 | 77 |
| 78 bool SQLiteCursor::RegisterSqliteCursor(JNIEnv* env) { | 78 bool SQLiteCursor::RegisterSqliteCursor(JNIEnv* env) { |
| 79 return RegisterNativesImpl(env); | 79 return RegisterNativesImpl(env); |
| 80 } | 80 } |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 } | 277 } |
| 278 | 278 |
| 279 void SQLiteCursor::RunMoveStatementOnUIThread(int pos) { | 279 void SQLiteCursor::RunMoveStatementOnUIThread(int pos) { |
| 280 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 280 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 281 if (!consumer_.get()) | 281 if (!consumer_.get()) |
| 282 consumer_.reset(new CancelableRequestConsumer()); | 282 consumer_.reset(new CancelableRequestConsumer()); |
| 283 service_->MoveStatement( | 283 service_->MoveStatement( |
| 284 statement_, position_, pos, consumer_.get(), | 284 statement_, position_, pos, consumer_.get(), |
| 285 base::Bind(&SQLiteCursor::OnMoved, base::Unretained(this))); | 285 base::Bind(&SQLiteCursor::OnMoved, base::Unretained(this))); |
| 286 } | 286 } |
| OLD | NEW |