| 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_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 test_observer_(NULL) { | 160 test_observer_(NULL) { |
| 161 } | 161 } |
| 162 | 162 |
| 163 SQLiteCursor::~SQLiteCursor() { | 163 SQLiteCursor::~SQLiteCursor() { |
| 164 } | 164 } |
| 165 | 165 |
| 166 void SQLiteCursor::DestroyOnUIThread() { | 166 void SQLiteCursor::DestroyOnUIThread() { |
| 167 // Consumer requests were set in the UI thread. They must be cancelled | 167 // Consumer requests were set in the UI thread. They must be cancelled |
| 168 // using the same thread. | 168 // using the same thread. |
| 169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 170 consumer_.reset(); | |
| 171 tracker_.reset(); | 170 tracker_.reset(); |
| 172 service_->CloseStatement(statement_); | 171 service_->CloseStatement(statement_); |
| 173 delete this; | 172 delete this; |
| 174 } | 173 } |
| 175 | 174 |
| 176 bool SQLiteCursor::GetFavicon(favicon_base::FaviconID id, | 175 bool SQLiteCursor::GetFavicon(favicon_base::FaviconID id, |
| 177 std::vector<unsigned char>* image_data) { | 176 std::vector<unsigned char>* image_data) { |
| 178 if (id) { | 177 if (id) { |
| 179 BrowserThread::PostTask( | 178 BrowserThread::PostTask( |
| 180 BrowserThread::UI, | 179 BrowserThread::UI, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 211 } | 210 } |
| 212 | 211 |
| 213 void SQLiteCursor::OnFaviconData( | 212 void SQLiteCursor::OnFaviconData( |
| 214 const favicon_base::FaviconRawBitmapResult& bitmap_result) { | 213 const favicon_base::FaviconRawBitmapResult& bitmap_result) { |
| 215 favicon_bitmap_result_ = bitmap_result; | 214 favicon_bitmap_result_ = bitmap_result; |
| 216 event_.Signal(); | 215 event_.Signal(); |
| 217 if (test_observer_) | 216 if (test_observer_) |
| 218 test_observer_->OnGetFaviconResult(); | 217 test_observer_->OnGetFaviconResult(); |
| 219 } | 218 } |
| 220 | 219 |
| 221 void SQLiteCursor::OnMoved(AndroidHistoryProviderService::Handle handle, | 220 void SQLiteCursor::OnMoved(int pos) { |
| 222 int pos) { | |
| 223 position_ = pos; | 221 position_ = pos; |
| 224 event_.Signal(); | 222 event_.Signal(); |
| 225 if (test_observer_) | 223 if (test_observer_) |
| 226 // Notified test_observer on UI thread instead of the one it will wait. | 224 // Notified test_observer on UI thread instead of the one it will wait. |
| 227 test_observer_->OnGetMoveToResult(); | 225 test_observer_->OnGetMoveToResult(); |
| 228 } | 226 } |
| 229 | 227 |
| 230 SQLiteCursor::JavaColumnType SQLiteCursor::GetColumnTypeInternal(int column) { | 228 SQLiteCursor::JavaColumnType SQLiteCursor::GetColumnTypeInternal(int column) { |
| 231 if (column == statement_->favicon_index()) | 229 if (column == statement_->favicon_index()) |
| 232 return SQLiteCursor::BLOB; | 230 return SQLiteCursor::BLOB; |
| 233 | 231 |
| 234 return ToJavaColumnType(statement_->statement()->ColumnType(column)); | 232 return ToJavaColumnType(statement_->statement()->ColumnType(column)); |
| 235 } | 233 } |
| 236 | 234 |
| 237 void SQLiteCursor::RunMoveStatementOnUIThread(int pos) { | 235 void SQLiteCursor::RunMoveStatementOnUIThread(int pos) { |
| 238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 239 if (!consumer_.get()) | 237 if (!tracker_.get()) |
| 240 consumer_.reset(new CancelableRequestConsumer()); | 238 tracker_.reset(new base::CancelableTaskTracker()); |
| 241 service_->MoveStatement( | 239 service_->MoveStatement( |
| 242 statement_, position_, pos, consumer_.get(), | 240 statement_, |
| 243 base::Bind(&SQLiteCursor::OnMoved, base::Unretained(this))); | 241 position_, |
| 242 pos, |
| 243 base::Bind(&SQLiteCursor::OnMoved, base::Unretained(this)), |
| 244 tracker_.get()); |
| 244 } | 245 } |
| OLD | NEW |