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/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 |
OLD | NEW |