| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "android_webview/browser/aw_form_database_service.h" | 5 #include "android_webview/browser/aw_form_database_service.h" |
| 6 | 6 |
| 7 #include "base/android/locale_utils.h" | 7 #include "base/android/locale_utils.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "components/autofill/core/browser/webdata/autofill_table.h" | 10 #include "components/autofill/core/browser/webdata/autofill_table.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), | 42 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), |
| 43 base::Bind(&DatabaseErrorCallback)); | 43 base::Bind(&DatabaseErrorCallback)); |
| 44 autofill_data_->Init(); | 44 autofill_data_->Init(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 AwFormDatabaseService::~AwFormDatabaseService() { | 47 AwFormDatabaseService::~AwFormDatabaseService() { |
| 48 Shutdown(); | 48 Shutdown(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void AwFormDatabaseService::Shutdown() { | 51 void AwFormDatabaseService::Shutdown() { |
| 52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 52 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 53 DCHECK(result_map_.empty()); | 53 DCHECK(result_map_.empty()); |
| 54 // TODO(sgurun) we don't run into this logic right now, | 54 // TODO(sgurun) we don't run into this logic right now, |
| 55 // but if we do, then we need to implement cancellation | 55 // but if we do, then we need to implement cancellation |
| 56 // of pending queries. | 56 // of pending queries. |
| 57 autofill_data_->ShutdownOnUIThread(); | 57 autofill_data_->ShutdownOnUIThread(); |
| 58 web_database_->ShutdownDatabase(); | 58 web_database_->ShutdownDatabase(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 scoped_refptr<autofill::AutofillWebDataService> | 61 scoped_refptr<autofill::AutofillWebDataService> |
| 62 AwFormDatabaseService::get_autofill_webdata_service() { | 62 AwFormDatabaseService::get_autofill_webdata_service() { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 PendingQuery query; | 100 PendingQuery query; |
| 101 query.result = result; | 101 query.result = result; |
| 102 query.completion = completion; | 102 query.completion = completion; |
| 103 result_map_[pending_query_handle] = query; | 103 result_map_[pending_query_handle] = query; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void AwFormDatabaseService::OnWebDataServiceRequestDone( | 106 void AwFormDatabaseService::OnWebDataServiceRequestDone( |
| 107 WebDataServiceBase::Handle h, | 107 WebDataServiceBase::Handle h, |
| 108 const WDTypedResult* result) { | 108 const WDTypedResult* result) { |
| 109 | 109 |
| 110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 110 DCHECK_CURRENTLY_ON(BrowserThread::DB); |
| 111 bool has_form_data = false; | 111 bool has_form_data = false; |
| 112 if (result) { | 112 if (result) { |
| 113 DCHECK_EQ(AUTOFILL_VALUE_RESULT, result->GetType()); | 113 DCHECK_EQ(AUTOFILL_VALUE_RESULT, result->GetType()); |
| 114 const WDResult<bool>* autofill_result = | 114 const WDResult<bool>* autofill_result = |
| 115 static_cast<const WDResult<bool>*>(result); | 115 static_cast<const WDResult<bool>*>(result); |
| 116 has_form_data = autofill_result->GetValue(); | 116 has_form_data = autofill_result->GetValue(); |
| 117 } | 117 } |
| 118 QueryMap::const_iterator it = result_map_.find(h); | 118 QueryMap::const_iterator it = result_map_.find(h); |
| 119 if (it == result_map_.end()) { | 119 if (it == result_map_.end()) { |
| 120 LOG(WARNING) << "Received unexpected callback from web data service"; | 120 LOG(WARNING) << "Received unexpected callback from web data service"; |
| 121 return; | 121 return; |
| 122 } | 122 } |
| 123 *(it->second.result) = has_form_data; | 123 *(it->second.result) = has_form_data; |
| 124 it->second.completion->Signal(); | 124 it->second.completion->Signal(); |
| 125 result_map_.erase(h); | 125 result_map_.erase(h); |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace android_webview | 128 } // namespace android_webview |
| OLD | NEW |