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

Side by Side Diff: chrome/browser/webdata/autocomplete_syncable_service.h

Issue 9585020: Cull autofill entries older than 60 days. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: if (!RemoveFormElementForID(pair_id)) Created 8 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_WEBDATA_AUTOCOMPLETE_SYNCABLE_SERVICE_H_ 4 #ifndef CHROME_BROWSER_WEBDATA_AUTOCOMPLETE_SYNCABLE_SERVICE_H_
5 #define CHROME_BROWSER_WEBDATA_AUTOCOMPLETE_SYNCABLE_SERVICE_H_ 5 #define CHROME_BROWSER_WEBDATA_AUTOCOMPLETE_SYNCABLE_SERVICE_H_
6 #pragma once 6 #pragma once
7 7
8 #include <map> 8 #include <map>
9 #include <set>
9 #include <string> 10 #include <string>
10 #include <utility> 11 #include <utility>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/basictypes.h" 14 #include "base/basictypes.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/threading/non_thread_safe.h" 16 #include "base/threading/non_thread_safe.h"
16 #include "chrome/browser/sync/api/sync_change.h" 17 #include "chrome/browser/sync/api/sync_change.h"
17 #include "chrome/browser/sync/api/sync_data.h" 18 #include "chrome/browser/sync/api/sync_data.h"
18 #include "chrome/browser/sync/api/sync_error.h" 19 #include "chrome/browser/sync/api/sync_error.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 87
87 // This is a helper map used only in Merge/Process* functions. The lifetime 88 // This is a helper map used only in Merge/Process* functions. The lifetime
88 // of the iterator is longer than the map object. The bool in the pair is used 89 // of the iterator is longer than the map object. The bool in the pair is used
89 // to indicate if the item needs to be added (true) or updated (false). 90 // to indicate if the item needs to be added (true) or updated (false).
90 typedef std::map<AutofillKey, 91 typedef std::map<AutofillKey,
91 std::pair<SyncChange::SyncChangeType, 92 std::pair<SyncChange::SyncChangeType,
92 std::vector<AutofillEntry>::iterator> > 93 std::vector<AutofillEntry>::iterator> >
93 AutocompleteEntryMap; 94 AutocompleteEntryMap;
94 95
95 // Creates or updates an autocomplete entry based on |data|. 96 // Creates or updates an autocomplete entry based on |data|.
97 // |data| - an entry for sync.
98 // |loaded_data| - entries that were loaded from local storage.
99 // |new_entries| - entries that came from the sync.
100 // |ignored_entries| - entries that came from the sync, but to old to be
Ilya Sherman 2012/03/23 22:44:45 nit: "to old" -> "too old"
GeorgeY 2012/03/26 19:59:10 Done.
101 // stored and immediately discarded.
96 void CreateOrUpdateEntry(const SyncData& data, 102 void CreateOrUpdateEntry(const SyncData& data,
97 AutocompleteEntryMap* loaded_data, 103 AutocompleteEntryMap* loaded_data,
98 std::vector<AutofillEntry>* bundle); 104 std::vector<AutofillEntry>* new_entries,
105 std::vector<AutofillEntry>* ignored_entries);
99 106
100 // Writes |entry| data into supplied |autofill_specifics|. 107 // Writes |entry| data into supplied |autofill_specifics|.
101 static void WriteAutofillEntry(const AutofillEntry& entry, 108 static void WriteAutofillEntry(const AutofillEntry& entry,
102 sync_pb::EntitySpecifics* autofill_specifics); 109 sync_pb::EntitySpecifics* autofill_specifics);
103 110
104 // Deletes the database entry corresponding to the |autofill| specifics. 111 // Deletes the database entry corresponding to the |autofill| specifics.
105 SyncError AutofillEntryDelete(const sync_pb::AutofillSpecifics& autofill); 112 SyncError AutofillEntryDelete(const sync_pb::AutofillSpecifics& autofill);
106 113
107 SyncData CreateSyncData(const AutofillEntry& entry) const; 114 SyncData CreateSyncData(const AutofillEntry& entry) const;
108 115
109 // Syncs |changes| to the cloud. 116 // Syncs |changes| to the cloud.
110 void ActOnChanges(const AutofillChangeList& changes); 117 void ActOnChanges(const AutofillChangeList& changes);
111 118
112 static std::string KeyToTag(const std::string& name, 119 static std::string KeyToTag(const std::string& name,
113 const std::string& value); 120 const std::string& value);
114 121
115 // For unit-tests. 122 // For unit-tests.
116 AutocompleteSyncableService(); 123 AutocompleteSyncableService();
117 void set_sync_processor(SyncChangeProcessor* sync_processor) { 124 void set_sync_processor(SyncChangeProcessor* sync_processor) {
118 sync_processor_.reset(sync_processor); 125 sync_processor_.reset(sync_processor);
119 } 126 }
120 127
128 // Ignore deletions of the following keys as they were never synced.
129 std::set<AutofillKey> keys_to_ignore_;
130
121 // Lifetime of AutocompleteSyncableService object is shorter than 131 // Lifetime of AutocompleteSyncableService object is shorter than
122 // |web_data_service_| passed to it. 132 // |web_data_service_| passed to it.
123 WebDataService* web_data_service_; 133 WebDataService* web_data_service_;
124 content::NotificationRegistrar notification_registrar_; 134 content::NotificationRegistrar notification_registrar_;
125 135
126 // We receive ownership of |sync_processor_| in MergeDataAndStartSyncing() and 136 // We receive ownership of |sync_processor_| in MergeDataAndStartSyncing() and
127 // destroy it in StopSyncing(). 137 // destroy it in StopSyncing().
128 scoped_ptr<SyncChangeProcessor> sync_processor_; 138 scoped_ptr<SyncChangeProcessor> sync_processor_;
129 139
130 DISALLOW_COPY_AND_ASSIGN(AutocompleteSyncableService); 140 DISALLOW_COPY_AND_ASSIGN(AutocompleteSyncableService);
131 }; 141 };
132 142
133 #endif // CHROME_BROWSER_WEBDATA_AUTOCOMPLETE_SYNCABLE_SERVICE_H_ 143 #endif // CHROME_BROWSER_WEBDATA_AUTOCOMPLETE_SYNCABLE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698