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

Side by Side Diff: chrome/browser/chromeos/contacts/fake_contact_database.cc

Issue 10829117: contacts: Add FakeContactDatabase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 4 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
« no previous file with comments | « chrome/browser/chromeos/contacts/fake_contact_database.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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.pb.h"
8 #include "chrome/browser/chromeos/contacts/contact_test_util.h"
9 #include "content/public/browser/browser_thread.h"
10
11 using content::BrowserThread;
12
13 namespace contacts {
14
15 FakeContactDatabase::FakeContactDatabase()
16 : init_success_(true),
17 save_success_(true),
18 load_success_(true) {
19 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
20 }
21
22 void FakeContactDatabase::Init(const FilePath& database_dir,
23 InitCallback callback) {
24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
25 callback.Run(init_success_);
26 }
27
28 void FakeContactDatabase::SetContacts(const ContactPointers& contacts,
29 const UpdateMetadata& metadata) {
30 test::CopyContacts(contacts, &contacts_);
31 metadata_ = metadata;
32 }
33
34 void FakeContactDatabase::DestroyOnUIThread() {
35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
36 delete this;
37 }
38
39 void FakeContactDatabase::SaveContacts(scoped_ptr<ContactPointers> contacts,
40 scoped_ptr<UpdateMetadata> metadata,
41 bool is_full_update,
42 SaveCallback callback) {
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
44 if (save_success_) {
45 test::CopyContacts(*contacts, &contacts_);
46 metadata_ = *metadata;
47 }
48 callback.Run(save_success_);
49 }
50
51 void FakeContactDatabase::LoadContacts(LoadCallback callback) {
52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
53 scoped_ptr<ScopedVector<Contact> > contacts(new ScopedVector<Contact>());
54 scoped_ptr<UpdateMetadata> metadata(new UpdateMetadata);
55 if (load_success_) {
56 test::CopyContacts(contacts_, contacts.get());
57 *metadata = metadata_;
58 }
59 callback.Run(load_success_, contacts.Pass(), metadata.Pass());
60 }
61
62 FakeContactDatabase::~FakeContactDatabase() {
63 }
64
65 } // namespace contacts
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/contacts/fake_contact_database.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698