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

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

Issue 10829247: contacts: Defer updates when offline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_STUB_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_STUB_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_STUB_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_STUB_H_
7 7
8 #include "chrome/browser/chromeos/gdata/gdata_contacts_service.h" 8 #include "chrome/browser/chromeos/gdata/gdata_contacts_service.h"
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 13
14 namespace contacts { 14 namespace contacts {
15 typedef std::vector<const contacts::Contact*> ContactPointers; 15 typedef std::vector<const contacts::Contact*> ContactPointers;
16 } 16 }
17 17
18 namespace gdata { 18 namespace gdata {
19 19
20 // "Stub" implementation of GDataContactsServiceInterface used for testing. 20 // "Stub" implementation of GDataContactsServiceInterface used for testing.
21 // Returns a pre-set list of contacts in response to DownloadContacts() calls. 21 // Returns a pre-set list of contacts in response to DownloadContacts() calls.
22 class GDataContactsServiceStub : public GDataContactsServiceInterface { 22 class GDataContactsServiceStub : public GDataContactsServiceInterface {
23 public: 23 public:
24 GDataContactsServiceStub(); 24 GDataContactsServiceStub();
25 virtual ~GDataContactsServiceStub(); 25 virtual ~GDataContactsServiceStub();
26 26
27 int num_download_requests() const { return num_download_requests_; }
28 void reset_stats() { num_download_requests_ = 0; }
27 void set_download_should_succeed(bool succeed) { 29 void set_download_should_succeed(bool succeed) {
28 download_should_succeed_ = succeed; 30 download_should_succeed_ = succeed;
29 } 31 }
30 32
31 // Sets the contacts that will be returned by DownloadContacts(), assuming 33 // Sets the contacts that will be returned by DownloadContacts(), assuming
32 // that the request's |min_update_time| matches |expected_min_update_time|. 34 // that the request's |min_update_time| matches |expected_min_update_time|.
33 void SetContacts(const contacts::ContactPointers& contacts, 35 void SetContacts(const contacts::ContactPointers& contacts,
34 const base::Time& expected_min_update_time); 36 const base::Time& expected_min_update_time);
35 37
36 // Overridden from GDataContactsServiceInterface: 38 // Overridden from GDataContactsServiceInterface:
37 virtual void Initialize() OVERRIDE; 39 virtual void Initialize() OVERRIDE;
38 virtual void DownloadContacts(SuccessCallback success_callback, 40 virtual void DownloadContacts(SuccessCallback success_callback,
39 FailureCallback failure_callback, 41 FailureCallback failure_callback,
40 const base::Time& min_update_time) OVERRIDE; 42 const base::Time& min_update_time) OVERRIDE;
41 43
42 private: 44 private:
45 // How many times has DownloadContacts() been called?
46 int num_download_requests_;
47
43 // Should calls to DownloadContacts() succeed? 48 // Should calls to DownloadContacts() succeed?
44 bool download_should_succeed_; 49 bool download_should_succeed_;
45 50
46 // Contacts to be returned by calls to DownloadContacts(). 51 // Contacts to be returned by calls to DownloadContacts().
47 ScopedVector<contacts::Contact> contacts_; 52 ScopedVector<contacts::Contact> contacts_;
48 53
49 // |min_update_time| value that we expect to be passed to DownloadContacts(). 54 // |min_update_time| value that we expect to be passed to DownloadContacts().
50 // If a different value is passed, we'll log an error and report failure. 55 // If a different value is passed, we'll log an error and report failure.
51 base::Time expected_min_update_time_; 56 base::Time expected_min_update_time_;
52 57
53 DISALLOW_COPY_AND_ASSIGN(GDataContactsServiceStub); 58 DISALLOW_COPY_AND_ASSIGN(GDataContactsServiceStub);
54 }; 59 };
55 60
56 } // namespace gdata 61 } // namespace gdata
57 62
58 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_STUB_H_ 63 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_STUB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698