 Chromium Code Reviews
 Chromium Code Reviews Issue 2550293002:
  [sync] Add autofill sync metadata to the web db  (Closed)
    
  
    Issue 2550293002:
  [sync] Add autofill sync metadata to the web db  (Closed) 
  | Index: components/autofill/core/browser/webdata/autofill_table.h | 
| diff --git a/components/autofill/core/browser/webdata/autofill_table.h b/components/autofill/core/browser/webdata/autofill_table.h | 
| index a8eceb0ae1b99c469fd9ba4cc3c234cc5d20b094..04ba0237d3de6613b6b076af65f7a2c981c70696 100644 | 
| --- a/components/autofill/core/browser/webdata/autofill_table.h | 
| +++ b/components/autofill/core/browser/webdata/autofill_table.h | 
| @@ -13,6 +13,8 @@ | 
| #include "base/gtest_prod_util.h" | 
| #include "base/macros.h" | 
| #include "base/strings/string16.h" | 
| +#include "components/sync/base/model_type.h" | 
| +#include "components/sync/model/metadata_batch.h" | 
| #include "components/webdata/common/web_database_table.h" | 
| class WebDatabase; | 
| @@ -21,6 +23,11 @@ namespace base { | 
| class Time; | 
| } | 
| +namespace sync_pb { | 
| +class EntityMetadata; | 
| +class ModelTypeState; | 
| +} | 
| + | 
| namespace autofill { | 
| class AutofillChange; | 
| @@ -228,6 +235,18 @@ struct FormFieldData; | 
| // a form. | 
| // use_date The date this address was last used to fill a form, | 
| // in internal t. | 
| +// autofill_sync_metadata | 
| +// Sync-specific metadata for autofill records. | 
| +// | 
| +// storage_key A string that uniquely identifies the metadata record | 
| +// as well as the corresponding autofill record. | 
| +// value The serialized EntityMetadata record. | 
| +// | 
| +// autofill_model_type_state | 
| +// Single row table that contains the sync ModelTypeState | 
| +// for the autofill model type. | 
| +// | 
| +// value The serialized ModelTypeState record. | 
| class AutofillTable : public WebDatabaseTable { | 
| public: | 
| @@ -403,6 +422,32 @@ class AutofillTable : public WebDatabaseTable { | 
| // Clear all profiles. | 
| bool ClearAutofillProfiles(); | 
| + // Read all the stored metadata of |model_type| and fill |metadata_records| | 
| + // with it. | 
| + bool GetAllSyncMetadata(syncer::ModelType model_type, | 
| + syncer::EntityMetadataMap* metadata_records); | 
| 
pavely
2016/12/08 23:34:45
Since you are accumulating metadata records in Ent
 
Patrick Noland
2016/12/10 00:39:35
I've added a todo for this.
 | 
| + | 
| + // Update the metadata row for |model_type|, keyed by |storage_key|, to | 
| + // contain the contents of |metadata|. | 
| + bool UpdateSyncMetadata(syncer::ModelType model_type, | 
| + const std::string& storage_key, | 
| + const sync_pb::EntityMetadata& metadata); | 
| + | 
| + // Remove the metadata row of type |model_type| keyed by |storage|key|. | 
| + bool ClearSyncMetadata(syncer::ModelType model_type, | 
| + const std::string& storage_key); | 
| + | 
| + // Retrieve the stored sync state for the |model_type|. | 
| + bool GetModelTypeState(syncer::ModelType model_type, | 
| + sync_pb::ModelTypeState* state); | 
| + | 
| + // Update the stored sync state for the |model_type|. | 
| + bool UpdateModelTypeState(syncer::ModelType model_type, | 
| + sync_pb::ModelTypeState& model_type_state); | 
| 
maxbogue
2016/12/08 21:14:05
const
 
Patrick Noland
2016/12/10 00:39:35
Done.
 | 
| + | 
| + // Clear the stored sync state for |model_type|. | 
| + bool ClearModelTypeState(syncer::ModelType model_type); | 
| + | 
| // Table migration functions. NB: These do not and should not rely on other | 
| // functions in this class. The implementation of a function such as | 
| // GetCreditCard may change over time, but MigrateToVersionXX should never | 
| @@ -419,6 +464,7 @@ class AutofillTable : public WebDatabaseTable { | 
| bool MigrateToVersion65AddServerMetadataTables(); | 
| bool MigrateToVersion66AddCardBillingAddress(); | 
| bool MigrateToVersion67AddMaskedCardBillingAddress(); | 
| + bool MigrateToVersion70AddSyncMetadata(); | 
| // Max data length saved in the table, AKA the maximum length allowed for | 
| // form data. | 
| @@ -496,6 +542,8 @@ class AutofillTable : public WebDatabaseTable { | 
| bool InitServerCardMetadataTable(); | 
| bool InitServerAddressesTable(); | 
| bool InitServerAddressMetadataTable(); | 
| + bool InitAutofillSyncMetadataTable(); | 
| + bool InitModelTypeStateTable(); | 
| DISALLOW_COPY_AND_ASSIGN(AutofillTable); | 
| }; |