OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // Mock ServerConnectionManager class for use in client regression tests. | 5 // Mock ServerConnectionManager class for use in client regression tests. |
6 | 6 |
7 #include "chrome/test/sync/engine/mock_server_connection.h" | 7 #include "chrome/test/sync/engine/mock_server_connection.h" |
8 | 8 |
9 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 9 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
10 #include "chrome/browser/sync/util/character_set_converters.h" | 10 #include "chrome/browser/sync/util/character_set_converters.h" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 name, version, sync_ts); | 374 name, version, sync_ts); |
375 } | 375 } |
376 | 376 |
377 void MockConnectionManager::AddUpdateExtendedAttributes(SyncEntity* ent, | 377 void MockConnectionManager::AddUpdateExtendedAttributes(SyncEntity* ent, |
378 PathString* xattr_key, syncable::Blob* xattr_value, int xattr_count) { | 378 PathString* xattr_key, syncable::Blob* xattr_value, int xattr_count) { |
379 sync_pb::ExtendedAttributes* mutable_extended_attributes = | 379 sync_pb::ExtendedAttributes* mutable_extended_attributes = |
380 ent->mutable_extended_attributes(); | 380 ent->mutable_extended_attributes(); |
381 for (int i = 0; i < xattr_count; i++) { | 381 for (int i = 0; i < xattr_count; i++) { |
382 sync_pb::ExtendedAttributes_ExtendedAttribute* extended_attribute = | 382 sync_pb::ExtendedAttributes_ExtendedAttribute* extended_attribute = |
383 mutable_extended_attributes->add_extendedattribute(); | 383 mutable_extended_attributes->add_extendedattribute(); |
384 extended_attribute->set_key(static_cast<const string&> | 384 extended_attribute->set_key(xattr_key[i]); |
385 (browser_sync::ToUTF8(xattr_key[i]))); | |
386 SyncerProtoUtil::CopyBlobIntoProtoBytes(xattr_value[i], | 385 SyncerProtoUtil::CopyBlobIntoProtoBytes(xattr_value[i], |
387 extended_attribute->mutable_value()); | 386 extended_attribute->mutable_value()); |
388 } | 387 } |
389 } | 388 } |
390 | 389 |
391 SyncEntity* MockConnectionManager::GetMutableLastUpdate() { | 390 SyncEntity* MockConnectionManager::GetMutableLastUpdate() { |
392 DCHECK(updates_.entries_size() > 0); | 391 DCHECK(updates_.entries_size() > 0); |
393 return updates_.mutable_entries()->Mutable(updates_.entries_size() - 1); | 392 return updates_.mutable_entries()->Mutable(updates_.entries_size() - 1); |
394 } | 393 } |
395 | 394 |
396 const CommitMessage& MockConnectionManager::last_sent_commit() const { | 395 const CommitMessage& MockConnectionManager::last_sent_commit() const { |
397 DCHECK(!commit_messages_.empty()); | 396 DCHECK(!commit_messages_.empty()); |
398 return *commit_messages_.back(); | 397 return *commit_messages_.back(); |
399 } | 398 } |
400 | 399 |
401 void MockConnectionManager::ThrottleNextRequest( | 400 void MockConnectionManager::ThrottleNextRequest( |
402 ThrottleRequestVisitor* visitor) { | 401 ThrottleRequestVisitor* visitor) { |
403 AutoLock lock(throttle_lock_); | 402 AutoLock lock(throttle_lock_); |
404 throttling_ = true; | 403 throttling_ = true; |
405 if (visitor) | 404 if (visitor) |
406 visitor->VisitAtomically(); | 405 visitor->VisitAtomically(); |
407 } | 406 } |
408 | 407 |
OLD | NEW |