| 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/webdata/web_data_service.h" | 5 #include "chrome/browser/webdata/web_data_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 WDKeywordsResult::WDKeywordsResult() | 73 WDKeywordsResult::WDKeywordsResult() |
| 74 : default_search_provider_id(0), | 74 : default_search_provider_id(0), |
| 75 builtin_keyword_version(0), | 75 builtin_keyword_version(0), |
| 76 backup_valid(false), | 76 backup_valid(false), |
| 77 did_default_search_provider_change(false) { | 77 did_default_search_provider_change(false) { |
| 78 } | 78 } |
| 79 | 79 |
| 80 WDKeywordsResult::~WDKeywordsResult() {} | 80 WDKeywordsResult::~WDKeywordsResult() {} |
| 81 | 81 |
| 82 WebDataService::WebDataService() | 82 WebDataService::WebDataService() |
| 83 : is_running_(false), | 83 : RefcountedProfileKeyedService(BrowserThread::UI), |
| 84 db_(NULL), | 84 is_running_(false), |
| 85 autocomplete_syncable_service_(NULL), | 85 db_(NULL), |
| 86 autofill_profile_syncable_service_(NULL), | 86 autocomplete_syncable_service_(NULL), |
| 87 failed_init_(false), | 87 autofill_profile_syncable_service_(NULL), |
| 88 should_commit_(false), | 88 failed_init_(false), |
| 89 next_request_handle_(1), | 89 should_commit_(false), |
| 90 main_loop_(MessageLoop::current()) { | 90 next_request_handle_(1), |
| 91 main_loop_(MessageLoop::current()) { |
| 91 } | 92 } |
| 92 | 93 |
| 93 // static | 94 // static |
| 94 void WebDataService::NotifyOfMultipleAutofillChanges( | 95 void WebDataService::NotifyOfMultipleAutofillChanges( |
| 95 WebDataService* web_data_service) { | 96 WebDataService* web_data_service) { |
| 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 97 | 98 |
| 98 if (!web_data_service) | 99 if (!web_data_service) |
| 99 return; | 100 return; |
| 100 | 101 |
| 101 BrowserThread::PostTask( | 102 BrowserThread::PostTask( |
| 102 BrowserThread::UI, FROM_HERE, | 103 BrowserThread::UI, FROM_HERE, |
| 103 Bind(&NotifyOfMultipleAutofillChangesTask, | 104 Bind(&NotifyOfMultipleAutofillChangesTask, |
| 104 make_scoped_refptr(web_data_service))); | 105 make_scoped_refptr(web_data_service))); |
| 105 } | 106 } |
| 106 | 107 |
| 108 void WebDataService::ShutdownOnUIThread() { |
| 109 ScheduleTask(FROM_HERE, |
| 110 Bind(&WebDataService::ShutdownSyncableServices, this)); |
| 111 UnloadDatabase(); |
| 112 } |
| 113 |
| 107 bool WebDataService::Init(const FilePath& profile_path) { | 114 bool WebDataService::Init(const FilePath& profile_path) { |
| 108 FilePath path = profile_path; | 115 FilePath path = profile_path; |
| 109 path = path.Append(chrome::kWebDataFilename); | 116 path = path.Append(chrome::kWebDataFilename); |
| 110 return InitWithPath(path); | 117 return InitWithPath(path); |
| 111 } | 118 } |
| 112 | 119 |
| 113 void WebDataService::Shutdown() { | |
| 114 ScheduleTask(FROM_HERE, | |
| 115 Bind(&WebDataService::ShutdownSyncableServices, this)); | |
| 116 UnloadDatabase(); | |
| 117 } | |
| 118 | |
| 119 bool WebDataService::IsRunning() const { | 120 bool WebDataService::IsRunning() const { |
| 120 return is_running_; | 121 return is_running_; |
| 121 } | 122 } |
| 122 | 123 |
| 123 void WebDataService::UnloadDatabase() { | 124 void WebDataService::UnloadDatabase() { |
| 124 ScheduleTask(FROM_HERE, Bind(&WebDataService::ShutdownDatabase, this)); | 125 ScheduleTask(FROM_HERE, Bind(&WebDataService::ShutdownDatabase, this)); |
| 125 } | 126 } |
| 126 | 127 |
| 127 void WebDataService::CancelRequest(Handle h) { | 128 void WebDataService::CancelRequest(Handle h) { |
| 128 base::AutoLock l(pending_lock_); | 129 base::AutoLock l(pending_lock_); |
| (...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 } | 1653 } |
| 1653 | 1654 |
| 1654 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { | 1655 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { |
| 1655 return result_; | 1656 return result_; |
| 1656 } | 1657 } |
| 1657 | 1658 |
| 1658 void WebDataService::WebDataRequest::RequestComplete() { | 1659 void WebDataService::WebDataRequest::RequestComplete() { |
| 1659 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, | 1660 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, |
| 1660 service_.get(), handle_)); | 1661 service_.get(), handle_)); |
| 1661 } | 1662 } |
| OLD | NEW |