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

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

Issue 10542076: ABANDONED: chromeos: Download contacts (work in progress). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor changes 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 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 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_
7
8 #include <set>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/scoped_vector.h"
16 #include "base/time.h"
17 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h"
18 #include "googleurl/src/gurl.h"
19
20 class Profile;
21
22 namespace base {
23 class Value;
24 }
25
26 namespace contacts {
27 struct Contact;
28 }
29
30 namespace gdata {
31
32 class GDataAuthService;
33 class GDataOperationRunner;
34
35 class GDataContactsServiceInterface {
36 public:
37 typedef base::Callback<void(scoped_ptr<ScopedVector<contacts::Contact> >)>
38 SuccessCallback;
39 typedef base::Closure FailureCallback;
40
41 virtual ~GDataContactsServiceInterface() {}
42
43 virtual void Initialize() = 0;
44
45 // Downloads all contacts changed at or after |min_update_time| and invokes
46 // the appropriate callback asynchronously on the UI thread when complete. If
47 // min_update_time.is_null() is true, all contacts will be returned.
48 virtual void DownloadContacts(SuccessCallback success_callback,
49 FailureCallback failure_callback,
50 const base::Time& min_update_time) = 0;
51
52 protected:
53 GDataContactsServiceInterface() {}
54
55 private:
56 DISALLOW_COPY_AND_ASSIGN(GDataContactsServiceInterface);
57 };
58
59 class GDataContactsService : public GDataContactsServiceInterface {
60 public:
61 typedef base::Callback<std::string(const std::string&)>
62 RewritePhotoUrlCallback;
63
64 explicit GDataContactsService(Profile* profile);
65 virtual ~GDataContactsService();
66
67 GDataAuthService* auth_service_for_testing();
68
69 void set_max_simultaneous_photo_downloads_for_testing(int max_downloads) {
70 max_simultaneous_photo_downloads_ = max_downloads;
71 }
72 void set_feed_url_for_testing(const GURL& url) {
73 feed_url_for_testing_ = url;
74 }
75 void set_rewrite_photo_url_callback_for_testing(RewritePhotoUrlCallback cb) {
76 rewrite_photo_url_callback_for_testing_ = cb;
77 }
78
79 // Overridden from GDataContactsServiceInterface:
80 virtual void Initialize() OVERRIDE;
81 virtual void DownloadContacts(SuccessCallback success_callback,
82 FailureCallback failure_callback,
83 const base::Time& min_update_time) OVERRIDE;
84
85 private:
86 class DownloadContactsRequest;
87
88 // Invoked by a download request once it's finished (either successfully or
89 // unsuccessfully).
90 void OnRequestComplete(DownloadContactsRequest* request);
91
92 Profile* profile_; // not owned
93
94 scoped_ptr<GDataOperationRunner> runner_;
95
96 // In-progress download requests.
97 std::set<DownloadContactsRequest*> requests_; // pointers are owned
98
99 // If non-empty, URL that will be used to fetch the feed. URLs contained
100 // within the feed will also be modified to use the host and port from this
101 // member.
102 GURL feed_url_for_testing_;
103
104 // Maximum number of photos we'll try to download at once (per
105 // DownloadContacts() request).
106 int max_simultaneous_photo_downloads_;
107
108 // Callback that's invoked to rewrite photo URLs for tests. Called iff
109 // |feed_url_for_testing_| has been set.
110 RewritePhotoUrlCallback rewrite_photo_url_callback_for_testing_;
111
112 DISALLOW_COPY_AND_ASSIGN(GDataContactsService);
113 };
114
115 } // namespace gdata
116
117 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/fake_gdata_contacts_service.cc ('k') | chrome/browser/chromeos/gdata/gdata_contacts_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698