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

Side by Side Diff: chrome/browser/history/android/sqlite_cursor.cc

Issue 10996063: Android: adds Get(Static)MethodIDOrNULL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
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"
11 #include "chrome/browser/history/android/android_history_types.h" 11 #include "chrome/browser/history/android/android_history_types.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "jni/SQLiteCursor_jni.h" 13 #include "jni/SQLiteCursor_jni.h"
14 #include "sql/statement.h" 14 #include "sql/statement.h"
15 15
16 using base::android::ConvertUTF8ToJavaString; 16 using base::android::ConvertUTF8ToJavaString;
17 using base::android::GetClass; 17 using base::android::GetClass;
18 using base::android::HasClass; 18 using base::android::HasClass;
19 using base::android::HasMethod; 19 using base::android::GetMethodIDOrNULL;
Sami 2012/10/01 15:46:00 Looks like NULL is still upper case here.
bulach 2012/10/01 17:25:00 Done.
20 using base::android::GetMethodID;
21 using base::android::ScopedJavaLocalRef; 20 using base::android::ScopedJavaLocalRef;
22 using content::BrowserThread; 21 using content::BrowserThread;
23 22
24 namespace { 23 namespace {
25 24
26 SQLiteCursor::JavaColumnType ToJavaColumnType(sql::ColType type) { 25 SQLiteCursor::JavaColumnType ToJavaColumnType(sql::ColType type) {
27 switch (type) { 26 switch (type) {
28 case sql::COLUMN_TYPE_INTEGER: 27 case sql::COLUMN_TYPE_INTEGER:
29 return SQLiteCursor::NUMERIC; 28 return SQLiteCursor::NUMERIC;
30 case sql::COLUMN_TYPE_FLOAT: 29 case sql::COLUMN_TYPE_FLOAT:
(...skipping 24 matching lines...) Expand all
55 const std::vector<std::string>& column_names, 54 const std::vector<std::string>& column_names,
56 history::AndroidStatement* statement, 55 history::AndroidStatement* statement,
57 AndroidHistoryProviderService* service, 56 AndroidHistoryProviderService* service,
58 FaviconService* favicon_service) { 57 FaviconService* favicon_service) {
59 if (!HasClass(env, kSQLiteCursorClassPath)) { 58 if (!HasClass(env, kSQLiteCursorClassPath)) {
60 LOG(ERROR) << "Can not find " << kSQLiteCursorClassPath; 59 LOG(ERROR) << "Can not find " << kSQLiteCursorClassPath;
61 return ScopedJavaLocalRef<jobject>(); 60 return ScopedJavaLocalRef<jobject>();
62 } 61 }
63 62
64 ScopedJavaLocalRef<jclass> sclass = GetClass(env, kSQLiteCursorClassPath); 63 ScopedJavaLocalRef<jclass> sclass = GetClass(env, kSQLiteCursorClassPath);
65 if (!HasMethod(env, sclass, "<init>", "(I)V")) { 64
65 jmethodID method_id = GetMethodIDOrNULL(env, sclass, "<init>", "(I)V");
66 if (!method_id) {
joth 2012/10/01 16:15:27 can we comment why it's OK for this not to exist (
bulach 2012/10/01 17:25:00 ugh, good point.. I think it's one of those "just
66 LOG(ERROR) << "Can not find " << kSQLiteCursorClassPath << " Constructor"; 67 LOG(ERROR) << "Can not find " << kSQLiteCursorClassPath << " Constructor";
67 return ScopedJavaLocalRef<jobject>(); 68 return ScopedJavaLocalRef<jobject>();
68 } 69 }
69 70
70 jmethodID method_id = GetMethodID(env, sclass, "<init>", "(I)V");
71 SQLiteCursor* cursor = new SQLiteCursor(column_names, statement, service, 71 SQLiteCursor* cursor = new SQLiteCursor(column_names, statement, service,
72 favicon_service); 72 favicon_service);
73 ScopedJavaLocalRef<jobject> obj(env, 73 ScopedJavaLocalRef<jobject> obj(env,
74 env->NewObject(sclass.obj(), method_id, reinterpret_cast<jint>(cursor))); 74 env->NewObject(sclass.obj(), method_id, reinterpret_cast<jint>(cursor)));
75 if (obj.is_null()) { 75 if (obj.is_null()) {
76 delete cursor; 76 delete cursor;
77 return ScopedJavaLocalRef<jobject>(); 77 return ScopedJavaLocalRef<jobject>();
78 } 78 }
79 return obj; 79 return obj;
80 } 80 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return SQLiteCursor::BLOB; 274 return SQLiteCursor::BLOB;
275 275
276 return ToJavaColumnType(statement_->statement()->ColumnType(column)); 276 return ToJavaColumnType(statement_->statement()->ColumnType(column));
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 service_->MoveStatement(statement_, position_, pos, &consumer_, 281 service_->MoveStatement(statement_, position_, pos, &consumer_,
282 base::Bind(&SQLiteCursor::OnMoved, base::Unretained(this))); 282 base::Bind(&SQLiteCursor::OnMoved, base::Unretained(this)));
283 } 283 }
OLDNEW
« base/android/jni_android.cc ('K') | « base/android/jni_generator/jni_generator_tests.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698