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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/gdata/fake_gdata_contacts_service.cc
diff --git a/chrome/browser/chromeos/gdata/fake_gdata_contacts_service.cc b/chrome/browser/chromeos/gdata/fake_gdata_contacts_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fe65cff2d54b69c8b0a12e113c7f6afd62424682
--- /dev/null
+++ b/chrome/browser/chromeos/gdata/fake_gdata_contacts_service.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/gdata/fake_gdata_contacts_service.h"
+
+#include <vector>
+
+#include "base/time.h"
+#include "chrome/browser/chromeos/contacts/contact.h"
+#include "chrome/browser/chromeos/contacts/contact_test_util.h"
+#include "chrome/browser/chromeos/gdata/gdata_util.h"
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
+
+namespace gdata {
+
+FakeGDataContactsService::FakeGDataContactsService()
+ : download_should_succeed_(true) {
+}
+
+FakeGDataContactsService::~FakeGDataContactsService() {
+}
+
+void FakeGDataContactsService::SetContacts(
+ const contacts::ContactPointers& contacts,
+ const base::Time& expected_min_update_time) {
+ contacts::test::CopyContacts(contacts, &contacts_);
+ expected_min_update_time_ = expected_min_update_time;
+}
+
+void FakeGDataContactsService::Initialize() {
+}
+
+void FakeGDataContactsService::DownloadContacts(
+ SuccessCallback success_callback,
+ FailureCallback failure_callback,
+ const base::Time& min_update_time) {
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (!download_should_succeed_) {
+ failure_callback.Run();
+ return;
+ }
+
+ if (min_update_time != expected_min_update_time_) {
+ LOG(ERROR) << "Actual minimum update time ("
+ << util::FormatTimeAsString(min_update_time) << ") "
+ << "differed from expected ("
+ << util::FormatTimeAsString(expected_min_update_time_)
+ << "); not returning any contacts";
+ failure_callback.Run();
+ return;
+ }
+
+ scoped_ptr<ScopedVector<contacts::Contact> > contacts(
+ new ScopedVector<contacts::Contact>());
+ contacts::test::CopyContacts(contacts_, contacts.get());
+ success_callback.Run(contacts.Pass());
+}
+
+} // namespace contacts

Powered by Google App Engine
This is Rietveld 408576698