WebApp: Add completion callbacks to AbstractWebAppDatabase.

All write and delete ops are async.

Promote WriteWebApp to be able to write multiple web apps in one write batch.
(WriteWebApps).

WriteWebApps matches DeleteWebApps now.

Next CL: Support batched update in WebAppRegistrar.

Bug: 891172
Change-Id: I7d3a06894b608076ddda51968726945292b4fe60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1774013
Commit-Queue: Alexey Baskakov <[email protected]>
Reviewed-by: Eric Willigers <[email protected]>
Cr-Commit-Position: refs/heads/master@{#692571}
diff --git a/chrome/browser/web_applications/web_app_database.h b/chrome/browser/web_applications/web_app_database.h
index 8ef472b..ecb430a0 100644
--- a/chrome/browser/web_applications/web_app_database.h
+++ b/chrome/browser/web_applications/web_app_database.h
@@ -34,8 +34,9 @@
 
   // AbstractWebAppDatabase:
   void OpenDatabase(OnceRegistryOpenedCallback callback) override;
-  void WriteWebApp(const WebApp& web_app) override;
-  void DeleteWebApps(std::vector<AppId> app_ids) override;
+  void WriteWebApps(AppsToWrite apps, CompletionCallback callback) override;
+  void DeleteWebApps(std::vector<AppId> app_ids,
+                     CompletionCallback callback) override;
 
   // Exposed for testing.
   static std::unique_ptr<WebAppProto> CreateWebAppProto(const WebApp& web_app);
@@ -56,13 +57,14 @@
       const base::Optional<syncer::ModelError>& error,
       std::unique_ptr<syncer::ModelTypeStore::RecordList> data_records);
 
-  void OnDataWritten(const base::Optional<syncer::ModelError>& error);
+  void OnDataWritten(CompletionCallback callback,
+                     const base::Optional<syncer::ModelError>& error);
 
   static std::unique_ptr<WebApp> ParseWebApp(const AppId& app_id,
                                              const std::string& value);
 
   void BeginTransaction();
-  void CommitTransaction();
+  void CommitTransaction(CompletionCallback callback);
 
   std::unique_ptr<syncer::ModelTypeStore> store_;
   std::unique_ptr<syncer::ModelTypeStore::WriteBatch> write_batch_;