Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/webdata/autocomplete_syncable_service.h" | 5 #include "chrome/browser/webdata/autocomplete_syncable_service.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/webdata/autofill_table.h" | 12 #include "chrome/browser/webdata/autofill_table.h" |
| 13 #include "chrome/browser/webdata/web_data_service.h" | 13 #include "chrome/browser/webdata/web_data_service.h" |
| 14 #include "chrome/browser/webdata/web_database.h" | 14 #include "chrome/browser/webdata/web_database.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "chrome/common/chrome_version_info.h" | |
| 16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 18 #include "net/base/escape.h" | 19 #include "net/base/escape.h" |
| 19 #include "sync/api/sync_error.h" | 20 #include "sync/api/sync_error.h" |
| 20 #include "sync/api/sync_error_factory.h" | 21 #include "sync/api/sync_error_factory.h" |
| 21 #include "sync/protocol/autofill_specifics.pb.h" | 22 #include "sync/protocol/autofill_specifics.pb.h" |
| 22 #include "sync/protocol/sync.pb.h" | 23 #include "sync/protocol/sync.pb.h" |
| 23 | 24 |
| 24 using content::BrowserThread; | 25 using content::BrowserThread; |
| 25 | 26 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 } else { | 75 } else { |
| 75 new_timestamps->insert(new_timestamps->begin(), | 76 new_timestamps->insert(new_timestamps->begin(), |
| 76 timestamps.begin(), | 77 timestamps.begin(), |
| 77 timestamps.end()); | 78 timestamps.end()); |
| 78 return false; | 79 return false; |
| 79 } | 80 } |
| 80 } | 81 } |
| 81 } | 82 } |
| 82 | 83 |
| 83 bool ShouldCullSyncedData() { | 84 bool ShouldCullSyncedData() { |
| 85 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | |
| 86 | |
| 84 // To set probability to 10% - set it to 0.1, 5% to 0.05, etc. | 87 // To set probability to 10% - set it to 0.1, 5% to 0.05, etc. |
| 85 static double kCullingProbability = 0.0; | 88 double culling_probability; |
|
tim (not reviewing)
2012/11/02 17:46:11
It's best to initialize (to 0, I suppose).
Ilya Sherman
2012/11/02 23:12:34
Done.
| |
| 86 return (base::RandDouble() < kCullingProbability); | 89 if (channel == chrome::VersionInfo::CHANNEL_CANARY) |
| 90 culling_probability = 1.0; | |
| 91 else if (channel == chrome::VersionInfo::CHANNEL_DEV) | |
| 92 culling_probability = 0.2; | |
| 93 else | |
| 94 culling_probability = 0.0; | |
| 95 | |
| 96 return (base::RandDouble() < culling_probability); | |
| 87 } | 97 } |
| 88 | 98 |
| 89 } // namespace | 99 } // namespace |
| 90 | 100 |
| 91 AutocompleteSyncableService::AutocompleteSyncableService( | 101 AutocompleteSyncableService::AutocompleteSyncableService( |
| 92 WebDataService* web_data_service) | 102 WebDataService* web_data_service) |
| 93 : web_data_service_(web_data_service) { | 103 : web_data_service_(web_data_service) { |
| 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 95 DCHECK(web_data_service_); | 105 DCHECK(web_data_service_); |
| 96 notification_registrar_.Add( | 106 notification_registrar_.Add( |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 UTF16ToUTF8(entry.key().value()))); | 462 UTF16ToUTF8(entry.key().value()))); |
| 453 return syncer::SyncData::CreateLocalData(tag, tag, autofill_specifics); | 463 return syncer::SyncData::CreateLocalData(tag, tag, autofill_specifics); |
| 454 } | 464 } |
| 455 | 465 |
| 456 // static | 466 // static |
| 457 std::string AutocompleteSyncableService::KeyToTag(const std::string& name, | 467 std::string AutocompleteSyncableService::KeyToTag(const std::string& name, |
| 458 const std::string& value) { | 468 const std::string& value) { |
| 459 std::string ns(kAutofillEntryNamespaceTag); | 469 std::string ns(kAutofillEntryNamespaceTag); |
| 460 return ns + net::EscapePath(name) + "|" + net::EscapePath(value); | 470 return ns + net::EscapePath(name) + "|" + net::EscapePath(value); |
| 461 } | 471 } |
| OLD | NEW |