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

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

Issue 12625005: remove call to get android MediaPlayer class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove useless . line Created 7 years, 9 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"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
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");
bulach 2013/03/13 15:06:10 while at it... :) this is not a system class, but
qinmin 2013/03/13 18:26:58 Good point, Done.
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 }
81 81
82 jint SQLiteCursor::GetCount(JNIEnv* env, jobject obj) { 82 jint SQLiteCursor::GetCount(JNIEnv* env, jobject obj) {
83 // Moves to maxium possible position so we will reach the last row, then finds 83 // Moves to maxium possible position so we will reach the last row, then finds
84 // out the total number of rows. 84 // out the total number of rows.
85 int current_position = position_; 85 int current_position = position_;
86 int count = MoveTo(env, obj, std::numeric_limits<int>::max() - 1) + 1; 86 int count = MoveTo(env, obj, std::numeric_limits<int>::max() - 1) + 1;
87 // Moves back to the previous position. 87 // Moves back to the previous position.
88 MoveTo(env, obj, current_position); 88 MoveTo(env, obj, current_position);
89 return count; 89 return count;
90 } 90 }
91 91
92 ScopedJavaLocalRef<jobjectArray> SQLiteCursor::GetColumnNames(JNIEnv* env, 92 ScopedJavaLocalRef<jobjectArray> SQLiteCursor::GetColumnNames(JNIEnv* env,
93 jobject obj) { 93 jobject obj) {
94 size_t count = column_names_.size(); 94 size_t count = column_names_.size();
95 ScopedJavaLocalRef<jclass> sclass = GetClass(env, "java/lang/String"); 95 ScopedJavaLocalRef<jclass> sclass = GetClass(env, "java/lang/String");
bulach 2013/03/13 15:06:10 94-103 could use base/android/jni_array.h and just
qinmin 2013/03/13 18:26:58 Good catch, done. On 2013/03/13 15:06:10, bulach w
96 ScopedJavaLocalRef<jobjectArray> arr(env, 96 ScopedJavaLocalRef<jobjectArray> arr(env,
97 env->NewObjectArray(count, sclass.obj(), NULL)); 97 env->NewObjectArray(count, sclass.obj(), NULL));
98 for (size_t i = 0; i < count; i++) { 98 for (size_t i = 0; i < count; i++) {
99 ScopedJavaLocalRef<jstring> str = 99 ScopedJavaLocalRef<jstring> str =
100 ConvertUTF8ToJavaString(env, column_names_[i].c_str()); 100 ConvertUTF8ToJavaString(env, column_names_[i].c_str());
101 env->SetObjectArrayElement(arr.obj(), i, str.obj()); 101 env->SetObjectArrayElement(arr.obj(), i, str.obj());
102 } 102 }
103 return arr; 103 return arr;
104 } 104 }
105 105
(...skipping 22 matching lines...) Expand all
128 jint column) { 128 jint column) {
129 std::vector<unsigned char> blob; 129 std::vector<unsigned char> blob;
130 130
131 // Assume the client will only get favicon using GetBlob. 131 // Assume the client will only get favicon using GetBlob.
132 if (statement_->favicon_index() == column) { 132 if (statement_->favicon_index() == column) {
133 if (!GetFavicon(statement_->statement()->ColumnInt(column), &blob)) 133 if (!GetFavicon(statement_->statement()->ColumnInt(column), &blob))
134 return ScopedJavaLocalRef<jbyteArray>(); 134 return ScopedJavaLocalRef<jbyteArray>();
135 } else { 135 } else {
136 statement_->statement()->ColumnBlobAsVector(column, &blob); 136 statement_->statement()->ColumnBlobAsVector(column, &blob);
137 } 137 }
138 ScopedJavaLocalRef<jbyteArray> jb(env, env->NewByteArray(blob.size())); 138 ScopedJavaLocalRef<jbyteArray> jb(env, env->NewByteArray(blob.size()));
bulach 2013/03/13 15:06:10 ditto, 138-140: return ToJavaByteArray(env, blob.
qinmin 2013/03/13 18:26:58 vector::data() is introduced in C++11, use &blob[0
139 int count = 0; 139 int count = 0;
140 for (std::vector<unsigned char>::const_iterator i = blob.begin(); 140 for (std::vector<unsigned char>::const_iterator i = blob.begin();
141 i != blob.end(); ++i) { 141 i != blob.end(); ++i) {
142 env->SetByteArrayRegion(jb.obj(), count++, 1, (jbyte *)i); 142 env->SetByteArrayRegion(jb.obj(), count++, 1, (jbyte *)i);
143 } 143 }
144 return jb; 144 return jb;
145 } 145 }
146 146
147 jboolean SQLiteCursor::IsNull(JNIEnv* env, jobject obj, jint column) { 147 jboolean SQLiteCursor::IsNull(JNIEnv* env, jobject obj, jint column) {
148 return NULL_TYPE == GetColumnTypeInternal(column) ? JNI_TRUE : JNI_FALSE; 148 return NULL_TYPE == GetColumnTypeInternal(column) ? JNI_TRUE : JNI_FALSE;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698