 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) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ | 
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ | 
| 7 | 7 | 
| 8 #include <stddef.h> | 8 #include <stddef.h> | 
| 9 | 9 | 
| 10 #include <memory> | 10 #include <memory> | 
| 11 #include <vector> | 11 #include <vector> | 
| 12 | 12 | 
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" | 
| 14 #include "base/macros.h" | 14 #include "base/macros.h" | 
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" | 
| 16 #include "components/sync/base/model_type.h" | |
| 17 #include "components/sync/model/metadata_batch.h" | |
| 16 #include "components/webdata/common/web_database_table.h" | 18 #include "components/webdata/common/web_database_table.h" | 
| 17 | 19 | 
| 18 class WebDatabase; | 20 class WebDatabase; | 
| 19 | 21 | 
| 20 namespace base { | 22 namespace base { | 
| 21 class Time; | 23 class Time; | 
| 22 } | 24 } | 
| 23 | 25 | 
| 26 namespace sync_pb { | |
| 27 class EntityMetadata; | |
| 28 class ModelTypeState; | |
| 29 } | |
| 30 | |
| 24 namespace autofill { | 31 namespace autofill { | 
| 25 | 32 | 
| 26 class AutofillChange; | 33 class AutofillChange; | 
| 27 class AutofillEntry; | 34 class AutofillEntry; | 
| 28 class AutofillProfile; | 35 class AutofillProfile; | 
| 29 class AutofillTableTest; | 36 class AutofillTableTest; | 
| 30 class CreditCard; | 37 class CreditCard; | 
| 31 | 38 | 
| 32 struct FormFieldData; | 39 struct FormFieldData; | 
| 33 | 40 | 
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 // server_address_metadata | 228 // server_address_metadata | 
| 222 // Metadata (currently, usage data) about server addresses. | 229 // Metadata (currently, usage data) about server addresses. | 
| 223 // This will be synced. | 230 // This will be synced. | 
| 224 // | 231 // | 
| 225 // id The server ID, which matches an ID from the | 232 // id The server ID, which matches an ID from the | 
| 226 // server_addresses table. | 233 // server_addresses table. | 
| 227 // use_count The number of times this address has been used to fill | 234 // use_count The number of times this address has been used to fill | 
| 228 // a form. | 235 // a form. | 
| 229 // use_date The date this address was last used to fill a form, | 236 // use_date The date this address was last used to fill a form, | 
| 230 // in internal t. | 237 // in internal t. | 
| 238 // autofill_sync_metadata | |
| 239 // Sync-specific metadata for autofill records. | |
| 240 // | |
| 241 // storage_key A string that uniquely identifies the metadata record | |
| 242 // as well as the corresponding autofill record. | |
| 243 // value The serialized EntityMetadata record. | |
| 244 // | |
| 245 // autofill_model_type_state | |
| 246 // Single row table that contains the sync ModelTypeState | |
| 247 // for the autofill model type. | |
| 248 // | |
| 249 // value The serialized ModelTypeState record. | |
| 231 | 250 | 
| 232 class AutofillTable : public WebDatabaseTable { | 251 class AutofillTable : public WebDatabaseTable { | 
| 233 public: | 252 public: | 
| 234 AutofillTable(); | 253 AutofillTable(); | 
| 235 ~AutofillTable() override; | 254 ~AutofillTable() override; | 
| 236 | 255 | 
| 237 // Retrieves the AutofillTable* owned by |db|. | 256 // Retrieves the AutofillTable* owned by |db|. | 
| 238 static AutofillTable* FromWebDatabase(WebDatabase* db); | 257 static AutofillTable* FromWebDatabase(WebDatabase* db); | 
| 239 | 258 | 
| 240 // WebDatabaseTable: | 259 // WebDatabaseTable: | 
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 // Empties the Autofill profiles "trash can". | 415 // Empties the Autofill profiles "trash can". | 
| 397 bool EmptyAutofillProfilesTrash(); | 416 bool EmptyAutofillProfilesTrash(); | 
| 398 | 417 | 
| 399 // Retrieves all profiles in the database that have been deleted since last | 418 // Retrieves all profiles in the database that have been deleted since last | 
| 400 // "empty" of the trash. | 419 // "empty" of the trash. | 
| 401 bool AddAutofillGUIDToTrash(const std::string& guid); | 420 bool AddAutofillGUIDToTrash(const std::string& guid); | 
| 402 | 421 | 
| 403 // Clear all profiles. | 422 // Clear all profiles. | 
| 404 bool ClearAutofillProfiles(); | 423 bool ClearAutofillProfiles(); | 
| 405 | 424 | 
| 425 // Read all the stored metadata of |model_type| and fill |metadata_records| | |
| 426 // with it. | |
| 427 bool GetAllSyncMetadata(syncer::ModelType model_type, | |
| 428 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.
 | |
| 429 | |
| 430 // Update the metadata row for |model_type|, keyed by |storage_key|, to | |
| 431 // contain the contents of |metadata|. | |
| 432 bool UpdateSyncMetadata(syncer::ModelType model_type, | |
| 433 const std::string& storage_key, | |
| 434 const sync_pb::EntityMetadata& metadata); | |
| 435 | |
| 436 // Remove the metadata row of type |model_type| keyed by |storage|key|. | |
| 437 bool ClearSyncMetadata(syncer::ModelType model_type, | |
| 438 const std::string& storage_key); | |
| 439 | |
| 440 // Retrieve the stored sync state for the |model_type|. | |
| 441 bool GetModelTypeState(syncer::ModelType model_type, | |
| 442 sync_pb::ModelTypeState* state); | |
| 443 | |
| 444 // Update the stored sync state for the |model_type|. | |
| 445 bool UpdateModelTypeState(syncer::ModelType model_type, | |
| 446 sync_pb::ModelTypeState& model_type_state); | |
| 
maxbogue
2016/12/08 21:14:05
const
 
Patrick Noland
2016/12/10 00:39:35
Done.
 | |
| 447 | |
| 448 // Clear the stored sync state for |model_type|. | |
| 449 bool ClearModelTypeState(syncer::ModelType model_type); | |
| 450 | |
| 406 // Table migration functions. NB: These do not and should not rely on other | 451 // Table migration functions. NB: These do not and should not rely on other | 
| 407 // functions in this class. The implementation of a function such as | 452 // functions in this class. The implementation of a function such as | 
| 408 // GetCreditCard may change over time, but MigrateToVersionXX should never | 453 // GetCreditCard may change over time, but MigrateToVersionXX should never | 
| 409 // change. | 454 // change. | 
| 410 bool MigrateToVersion54AddI18nFieldsAndRemoveDeprecatedFields(); | 455 bool MigrateToVersion54AddI18nFieldsAndRemoveDeprecatedFields(); | 
| 411 bool MigrateToVersion55MergeAutofillDatesTable(); | 456 bool MigrateToVersion55MergeAutofillDatesTable(); | 
| 412 bool MigrateToVersion56AddProfileLanguageCodeForFormatting(); | 457 bool MigrateToVersion56AddProfileLanguageCodeForFormatting(); | 
| 413 bool MigrateToVersion57AddFullNameField(); | 458 bool MigrateToVersion57AddFullNameField(); | 
| 414 bool MigrateToVersion60AddServerCards(); | 459 bool MigrateToVersion60AddServerCards(); | 
| 415 bool MigrateToVersion61AddUsageStats(); | 460 bool MigrateToVersion61AddUsageStats(); | 
| 416 bool MigrateToVersion62AddUsageStatsForUnmaskedCards(); | 461 bool MigrateToVersion62AddUsageStatsForUnmaskedCards(); | 
| 417 bool MigrateToVersion63AddServerRecipientName(); | 462 bool MigrateToVersion63AddServerRecipientName(); | 
| 418 bool MigrateToVersion64AddUnmaskDate(); | 463 bool MigrateToVersion64AddUnmaskDate(); | 
| 419 bool MigrateToVersion65AddServerMetadataTables(); | 464 bool MigrateToVersion65AddServerMetadataTables(); | 
| 420 bool MigrateToVersion66AddCardBillingAddress(); | 465 bool MigrateToVersion66AddCardBillingAddress(); | 
| 421 bool MigrateToVersion67AddMaskedCardBillingAddress(); | 466 bool MigrateToVersion67AddMaskedCardBillingAddress(); | 
| 467 bool MigrateToVersion70AddSyncMetadata(); | |
| 422 | 468 | 
| 423 // Max data length saved in the table, AKA the maximum length allowed for | 469 // Max data length saved in the table, AKA the maximum length allowed for | 
| 424 // form data. | 470 // form data. | 
| 425 // Copied to components/autofill/ios/browser/resources/autofill_controller.js. | 471 // Copied to components/autofill/ios/browser/resources/autofill_controller.js. | 
| 426 static const size_t kMaxDataLength; | 472 static const size_t kMaxDataLength; | 
| 427 | 473 | 
| 428 private: | 474 private: | 
| 429 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill); | 475 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill); | 
| 430 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill_AddChanges); | 476 FRIEND_TEST_ALL_PREFIXES(AutofillTableTest, Autofill_AddChanges); | 
| 431 FRIEND_TEST_ALL_PREFIXES( | 477 FRIEND_TEST_ALL_PREFIXES( | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 bool InitProfilesTable(); | 535 bool InitProfilesTable(); | 
| 490 bool InitProfileNamesTable(); | 536 bool InitProfileNamesTable(); | 
| 491 bool InitProfileEmailsTable(); | 537 bool InitProfileEmailsTable(); | 
| 492 bool InitProfilePhonesTable(); | 538 bool InitProfilePhonesTable(); | 
| 493 bool InitProfileTrashTable(); | 539 bool InitProfileTrashTable(); | 
| 494 bool InitMaskedCreditCardsTable(); | 540 bool InitMaskedCreditCardsTable(); | 
| 495 bool InitUnmaskedCreditCardsTable(); | 541 bool InitUnmaskedCreditCardsTable(); | 
| 496 bool InitServerCardMetadataTable(); | 542 bool InitServerCardMetadataTable(); | 
| 497 bool InitServerAddressesTable(); | 543 bool InitServerAddressesTable(); | 
| 498 bool InitServerAddressMetadataTable(); | 544 bool InitServerAddressMetadataTable(); | 
| 545 bool InitAutofillSyncMetadataTable(); | |
| 546 bool InitModelTypeStateTable(); | |
| 499 | 547 | 
| 500 DISALLOW_COPY_AND_ASSIGN(AutofillTable); | 548 DISALLOW_COPY_AND_ASSIGN(AutofillTable); | 
| 501 }; | 549 }; | 
| 502 | 550 | 
| 503 } // namespace autofill | 551 } // namespace autofill | 
| 504 | 552 | 
| 505 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ | 553 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ | 
| OLD | NEW |