Chromium Code Reviews| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 test_observer_(NULL) { | 149 test_observer_(NULL) { |
| 150 } | 150 } |
| 151 | 151 |
| 152 SQLiteCursor::~SQLiteCursor() { | 152 SQLiteCursor::~SQLiteCursor() { |
| 153 // Consumer requests were set in the UI thread. They must be cancelled | 153 // Consumer requests were set in the UI thread. They must be cancelled |
| 154 // using the same thread. | 154 // using the same thread. |
| 155 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 155 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 156 CancelAllRequests(NULL); | 156 CancelAllRequests(NULL); |
| 157 } else { | 157 } else { |
| 158 base::WaitableEvent event(false, false); | 158 base::WaitableEvent event(false, false); |
| 159 BrowserThread::PostTask( | 159 if (BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
|
sky
2013/05/30 19:33:05
From PostTask: " even if the task is posted, there
michaelbai
2013/05/31 05:17:02
In the case of UI message loop goes away, the whol
| |
| 160 BrowserThread::UI, | |
| 161 FROM_HERE, | |
| 162 base::Bind(&SQLiteCursor::CancelAllRequests, base::Unretained(this), | 160 base::Bind(&SQLiteCursor::CancelAllRequests, base::Unretained(this), |
| 163 &event)); | 161 &event))) { |
| 164 event.Wait(); | 162 event.Wait(); |
| 163 } | |
| 165 } | 164 } |
| 166 | 165 |
| 167 BrowserThread::PostTask( | 166 BrowserThread::PostTask( |
| 168 BrowserThread::UI, | 167 BrowserThread::UI, |
| 169 FROM_HERE, | 168 FROM_HERE, |
| 170 base::Bind(&AndroidHistoryProviderService::CloseStatement, | 169 base::Bind(&AndroidHistoryProviderService::CloseStatement, |
| 171 base::Unretained(service_), statement_)); | 170 base::Unretained(service_), statement_)); |
| 172 } | 171 } |
| 173 | 172 |
| 174 bool SQLiteCursor::GetFavicon(chrome::FaviconID id, | 173 bool SQLiteCursor::GetFavicon(chrome::FaviconID id, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 } | 244 } |
| 246 | 245 |
| 247 void SQLiteCursor::RunMoveStatementOnUIThread(int pos) { | 246 void SQLiteCursor::RunMoveStatementOnUIThread(int pos) { |
| 248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 249 if (!consumer_.get()) | 248 if (!consumer_.get()) |
| 250 consumer_.reset(new CancelableRequestConsumer()); | 249 consumer_.reset(new CancelableRequestConsumer()); |
| 251 service_->MoveStatement( | 250 service_->MoveStatement( |
| 252 statement_, position_, pos, consumer_.get(), | 251 statement_, position_, pos, consumer_.get(), |
| 253 base::Bind(&SQLiteCursor::OnMoved, base::Unretained(this))); | 252 base::Bind(&SQLiteCursor::OnMoved, base::Unretained(this))); |
| 254 } | 253 } |
| OLD | NEW |