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

Side by Side Diff: chrome/browser/sync/glue/autofill_profile_model_associator.cc

Issue 6534013: [Sync] Set logging that may contain personal information to verbosity level 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 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
« no previous file with comments | « chrome/browser/sync/glue/autofill_model_associator.cc ('k') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/sync/glue/autofill_profile_model_associator.h" 5 #include "chrome/browser/sync/glue/autofill_profile_model_associator.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/sync/glue/autofill_profile_change_processor.h" 8 #include "chrome/browser/sync/glue/autofill_profile_change_processor.h"
9 #include "chrome/browser/sync/glue/do_optimistic_refresh_task.h" 9 #include "chrome/browser/sync/glue/do_optimistic_refresh_task.h"
10 #include "chrome/browser/sync/profile_sync_service.h" 10 #include "chrome/browser/sync/profile_sync_service.h"
(...skipping 28 matching lines...) Expand all
39 39
40 bool AutofillProfileModelAssociator::TraverseAndAssociateChromeAutoFillProfiles( 40 bool AutofillProfileModelAssociator::TraverseAndAssociateChromeAutoFillProfiles(
41 sync_api::WriteTransaction* write_trans, 41 sync_api::WriteTransaction* write_trans,
42 const sync_api::ReadNode& autofill_root, 42 const sync_api::ReadNode& autofill_root,
43 const std::vector<AutoFillProfile*>& all_profiles_from_db, 43 const std::vector<AutoFillProfile*>& all_profiles_from_db,
44 std::set<std::string>* current_profiles, 44 std::set<std::string>* current_profiles,
45 std::vector<AutoFillProfile*>* updated_profiles, 45 std::vector<AutoFillProfile*>* updated_profiles,
46 std::vector<AutoFillProfile*>* new_profiles, 46 std::vector<AutoFillProfile*>* new_profiles,
47 std::vector<std::string>* profiles_to_delete) { 47 std::vector<std::string>* profiles_to_delete) {
48 48
49 if (VLOG_IS_ON(1)) { 49 if (VLOG_IS_ON(2)) {
50 VLOG(1) << "[AUTOFILL MIGRATION]" 50 VLOG(2) << "[AUTOFILL MIGRATION]"
51 << "Printing profiles from web db"; 51 << "Printing profiles from web db";
52 52
53 for (std::vector<AutoFillProfile*>::const_iterator ix = 53 for (std::vector<AutoFillProfile*>::const_iterator ix =
54 all_profiles_from_db.begin(); ix != all_profiles_from_db.end(); ++ix) { 54 all_profiles_from_db.begin(); ix != all_profiles_from_db.end(); ++ix) {
55 AutoFillProfile* p = *ix; 55 AutoFillProfile* p = *ix;
56 VLOG(1) << "[AUTOFILL MIGRATION] " 56 VLOG(2) << "[AUTOFILL MIGRATION] "
57 << p->GetFieldText(AutoFillType(NAME_FIRST)) 57 << p->GetFieldText(AutoFillType(NAME_FIRST))
58 << p->GetFieldText(AutoFillType(NAME_LAST)) 58 << p->GetFieldText(AutoFillType(NAME_LAST))
59 << p->guid(); 59 << p->guid();
60 } 60 }
61 } 61 }
62 62
63 VLOG(1) << "[AUTOFILL MIGRATION]" 63 VLOG(1) << "[AUTOFILL MIGRATION]"
64 << "Looking for the above data in sync db.."; 64 << "Looking for the above data in sync db..";
65 65
66 // Alias the all_profiles_from_db so we fit in 80 characters 66 // Alias the all_profiles_from_db so we fit in 80 characters
67 const std::vector<AutoFillProfile*>& profiles(all_profiles_from_db); 67 const std::vector<AutoFillProfile*>& profiles(all_profiles_from_db);
68 for (std::vector<AutoFillProfile*>::const_iterator ix = profiles.begin(); 68 for (std::vector<AutoFillProfile*>::const_iterator ix = profiles.begin();
69 ix != profiles.end(); 69 ix != profiles.end();
70 ++ix) { 70 ++ix) {
71 std::string guid((*ix)->guid()); 71 std::string guid((*ix)->guid());
72 72
73 ReadNode node(write_trans); 73 ReadNode node(write_trans);
74 if (node.InitByClientTagLookup(syncable::AUTOFILL_PROFILE, guid) && 74 if (node.InitByClientTagLookup(syncable::AUTOFILL_PROFILE, guid) &&
75 // The following check is to ensure the given sync node is not already 75 // The following check is to ensure the given sync node is not already
76 // associated with another profile. That could happen if the user has 76 // associated with another profile. That could happen if the user has
77 // the same profile duplicated. 77 // the same profile duplicated.
78 current_profiles->find(guid) == current_profiles->end()) { 78 current_profiles->find(guid) == current_profiles->end()) {
79 79
80 VLOG(1) << "[AUTOFILL MIGRATION]" 80 VLOG(2) << "[AUTOFILL MIGRATION]"
81 << " Found in sync db: " 81 << " Found in sync db: "
82 << (*ix)->GetFieldText(AutoFillType(NAME_FIRST)) 82 << (*ix)->GetFieldText(AutoFillType(NAME_FIRST))
83 << (*ix)->GetFieldText(AutoFillType(NAME_LAST)) 83 << (*ix)->GetFieldText(AutoFillType(NAME_LAST))
84 << (*ix)->guid() 84 << (*ix)->guid()
85 << " so associating with node id " << node.GetId(); 85 << " so associating with node id " << node.GetId();
86 const sync_pb::AutofillProfileSpecifics& autofill( 86 const sync_pb::AutofillProfileSpecifics& autofill(
87 node.GetAutofillProfileSpecifics()); 87 node.GetAutofillProfileSpecifics());
88 if (OverwriteProfileWithServerData(*ix, autofill)) { 88 if (OverwriteProfileWithServerData(*ix, autofill)) {
89 updated_profiles->push_back(*ix); 89 updated_profiles->push_back(*ix);
90 } 90 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 return false; 297 return false;
298 } 298 }
299 const sync_pb::AutofillProfileSpecifics& autofill_specifics( 299 const sync_pb::AutofillProfileSpecifics& autofill_specifics(
300 read_node.GetAutofillProfileSpecifics()); 300 read_node.GetAutofillProfileSpecifics());
301 AutoFillProfile* p = new AutoFillProfile(autofill_specifics.guid()); 301 AutoFillProfile* p = new AutoFillProfile(autofill_specifics.guid());
302 OverwriteProfileWithServerData(p, autofill_specifics); 302 OverwriteProfileWithServerData(p, autofill_specifics);
303 new_profiles->push_back(p); 303 new_profiles->push_back(p);
304 std::string guid = autofill_specifics.guid(); 304 std::string guid = autofill_specifics.guid();
305 Associate(&guid, sync_node_id); 305 Associate(&guid, sync_node_id);
306 current_profiles->insert(autofill_specifics.guid()); 306 current_profiles->insert(autofill_specifics.guid());
307 VLOG(1) << "[AUTOFILL MIGRATION]" 307 VLOG(2) << "[AUTOFILL MIGRATION]"
308 << "Found in sync db but with a different guid: " 308 << "Found in sync db but with a different guid: "
309 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(NAME_FIRST))) 309 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(NAME_FIRST)))
310 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(NAME_LAST))) 310 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(NAME_LAST)))
311 << "New guid " << autofill_specifics.guid() << " sync node id " 311 << "New guid " << autofill_specifics.guid() << " sync node id "
312 << sync_node_id << " so associating. Profile to be deleted " 312 << sync_node_id << " so associating. Profile to be deleted "
313 << profile.guid(); 313 << profile.guid();
314 } else { 314 } else {
315 sync_api::WriteNode node(trans); 315 sync_api::WriteNode node(trans);
316 if (!node.InitUniqueByCreation( 316 if (!node.InitUniqueByCreation(
317 syncable::AUTOFILL_PROFILE, autofill_root, profile.guid())) { 317 syncable::AUTOFILL_PROFILE, autofill_root, profile.guid())) {
318 LOG(ERROR) << "Failed to create autofill sync node."; 318 LOG(ERROR) << "Failed to create autofill sync node.";
319 return false; 319 return false;
320 } 320 }
321 node.SetTitle(UTF8ToWide(profile.guid())); 321 node.SetTitle(UTF8ToWide(profile.guid()));
322 VLOG(1) << "[AUTOFILL MIGRATION]" 322 VLOG(2) << "[AUTOFILL MIGRATION]"
323 << "NOT Found in sync db " 323 << "NOT Found in sync db "
324 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(NAME_FIRST))) 324 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(NAME_FIRST)))
325 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(NAME_LAST))) 325 << UTF16ToUTF8(profile.GetFieldText(AutoFillType(NAME_LAST)))
326 << profile.guid() 326 << profile.guid()
327 << " so creating a new sync node. Sync node id " 327 << " so creating a new sync node. Sync node id "
328 << node.GetId(); 328 << node.GetId();
329 AutofillProfileChangeProcessor::WriteAutofillProfile(profile, &node); 329 AutofillProfileChangeProcessor::WriteAutofillProfile(profile, &node);
330 current_profiles->insert(profile.guid()); 330 current_profiles->insert(profile.guid());
331 std::string guid = profile.guid(); 331 std::string guid = profile.guid();
332 Associate(&guid, node.GetId()); 332 Associate(&guid, node.GetId());
(...skipping 27 matching lines...) Expand all
360 } 360 }
361 return true; 361 return true;
362 } 362 }
363 363
364 void AutofillProfileModelAssociator::AddNativeProfileIfNeeded( 364 void AutofillProfileModelAssociator::AddNativeProfileIfNeeded(
365 const sync_pb::AutofillProfileSpecifics& profile, 365 const sync_pb::AutofillProfileSpecifics& profile,
366 DataBundle* bundle, 366 DataBundle* bundle,
367 const sync_api::ReadNode& node) { 367 const sync_api::ReadNode& node) {
368 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 368 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
369 369
370 VLOG(1) << "[AUTOFILL MIGRATION] " 370 VLOG(2) << "[AUTOFILL MIGRATION] "
371 << "Trying to lookup " 371 << "Trying to lookup "
372 << profile.name_first() 372 << profile.name_first()
373 << " " 373 << " "
374 << profile.name_last() 374 << profile.name_last()
375 << "sync node id " << node.GetId() 375 << "sync node id " << node.GetId()
376 << " Guid " << profile.guid() 376 << " Guid " << profile.guid()
377 << " in the web db"; 377 << " in the web db";
378 378
379 if (bundle->current_profiles.find(profile.guid()) == 379 if (bundle->current_profiles.find(profile.guid()) ==
380 bundle->current_profiles.end()) { 380 bundle->current_profiles.end()) {
381 std::string guid(profile.guid()); 381 std::string guid(profile.guid());
382 Associate(&guid, node.GetId()); 382 Associate(&guid, node.GetId());
383 AutoFillProfile* p = new AutoFillProfile(profile.guid()); 383 AutoFillProfile* p = new AutoFillProfile(profile.guid());
384 OverwriteProfileWithServerData(p, profile); 384 OverwriteProfileWithServerData(p, profile);
385 bundle->new_profiles.push_back(p); 385 bundle->new_profiles.push_back(p);
386 VLOG(1) << "[AUTOFILL MIGRATION] " 386 VLOG(2) << "[AUTOFILL MIGRATION] "
387 << " Did not find one so creating it on web db"; 387 << " Did not find one so creating it on web db";
388 } else { 388 } else {
389 VLOG(1) << "[AUTOFILL MIGRATION] " 389 VLOG(2) << "[AUTOFILL MIGRATION] "
390 << " Found it on web db. Moving on "; 390 << " Found it on web db. Moving on ";
391 } 391 }
392 } 392 }
393 393
394 bool AutofillProfileModelAssociator::SaveChangesToWebData( 394 bool AutofillProfileModelAssociator::SaveChangesToWebData(
395 const DataBundle& bundle) { 395 const DataBundle& bundle) {
396 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 396 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
397 397
398 if (IsAbortPending()) 398 if (IsAbortPending())
399 return false; 399 return false;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 472
473 AutofillProfileModelAssociator::DataBundle::DataBundle() {} 473 AutofillProfileModelAssociator::DataBundle::DataBundle() {}
474 474
475 AutofillProfileModelAssociator::DataBundle::~DataBundle() { 475 AutofillProfileModelAssociator::DataBundle::~DataBundle() {
476 STLDeleteElements(&new_profiles); 476 STLDeleteElements(&new_profiles);
477 } 477 }
478 478
479 479
480 } // namespace browser_sync 480 } // namespace browser_sync
481 481
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/autofill_model_associator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698