OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sync/test/fake_server/fake_server.h" | 5 #include "sync/test/fake_server/fake_server.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 const sync_pb::EntitySpecifics& updated_specifics) { | 549 const sync_pb::EntitySpecifics& updated_specifics) { |
550 EntityMap::const_iterator iter = entities_.find(id); | 550 EntityMap::const_iterator iter = entities_.find(id); |
551 if (iter == entities_.end() || | 551 if (iter == entities_.end() || |
552 iter->second->GetModelType() != | 552 iter->second->GetModelType() != |
553 GetModelTypeFromSpecifics(updated_specifics)) { | 553 GetModelTypeFromSpecifics(updated_specifics)) { |
554 return false; | 554 return false; |
555 } | 555 } |
556 | 556 |
557 scoped_ptr<FakeServerEntity> entity = entities_.take_and_erase(iter); | 557 scoped_ptr<FakeServerEntity> entity = entities_.take_and_erase(iter); |
558 entity->SetSpecifics(updated_specifics); | 558 entity->SetSpecifics(updated_specifics); |
| 559 UpdateEntityVersion(entity.get()); |
| 560 entities_.insert(id, entity.Pass()); |
| 561 return true; |
| 562 } |
| 563 |
| 564 bool FakeServer::ModifyBookmarkEntity( |
| 565 const std::string& id, |
| 566 const std::string& parent_id, |
| 567 const sync_pb::EntitySpecifics& updated_specifics) { |
| 568 EntityMap::const_iterator iter = entities_.find(id); |
| 569 if (iter == entities_.end() || |
| 570 iter->second->GetModelType() != syncer::BOOKMARKS || |
| 571 GetModelTypeFromSpecifics(updated_specifics) != syncer::BOOKMARKS) { |
| 572 return false; |
| 573 } |
| 574 |
| 575 scoped_ptr<BookmarkEntity> entity( |
| 576 static_cast<BookmarkEntity*>(entities_.take_and_erase(iter).release())); |
| 577 |
| 578 entity->SetParentId(parent_id); |
| 579 entity->SetSpecifics(updated_specifics); |
559 if (updated_specifics.has_bookmark()) { | 580 if (updated_specifics.has_bookmark()) { |
560 entity->SetName(updated_specifics.bookmark().title()); | 581 entity->SetName(updated_specifics.bookmark().title()); |
561 } | 582 } |
562 UpdateEntityVersion(entity.get()); | 583 UpdateEntityVersion(entity.get()); |
563 entities_.insert(id, entity.Pass()); | 584 entities_.insert(id, entity.Pass()); |
564 return true; | 585 return true; |
565 } | 586 } |
566 | 587 |
567 void FakeServer::ClearServerData() { | 588 void FakeServer::ClearServerData() { |
568 DCHECK(thread_checker_.CalledOnValidThread()); | 589 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 DCHECK(thread_checker_.CalledOnValidThread()); | 696 DCHECK(thread_checker_.CalledOnValidThread()); |
676 return weak_ptr_factory_.GetWeakPtr(); | 697 return weak_ptr_factory_.GetWeakPtr(); |
677 } | 698 } |
678 | 699 |
679 std::string FakeServer::GetStoreBirthday() const { | 700 std::string FakeServer::GetStoreBirthday() const { |
680 DCHECK(thread_checker_.CalledOnValidThread()); | 701 DCHECK(thread_checker_.CalledOnValidThread()); |
681 return base::Int64ToString(store_birthday_); | 702 return base::Int64ToString(store_birthday_); |
682 } | 703 } |
683 | 704 |
684 } // namespace fake_server | 705 } // namespace fake_server |
OLD | NEW |