OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/contacts/fake_contact_database.h" |
| 6 |
| 7 #include "chrome/browser/chromeos/contacts/contact.h" |
| 8 #include "chrome/browser/chromeos/contacts/contact_test_lib.h" |
| 9 |
| 10 namespace contacts { |
| 11 |
| 12 FakeContactDatabase::FakeContactDatabase() |
| 13 : init_success_(true), |
| 14 save_success_(true), |
| 15 load_success_(true) { |
| 16 } |
| 17 |
| 18 FakeContactDatabase::~FakeContactDatabase() { |
| 19 } |
| 20 |
| 21 void FakeContactDatabase::Init(const FilePath& database_path, |
| 22 InitCallback callback) { |
| 23 callback.Run(init_success_); |
| 24 } |
| 25 |
| 26 void FakeContactDatabase::SetContacts(const ContactPointers& contacts) { |
| 27 test::CopyContacts(contacts, &contacts_); |
| 28 } |
| 29 |
| 30 void FakeContactDatabase::SaveContacts(scoped_ptr<ContactPointers> contacts, |
| 31 bool is_full_update, |
| 32 SaveCallback callback) { |
| 33 if (save_success_) |
| 34 test::CopyContacts(*contacts, &contacts_); |
| 35 callback.Run(save_success_); |
| 36 } |
| 37 |
| 38 void FakeContactDatabase::LoadContacts(LoadCallback callback) { |
| 39 scoped_ptr<ScopedVector<Contact> > contacts(new ScopedVector<Contact>()); |
| 40 if (load_success_) |
| 41 test::CopyContacts(contacts_, contacts.get()); |
| 42 callback.Run(load_success_, contacts.Pass()); |
| 43 } |
| 44 |
| 45 } // namespace contacts |
OLD | NEW |