| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/webdata/common/web_database_service.h" | 5 #include "components/webdata/common/web_database_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "components/webdata/common/web_data_request_manager.h" | 9 #include "components/webdata/common/web_data_request_manager.h" |
| 10 #include "components/webdata/common/web_data_results.h" | 10 #include "components/webdata/common/web_data_results.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 void WebDatabaseService::ShutdownDatabase() { | 78 void WebDatabaseService::ShutdownDatabase() { |
| 79 if (!wds_backend_) | 79 if (!wds_backend_) |
| 80 return; | 80 return; |
| 81 weak_ptr_factory_.InvalidateWeakPtrs(); | 81 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 82 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 82 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 83 Bind(&WebDataServiceBackend::ShutdownDatabase, | 83 Bind(&WebDataServiceBackend::ShutdownDatabase, |
| 84 wds_backend_, false)); | 84 wds_backend_, false)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 WebDatabase* WebDatabaseService::GetDatabaseOnDB() const { | 87 void WebDatabaseService::GetDatabaseOnDB(const DBCallback& callback) { |
| 88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 89 if (!wds_backend_) | 89 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 90 return NULL; | 90 Bind(&WebDataServiceBackend::GetDatabaseAsync, wds_backend_, callback)); |
| 91 return wds_backend_->database(); | |
| 92 } | 91 } |
| 93 | 92 |
| 94 void WebDatabaseService::ScheduleDBTask( | 93 void WebDatabaseService::ScheduleDBTask( |
| 95 const tracked_objects::Location& from_here, | 94 const tracked_objects::Location& from_here, |
| 96 const WriteTask& task) { | 95 const WriteTask& task) { |
| 97 if (!wds_backend_) { | 96 if (!wds_backend_) { |
| 98 NOTREACHED() << "Task scheduled after Shutdown()"; | 97 NOTREACHED() << "Task scheduled after Shutdown()"; |
| 99 return; | 98 return; |
| 100 } | 99 } |
| 101 | 100 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 FOR_EACH_OBSERVER(WebDatabaseObserver, | 149 FOR_EACH_OBSERVER(WebDatabaseObserver, |
| 151 observer_list_, | 150 observer_list_, |
| 152 WebDatabaseLoaded()); | 151 WebDatabaseLoaded()); |
| 153 } else { | 152 } else { |
| 154 // Notify that the database load failed. | 153 // Notify that the database load failed. |
| 155 FOR_EACH_OBSERVER(WebDatabaseObserver, | 154 FOR_EACH_OBSERVER(WebDatabaseObserver, |
| 156 observer_list_, | 155 observer_list_, |
| 157 WebDatabaseLoadFailed(status)); | 156 WebDatabaseLoadFailed(status)); |
| 158 } | 157 } |
| 159 } | 158 } |
| OLD | NEW |