| 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" |
| 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 "ui/gfx/favicon_size.h" |
| 14 #include "sql/statement.h" | 15 #include "sql/statement.h" |
| 15 | 16 |
| 16 using base::android::ConvertUTF8ToJavaString; | 17 using base::android::ConvertUTF8ToJavaString; |
| 17 using base::android::GetClass; | 18 using base::android::GetClass; |
| 18 using base::android::HasClass; | 19 using base::android::HasClass; |
| 19 using base::android::HasMethod; | 20 using base::android::HasMethod; |
| 20 using base::android::GetMethodID; | 21 using base::android::GetMethodID; |
| 21 using base::android::ScopedJavaLocalRef; | 22 using base::android::ScopedJavaLocalRef; |
| 22 using content::BrowserThread; | 23 using content::BrowserThread; |
| 23 | 24 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 FROM_HERE, | 216 FROM_HERE, |
| 216 base::Bind(&SQLiteCursor::GetFaviconForIDInUIThread, | 217 base::Bind(&SQLiteCursor::GetFaviconForIDInUIThread, |
| 217 base::Unretained(this), id, &consumer_, | 218 base::Unretained(this), id, &consumer_, |
| 218 base::Bind(&SQLiteCursor::OnFaviconData, | 219 base::Bind(&SQLiteCursor::OnFaviconData, |
| 219 base::Unretained(this)))); | 220 base::Unretained(this)))); |
| 220 | 221 |
| 221 if (test_observer_) | 222 if (test_observer_) |
| 222 test_observer_->OnPostGetFaviconTask(); | 223 test_observer_->OnPostGetFaviconTask(); |
| 223 | 224 |
| 224 event_.Wait(); | 225 event_.Wait(); |
| 225 if (!favicon_.is_valid()) | 226 if (!favicon_bitmap_result_.is_valid()) |
| 226 return false; | 227 return false; |
| 227 | 228 |
| 228 image_data->assign(favicon_.image_data->front(), | 229 scoped_refptr<base::RefCountedMemory> bitmap_data = |
| 229 favicon_.image_data->front() + favicon_.image_data->size()); | 230 favicon_bitmap_result_.bitmap_data; |
| 231 image_data->assign(bitmap_data->front(), |
| 232 bitmap_data->front() + bitmap_data->size()); |
| 230 return true; | 233 return true; |
| 231 } | 234 } |
| 232 | 235 |
| 233 return false; | 236 return false; |
| 234 } | 237 } |
| 235 | 238 |
| 236 void SQLiteCursor::GetFaviconForIDInUIThread( | 239 void SQLiteCursor::GetFaviconForIDInUIThread( |
| 237 history::FaviconID id, | 240 history::FaviconID id, |
| 238 CancelableRequestConsumerBase* consumer, | 241 CancelableRequestConsumerBase* consumer, |
| 239 const FaviconService::FaviconDataCallback& callback) { | 242 const FaviconService::FaviconRawCallback& callback) { |
| 240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 241 favicon_service_->GetFaviconForID(id, consumer, callback); | 244 favicon_service_->GetRawFaviconForID(id, gfx::kFaviconSize, |
| 245 ui::SCALE_FACTOR_100P, consumer, callback); |
| 242 } | 246 } |
| 243 | 247 |
| 244 | 248 |
| 245 void SQLiteCursor::OnFaviconData(FaviconService::Handle handle, | 249 void SQLiteCursor::OnFaviconData( |
| 246 history::FaviconData favicon) { | 250 FaviconService::Handle handle, |
| 247 favicon_ = favicon; | 251 const history::FaviconBitmapResult& bitmap_result) { |
| 252 favicon_bitmap_result_ = bitmap_result; |
| 248 event_.Signal(); | 253 event_.Signal(); |
| 249 if (test_observer_) | 254 if (test_observer_) |
| 250 test_observer_->OnGetFaviconResult(); | 255 test_observer_->OnGetFaviconResult(); |
| 251 } | 256 } |
| 252 | 257 |
| 253 void SQLiteCursor::OnMoved(AndroidHistoryProviderService::Handle handle, | 258 void SQLiteCursor::OnMoved(AndroidHistoryProviderService::Handle handle, |
| 254 int pos) { | 259 int pos) { |
| 255 position_ = pos; | 260 position_ = pos; |
| 256 event_.Signal(); | 261 event_.Signal(); |
| 257 if (test_observer_) | 262 if (test_observer_) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 271 return SQLiteCursor::BLOB; | 276 return SQLiteCursor::BLOB; |
| 272 | 277 |
| 273 return ToJavaColumnType(statement_->statement()->ColumnType(column)); | 278 return ToJavaColumnType(statement_->statement()->ColumnType(column)); |
| 274 } | 279 } |
| 275 | 280 |
| 276 void SQLiteCursor::RunMoveStatementOnUIThread(int pos) { | 281 void SQLiteCursor::RunMoveStatementOnUIThread(int pos) { |
| 277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 278 service_->MoveStatement(statement_, position_, pos, &consumer_, | 283 service_->MoveStatement(statement_, position_, pos, &consumer_, |
| 279 base::Bind(&SQLiteCursor::OnMoved, base::Unretained(this))); | 284 base::Bind(&SQLiteCursor::OnMoved, base::Unretained(this))); |
| 280 } | 285 } |
| OLD | NEW |