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

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

Issue 10823080: contacts: Add GDataContactsServiceStub. (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/gdata/gdata_contacts_service_stub.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/gdata/gdata_contacts_service_stub.h"
6
7 #include "chrome/browser/chromeos/contacts/contact.pb.h"
8 #include "chrome/browser/chromeos/contacts/contact_test_util.h"
9 #include "chrome/browser/chromeos/gdata/gdata_util.h"
10 #include "content/public/browser/browser_thread.h"
11
12 using content::BrowserThread;
13
14 namespace gdata {
15
16 GDataContactsServiceStub::GDataContactsServiceStub()
17 : download_should_succeed_(true) {
18 }
19
20 GDataContactsServiceStub::~GDataContactsServiceStub() {
21 }
22
23 void GDataContactsServiceStub::SetContacts(
24 const contacts::ContactPointers& contacts,
25 const base::Time& expected_min_update_time) {
26 contacts::test::CopyContacts(contacts, &contacts_);
27 expected_min_update_time_ = expected_min_update_time;
28 }
29
30 void GDataContactsServiceStub::Initialize() {
31 }
32
33 void GDataContactsServiceStub::DownloadContacts(
34 SuccessCallback success_callback,
35 FailureCallback failure_callback,
36 const base::Time& min_update_time) {
37 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
38
39 if (!download_should_succeed_) {
40 failure_callback.Run();
41 return;
42 }
43
44 if (min_update_time != expected_min_update_time_) {
45 LOG(ERROR) << "Actual minimum update time ("
46 << util::FormatTimeAsString(min_update_time) << ") "
47 << "differed from expected ("
48 << util::FormatTimeAsString(expected_min_update_time_)
49 << "); not returning any contacts";
50 failure_callback.Run();
51 return;
52 }
53
54 scoped_ptr<ScopedVector<contacts::Contact> > contacts(
55 new ScopedVector<contacts::Contact>());
56 contacts::test::CopyContacts(contacts_, contacts.get());
57 success_callback.Run(contacts.Pass());
58 }
59
60 } // namespace contacts
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_contacts_service_stub.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698