| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 WDAppImagesResult::~WDAppImagesResult() {} | 71 WDAppImagesResult::~WDAppImagesResult() {} |
| 72 | 72 |
| 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 } | 76 } |
| 77 | 77 |
| 78 WDKeywordsResult::~WDKeywordsResult() {} | 78 WDKeywordsResult::~WDKeywordsResult() {} |
| 79 | 79 |
| 80 WebDataService::WebDataService() | 80 WebDataService::WebDataService() |
| 81 : is_running_(false), | 81 : RefcountedProfileKeyedService(BrowserThread::UI), |
| 82 db_(NULL), | 82 is_running_(false), |
| 83 autocomplete_syncable_service_(NULL), | 83 db_(NULL), |
| 84 autofill_profile_syncable_service_(NULL), | 84 autocomplete_syncable_service_(NULL), |
| 85 failed_init_(false), | 85 autofill_profile_syncable_service_(NULL), |
| 86 should_commit_(false), | 86 failed_init_(false), |
| 87 next_request_handle_(1), | 87 should_commit_(false), |
| 88 main_loop_(MessageLoop::current()) { | 88 next_request_handle_(1), |
| 89 main_loop_(MessageLoop::current()) { |
| 89 } | 90 } |
| 90 | 91 |
| 91 // static | 92 // static |
| 92 void WebDataService::NotifyOfMultipleAutofillChanges( | 93 void WebDataService::NotifyOfMultipleAutofillChanges( |
| 93 WebDataService* web_data_service) { | 94 WebDataService* web_data_service) { |
| 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 95 | 96 |
| 96 if (!web_data_service) | 97 if (!web_data_service) |
| 97 return; | 98 return; |
| 98 | 99 |
| 99 BrowserThread::PostTask( | 100 BrowserThread::PostTask( |
| 100 BrowserThread::UI, FROM_HERE, | 101 BrowserThread::UI, FROM_HERE, |
| 101 Bind(&NotifyOfMultipleAutofillChangesTask, | 102 Bind(&NotifyOfMultipleAutofillChangesTask, |
| 102 make_scoped_refptr(web_data_service))); | 103 make_scoped_refptr(web_data_service))); |
| 103 } | 104 } |
| 104 | 105 |
| 106 void WebDataService::ShutdownOnUIThread() { |
| 107 ScheduleTask(FROM_HERE, |
| 108 Bind(&WebDataService::ShutdownSyncableServices, this)); |
| 109 UnloadDatabase(); |
| 110 } |
| 111 |
| 105 bool WebDataService::Init(const FilePath& profile_path) { | 112 bool WebDataService::Init(const FilePath& profile_path) { |
| 106 FilePath path = profile_path; | 113 FilePath path = profile_path; |
| 107 path = path.Append(chrome::kWebDataFilename); | 114 path = path.Append(chrome::kWebDataFilename); |
| 108 return InitWithPath(path); | 115 return InitWithPath(path); |
| 109 } | 116 } |
| 110 | 117 |
| 111 void WebDataService::Shutdown() { | |
| 112 ScheduleTask(FROM_HERE, | |
| 113 Bind(&WebDataService::ShutdownSyncableServices, this)); | |
| 114 UnloadDatabase(); | |
| 115 } | |
| 116 | |
| 117 bool WebDataService::IsRunning() const { | 118 bool WebDataService::IsRunning() const { |
| 118 return is_running_; | 119 return is_running_; |
| 119 } | 120 } |
| 120 | 121 |
| 121 void WebDataService::UnloadDatabase() { | 122 void WebDataService::UnloadDatabase() { |
| 122 ScheduleTask(FROM_HERE, Bind(&WebDataService::ShutdownDatabase, this)); | 123 ScheduleTask(FROM_HERE, Bind(&WebDataService::ShutdownDatabase, this)); |
| 123 } | 124 } |
| 124 | 125 |
| 125 void WebDataService::CancelRequest(Handle h) { | 126 void WebDataService::CancelRequest(Handle h) { |
| 126 base::AutoLock l(pending_lock_); | 127 base::AutoLock l(pending_lock_); |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 } | 1621 } |
| 1621 | 1622 |
| 1622 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { | 1623 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { |
| 1623 return result_; | 1624 return result_; |
| 1624 } | 1625 } |
| 1625 | 1626 |
| 1626 void WebDataService::WebDataRequest::RequestComplete() { | 1627 void WebDataService::WebDataRequest::RequestComplete() { |
| 1627 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, | 1628 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, |
| 1628 service_.get(), handle_)); | 1629 service_.get(), handle_)); |
| 1629 } | 1630 } |
| OLD | NEW |