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

Side by Side Diff: chrome/browser/chromeos/gdata/fake_gdata_contacts_service.cc

Issue 10818017: contacts: Add GDataContactsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor cleanup 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
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/gdata/fake_gdata_contacts_service.h"
6
7 #include <vector>
8
9 #include "base/time.h"
10 #include "chrome/browser/chromeos/contacts/contact.h"
11 #include "chrome/browser/chromeos/contacts/contact_test_util.h"
12 #include "chrome/browser/chromeos/gdata/gdata_util.h"
13 #include "content/public/browser/browser_thread.h"
14
15 using content::BrowserThread;
16
17 namespace gdata {
18
19 FakeGDataContactsService::FakeGDataContactsService()
20 : download_should_succeed_(true) {
21 }
22
23 FakeGDataContactsService::~FakeGDataContactsService() {
24 }
25
26 void FakeGDataContactsService::SetContacts(
27 const contacts::ContactPointers& contacts,
28 const base::Time& expected_min_update_time) {
29 contacts::test::CopyContacts(contacts, &contacts_);
30 expected_min_update_time_ = expected_min_update_time;
31 }
32
33 void FakeGDataContactsService::Initialize() {
34 }
35
36 void FakeGDataContactsService::DownloadContacts(
37 SuccessCallback success_callback,
38 FailureCallback failure_callback,
39 const base::Time& min_update_time) {
40 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
41
42 if (!download_should_succeed_) {
43 failure_callback.Run();
44 return;
45 }
46
47 if (min_update_time != expected_min_update_time_) {
48 LOG(ERROR) << "Actual minimum update time ("
49 << util::FormatTimeAsString(min_update_time) << ") "
50 << "differed from expected ("
51 << util::FormatTimeAsString(expected_min_update_time_)
52 << "); not returning any contacts";
53 failure_callback.Run();
54 return;
55 }
56
57 scoped_ptr<ScopedVector<contacts::Contact> > contacts(
58 new ScopedVector<contacts::Contact>());
59 contacts::test::CopyContacts(contacts_, contacts.get());
60 success_callback.Run(contacts.Pass());
61 }
62
63 } // namespace contacts
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698