Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: android_webview/browser/aw_form_database_service.cc

Issue 16154031: Un-refcount AutofillWebData and TokenWebData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on ToT Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "components/autofill/browser/webdata/autofill_table.h" 7 #include "components/autofill/browser/webdata/autofill_table.h"
8 #include "components/webdata/common/webdata_constants.h" 8 #include "components/webdata/common/webdata_constants.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "ui/base/l10n/l10n_util_android.h" 10 #include "ui/base/l10n/l10n_util_android.h"
(...skipping 16 matching lines...) Expand all
27 : pending_query_handle_(0), 27 : pending_query_handle_(0),
28 has_form_data_(false), 28 has_form_data_(false),
29 completion_(false, false) { 29 completion_(false, false) {
30 30
31 web_database_ = new WebDatabaseService(path.Append(kWebDataFilename)); 31 web_database_ = new WebDatabaseService(path.Append(kWebDataFilename));
32 web_database_->AddTable( 32 web_database_->AddTable(
33 scoped_ptr<WebDatabaseTable>(new autofill::AutofillTable( 33 scoped_ptr<WebDatabaseTable>(new autofill::AutofillTable(
34 l10n_util::GetDefaultLocale()))); 34 l10n_util::GetDefaultLocale())));
35 web_database_->LoadDatabase(); 35 web_database_->LoadDatabase();
36 36
37 autofill_data_ = new autofill::AutofillWebDataService( 37 autofill_data_ .reset(new autofill::AutofillWebDataService(
38 web_database_, base::Bind(&DatabaseErrorCallback)); 38 web_database_, base::Bind(&DatabaseErrorCallback)));
39 autofill_data_->Init(); 39 autofill_data_->Init();
40 } 40 }
41 41
42 AwFormDatabaseService::~AwFormDatabaseService() { 42 AwFormDatabaseService::~AwFormDatabaseService() {
43 CancelPendingQuery(); 43 CancelPendingQuery();
44 Shutdown(); 44 Shutdown();
45 } 45 }
46 46
47 void AwFormDatabaseService::Shutdown() { 47 void AwFormDatabaseService::Shutdown() {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
49 autofill_data_->ShutdownOnUIThread(); 49 autofill_data_->ShutdownOnUIThread();
50 web_database_->ShutdownDatabase(); 50 web_database_->ShutdownDatabase();
51 } 51 }
52 52
53 void AwFormDatabaseService::CancelPendingQuery() { 53 void AwFormDatabaseService::CancelPendingQuery() {
54 if (pending_query_handle_) { 54 if (pending_query_handle_) {
55 if (autofill_data_) 55 if (autofill_data_)
56 autofill_data_->CancelRequest(pending_query_handle_); 56 autofill_data_->CancelRequest(pending_query_handle_);
57 pending_query_handle_ = 0; 57 pending_query_handle_ = 0;
58 } 58 }
59 } 59 }
60 60
61 scoped_refptr<autofill::AutofillWebDataService> 61 autofill::AutofillWebDataService*
62 AwFormDatabaseService::get_autofill_webdata_service() { 62 AwFormDatabaseService::get_autofill_webdata_service() {
63 return autofill_data_; 63 return autofill_data_.get();
64 } 64 }
65 65
66 void AwFormDatabaseService::ClearFormData() { 66 void AwFormDatabaseService::ClearFormData() {
67 base::Time begin; 67 base::Time begin;
68 base::Time end = base::Time::Max(); 68 base::Time end = base::Time::Max();
69 autofill_data_->RemoveFormElementsAddedBetween(begin, end); 69 autofill_data_->RemoveFormElementsAddedBetween(begin, end);
70 autofill_data_->RemoveAutofillDataModifiedBetween(begin, end); 70 autofill_data_->RemoveAutofillDataModifiedBetween(begin, end);
71 } 71 }
72 72
73 bool AwFormDatabaseService::HasFormData() { 73 bool AwFormDatabaseService::HasFormData() {
(...skipping 22 matching lines...) Expand all
96 if (result) { 96 if (result) {
97 DCHECK_EQ(AUTOFILL_VALUE_RESULT, result->GetType()); 97 DCHECK_EQ(AUTOFILL_VALUE_RESULT, result->GetType());
98 const WDResult<bool>* autofill_result = 98 const WDResult<bool>* autofill_result =
99 static_cast<const WDResult<bool>*>(result); 99 static_cast<const WDResult<bool>*>(result);
100 has_form_data_ = autofill_result->GetValue(); 100 has_form_data_ = autofill_result->GetValue();
101 } 101 }
102 completion_.Signal(); 102 completion_.Signal();
103 } 103 }
104 104
105 } // namespace android_webview 105 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/aw_form_database_service.h ('k') | android_webview/native/aw_form_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698