Revert of ui: Clean up damaged rects and clear them after painting. (patchset #2...
[chromium-blink-merge.git] / android_webview / browser / aw_form_database_service.h
blob857b23a35178bfd8fe1ef710defad159c87cbd8d
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
3 // found in the LICENSE file.
5 #ifndef ANDROID_WEBVIEW_BROWSER_AW_FORM_DATABASE_SERVICE_H_
6 #define ANDROID_WEBVIEW_BROWSER_AW_FORM_DATABASE_SERVICE_H_
8 #include "base/basictypes.h"
9 #include "base/files/file_path.h"
10 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
11 #include "components/webdata/common/web_data_service_consumer.h"
12 #include "components/webdata/common/web_database_service.h"
14 namespace base {
15 class WaitableEvent;
18 namespace android_webview {
20 // Handles the database operations necessary to implement the autocomplete
21 // functionality. This includes creating and initializing the components that
22 // handle the database backend, and providing a synchronous interface when
23 // needed (the chromium database components have an async. interface).
24 class AwFormDatabaseService : public WebDataServiceConsumer {
25 public:
26 AwFormDatabaseService(const base::FilePath path);
28 ~AwFormDatabaseService() override;
30 void Shutdown();
32 // Returns whether the database has any data stored. May do
33 // IO access and block.
34 bool HasFormData();
36 // Clear any saved form data. Executes asynchronously.
37 void ClearFormData();
39 scoped_refptr<autofill::AutofillWebDataService>
40 get_autofill_webdata_service();
42 // WebDataServiceConsumer implementation.
43 void OnWebDataServiceRequestDone(WebDataServiceBase::Handle h,
44 const WDTypedResult* result) override;
46 private:
47 struct PendingQuery {
48 bool* result;
49 base::WaitableEvent* completion;
51 typedef std::map<WebDataServiceBase::Handle, PendingQuery> QueryMap;
53 void ClearFormDataImpl();
54 void HasFormDataImpl(base::WaitableEvent* completion, bool* result);
56 QueryMap result_map_;
58 scoped_refptr<autofill::AutofillWebDataService> autofill_data_;
59 scoped_refptr<WebDatabaseService> web_database_;
61 DISALLOW_COPY_AND_ASSIGN(AwFormDatabaseService);
64 } // namespace android_webview
66 #endif // ANDROID_WEBVIEW_BROWSER_AW_FORM_DATABASE_SERVICE_H_