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

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

Issue 6375007: [Sync] Refactored ProfileSyncService and remove its backend() function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comment Created 9 years, 11 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) 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/password_model_associator.h" 5 #include "chrome/browser/sync/glue/password_model_associator.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 27 matching lines...) Expand all
38 38
39 PasswordModelAssociator::~PasswordModelAssociator() {} 39 PasswordModelAssociator::~PasswordModelAssociator() {}
40 40
41 bool PasswordModelAssociator::AssociateModels() { 41 bool PasswordModelAssociator::AssociateModels() {
42 DCHECK(expected_loop_ == MessageLoop::current()); 42 DCHECK(expected_loop_ == MessageLoop::current());
43 { 43 {
44 base::AutoLock lock(abort_association_pending_lock_); 44 base::AutoLock lock(abort_association_pending_lock_);
45 abort_association_pending_ = false; 45 abort_association_pending_ = false;
46 } 46 }
47 47
48 sync_api::WriteTransaction trans( 48 sync_api::WriteTransaction trans(sync_service_->GetUserShare());
49 sync_service_->backend()->GetUserShareHandle());
50 sync_api::ReadNode password_root(&trans); 49 sync_api::ReadNode password_root(&trans);
51 if (!password_root.InitByTagLookup(kPasswordTag)) { 50 if (!password_root.InitByTagLookup(kPasswordTag)) {
52 LOG(ERROR) << "Server did not create the top-level password node. We " 51 LOG(ERROR) << "Server did not create the top-level password node. We "
53 << "might be running against an out-of-date server."; 52 << "might be running against an out-of-date server.";
54 return false; 53 return false;
55 } 54 }
56 55
57 std::vector<webkit_glue::PasswordForm*> passwords; 56 std::vector<webkit_glue::PasswordForm*> passwords;
58 if (!password_store_->FillAutofillableLogins(&passwords) || 57 if (!password_store_->FillAutofillableLogins(&passwords) ||
59 !password_store_->FillBlacklistLogins(&passwords)) { 58 !password_store_->FillBlacklistLogins(&passwords)) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 168
170 bool PasswordModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) { 169 bool PasswordModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) {
171 DCHECK(has_nodes); 170 DCHECK(has_nodes);
172 *has_nodes = false; 171 *has_nodes = false;
173 int64 password_sync_id; 172 int64 password_sync_id;
174 if (!GetSyncIdForTaggedNode(kPasswordTag, &password_sync_id)) { 173 if (!GetSyncIdForTaggedNode(kPasswordTag, &password_sync_id)) {
175 LOG(ERROR) << "Server did not create the top-level password node. We " 174 LOG(ERROR) << "Server did not create the top-level password node. We "
176 << "might be running against an out-of-date server."; 175 << "might be running against an out-of-date server.";
177 return false; 176 return false;
178 } 177 }
179 sync_api::ReadTransaction trans( 178 sync_api::ReadTransaction trans(sync_service_->GetUserShare());
180 sync_service_->backend()->GetUserShareHandle());
181 179
182 sync_api::ReadNode password_node(&trans); 180 sync_api::ReadNode password_node(&trans);
183 if (!password_node.InitByIdLookup(password_sync_id)) { 181 if (!password_node.InitByIdLookup(password_sync_id)) {
184 LOG(ERROR) << "Server did not create the top-level password node. We " 182 LOG(ERROR) << "Server did not create the top-level password node. We "
185 << "might be running against an out-of-date server."; 183 << "might be running against an out-of-date server.";
186 return false; 184 return false;
187 } 185 }
188 186
189 // The sync model has user created nodes if the password folder has any 187 // The sync model has user created nodes if the password folder has any
190 // children. 188 // children.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 DCHECK(expected_loop_ == MessageLoop::current()); 232 DCHECK(expected_loop_ == MessageLoop::current());
235 SyncIdToPasswordMap::iterator iter = id_map_inverse_.find(sync_id); 233 SyncIdToPasswordMap::iterator iter = id_map_inverse_.find(sync_id);
236 if (iter == id_map_inverse_.end()) 234 if (iter == id_map_inverse_.end())
237 return; 235 return;
238 CHECK(id_map_.erase(iter->second)); 236 CHECK(id_map_.erase(iter->second));
239 id_map_inverse_.erase(iter); 237 id_map_inverse_.erase(iter);
240 } 238 }
241 239
242 bool PasswordModelAssociator::GetSyncIdForTaggedNode(const std::string& tag, 240 bool PasswordModelAssociator::GetSyncIdForTaggedNode(const std::string& tag,
243 int64* sync_id) { 241 int64* sync_id) {
244 sync_api::ReadTransaction trans( 242 sync_api::ReadTransaction trans(sync_service_->GetUserShare());
245 sync_service_->backend()->GetUserShareHandle());
246 sync_api::ReadNode sync_node(&trans); 243 sync_api::ReadNode sync_node(&trans);
247 if (!sync_node.InitByTagLookup(tag.c_str())) 244 if (!sync_node.InitByTagLookup(tag.c_str()))
248 return false; 245 return false;
249 *sync_id = sync_node.GetId(); 246 *sync_id = sync_node.GetId();
250 return true; 247 return true;
251 } 248 }
252 249
253 bool PasswordModelAssociator::WriteToPasswordStore( 250 bool PasswordModelAssociator::WriteToPasswordStore(
254 const PasswordVector* new_passwords, 251 const PasswordVector* new_passwords,
255 const PasswordVector* updated_passwords, 252 const PasswordVector* updated_passwords,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 const std::string& password_element, 385 const std::string& password_element,
389 const std::string& signon_realm) { 386 const std::string& signon_realm) {
390 return EscapePath(origin_url) + "|" + 387 return EscapePath(origin_url) + "|" +
391 EscapePath(username_element) + "|" + 388 EscapePath(username_element) + "|" +
392 EscapePath(username_value) + "|" + 389 EscapePath(username_value) + "|" +
393 EscapePath(password_element) + "|" + 390 EscapePath(password_element) + "|" +
394 EscapePath(signon_realm); 391 EscapePath(signon_realm);
395 } 392 }
396 393
397 } // namespace browser_sync 394 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/password_model_associator.h ('k') | chrome/browser/sync/glue/preference_model_associator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698