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

Side by Side Diff: chrome/browser/search_engines/template_url_service.cc

Issue 10873075: Add a histogram to track deletes on synced search engines. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/search_engines/template_url_service.h" 5 #include "chrome/browser/search_engines/template_url_service.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // FirstPotentialDefaultEngine is called, and from where. 94 // FirstPotentialDefaultEngine is called, and from where.
95 enum FirstPotentialEngineCaller { 95 enum FirstPotentialEngineCaller {
96 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP, 96 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP,
97 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_PROCESSING_SYNC_CHANGES, 97 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_PROCESSING_SYNC_CHANGES,
98 FIRST_POTENTIAL_CALLSITE_ON_LOAD, 98 FIRST_POTENTIAL_CALLSITE_ON_LOAD,
99 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_SYNCING, 99 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_SYNCING,
100 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_NOT_SYNCING, 100 FIRST_POTENTIAL_CALLSITE_FIND_NEW_DSP_NOT_SYNCING,
101 FIRST_POTENTIAL_CALLSITE_MAX, 101 FIRST_POTENTIAL_CALLSITE_MAX,
102 }; 102 };
103 103
104 const char kDeleteSyncedEngineHistogramName[] =
105 "Search.DeleteSyncedSearchEngine";
106
107 // Values for an enumerated histogram used to track whenever an ACTION_DELETE is
108 // sent to the server for search engines.
109 enum DeleteSyncedSearchEngineEvent {
110 DELETE_ENGINE_USER_ACTION,
111 DELETE_ENGINE_PRE_SYNC,
112 DELETE_ENGINE_EMPTY_FIELD,
113 DELETE_ENGINE_MAX,
114 };
115
104 TemplateURL* FirstPotentialDefaultEngine( 116 TemplateURL* FirstPotentialDefaultEngine(
105 const TemplateURLService::TemplateURLVector& template_urls) { 117 const TemplateURLService::TemplateURLVector& template_urls) {
106 for (TemplateURLService::TemplateURLVector::const_iterator i( 118 for (TemplateURLService::TemplateURLVector::const_iterator i(
107 template_urls.begin()); i != template_urls.end(); ++i) { 119 template_urls.begin()); i != template_urls.end(); ++i) {
108 if ((*i)->ShowInDefaultList()) { 120 if ((*i)->ShowInDefaultList()) {
109 DCHECK(!(*i)->IsExtensionKeyword()); 121 DCHECK(!(*i)->IsExtensionKeyword());
110 return *i; 122 return *i;
111 } 123 }
112 } 124 }
113 return NULL; 125 return NULL;
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 1157
1146 if (pre_sync_deletes_.find(sync_turl->sync_guid()) != 1158 if (pre_sync_deletes_.find(sync_turl->sync_guid()) !=
1147 pre_sync_deletes_.end()) { 1159 pre_sync_deletes_.end()) {
1148 // This entry was deleted before the initial sync began (possibly through 1160 // This entry was deleted before the initial sync began (possibly through
1149 // preprocessing in TemplateURLService's loading code). Ignore it and send 1161 // preprocessing in TemplateURLService's loading code). Ignore it and send
1150 // an ACTION_DELETE up to the server. 1162 // an ACTION_DELETE up to the server.
1151 new_changes.push_back( 1163 new_changes.push_back(
1152 syncer::SyncChange(FROM_HERE, 1164 syncer::SyncChange(FROM_HERE,
1153 syncer::SyncChange::ACTION_DELETE, 1165 syncer::SyncChange::ACTION_DELETE,
1154 iter->second)); 1166 iter->second));
1167 UMA_HISTOGRAM_ENUMERATION(kDeleteSyncedEngineHistogramName,
1168 DELETE_ENGINE_PRE_SYNC, DELETE_ENGINE_MAX);
1155 continue; 1169 continue;
1156 } 1170 }
1157 1171
1158 if (local_turl) { 1172 if (local_turl) {
1159 DCHECK(IsFromSync(local_turl, sync_data_map)); 1173 DCHECK(IsFromSync(local_turl, sync_data_map));
1160 // This local search engine is already synced. If the timestamp differs 1174 // This local search engine is already synced. If the timestamp differs
1161 // from Sync, we need to update locally or to the cloud. Note that if the 1175 // from Sync, we need to update locally or to the cloud. Note that if the
1162 // timestamps are equal, we touch neither. 1176 // timestamps are equal, we touch neither.
1163 if (sync_turl->last_modified() > local_turl->last_modified()) { 1177 if (sync_turl->last_modified() > local_turl->last_modified()) {
1164 // We've received an update from Sync. We should replace all synced 1178 // We've received an update from Sync. We should replace all synced
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 sync_pb::SearchEngineSpecifics specifics = 1316 sync_pb::SearchEngineSpecifics specifics =
1303 sync_data.GetSpecifics().search_engine(); 1317 sync_data.GetSpecifics().search_engine();
1304 1318
1305 // Past bugs might have caused either of these fields to be empty. Just 1319 // Past bugs might have caused either of these fields to be empty. Just
1306 // delete this data off the server. 1320 // delete this data off the server.
1307 if (specifics.url().empty() || specifics.sync_guid().empty()) { 1321 if (specifics.url().empty() || specifics.sync_guid().empty()) {
1308 change_list->push_back( 1322 change_list->push_back(
1309 syncer::SyncChange(FROM_HERE, 1323 syncer::SyncChange(FROM_HERE,
1310 syncer::SyncChange::ACTION_DELETE, 1324 syncer::SyncChange::ACTION_DELETE,
1311 sync_data)); 1325 sync_data));
1326 UMA_HISTOGRAM_ENUMERATION(kDeleteSyncedEngineHistogramName,
1327 DELETE_ENGINE_EMPTY_FIELD, DELETE_ENGINE_MAX);
1312 return NULL; 1328 return NULL;
1313 } 1329 }
1314 1330
1315 TemplateURLData data(existing_turl ? 1331 TemplateURLData data(existing_turl ?
1316 existing_turl->data() : TemplateURLData()); 1332 existing_turl->data() : TemplateURLData());
1317 data.short_name = UTF8ToUTF16(specifics.short_name()); 1333 data.short_name = UTF8ToUTF16(specifics.short_name());
1318 data.originating_url = GURL(specifics.originating_url()); 1334 data.originating_url = GURL(specifics.originating_url());
1319 string16 keyword(UTF8ToUTF16(specifics.keyword())); 1335 string16 keyword(UTF8ToUTF16(specifics.keyword()));
1320 // NOTE: Once this code has shipped in a couple of stable releases, we can 1336 // NOTE: Once this code has shipped in a couple of stable releases, we can
1321 // probably remove the migration portion, comment out the 1337 // probably remove the migration portion, comment out the
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 // Extension keywords are not persisted. 2237 // Extension keywords are not persisted.
2222 // TODO(mpcomplete): If we allow editing extension keywords, then those should 2238 // TODO(mpcomplete): If we allow editing extension keywords, then those should
2223 // be persisted to disk and synced. 2239 // be persisted to disk and synced.
2224 if (service_.get() && !template_url->IsExtensionKeyword()) 2240 if (service_.get() && !template_url->IsExtensionKeyword())
2225 service_->RemoveKeyword(template_url->id()); 2241 service_->RemoveKeyword(template_url->id());
2226 2242
2227 // Inform sync of the deletion. 2243 // Inform sync of the deletion.
2228 ProcessTemplateURLChange(FROM_HERE, 2244 ProcessTemplateURLChange(FROM_HERE,
2229 template_url, 2245 template_url,
2230 syncer::SyncChange::ACTION_DELETE); 2246 syncer::SyncChange::ACTION_DELETE);
2247 UMA_HISTOGRAM_ENUMERATION(kDeleteSyncedEngineHistogramName,
2248 DELETE_ENGINE_USER_ACTION, DELETE_ENGINE_MAX);
2231 2249
2232 if (profile_) { 2250 if (profile_) {
2233 content::Source<Profile> source(profile_); 2251 content::Source<Profile> source(profile_);
2234 TemplateURLID id = template_url->id(); 2252 TemplateURLID id = template_url->id();
2235 content::NotificationService::current()->Notify( 2253 content::NotificationService::current()->Notify(
2236 chrome::NOTIFICATION_TEMPLATE_URL_REMOVED, 2254 chrome::NOTIFICATION_TEMPLATE_URL_REMOVED,
2237 source, 2255 source,
2238 content::Details<TemplateURLID>(&id)); 2256 content::Details<TemplateURLID>(&id));
2239 } 2257 }
2240 2258
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
2504 // TODO(mpcomplete): If we allow editing extension keywords, then those 2522 // TODO(mpcomplete): If we allow editing extension keywords, then those
2505 // should be persisted to disk and synced. 2523 // should be persisted to disk and synced.
2506 if (template_url->sync_guid().empty() && 2524 if (template_url->sync_guid().empty() &&
2507 !template_url->IsExtensionKeyword()) { 2525 !template_url->IsExtensionKeyword()) {
2508 template_url->data_.sync_guid = base::GenerateGUID(); 2526 template_url->data_.sync_guid = base::GenerateGUID();
2509 if (service_.get()) 2527 if (service_.get())
2510 service_->UpdateKeyword(template_url->data()); 2528 service_->UpdateKeyword(template_url->data());
2511 } 2529 }
2512 } 2530 }
2513 } 2531 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698