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/drive_api_service.cc

Issue 10829375: Cleanup: separate WAPI and Drive API code in gdata_documents_service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for comments 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
(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/drive_api_service.h"
6
7 #include <string>
8
9 #include "base/bind.h"
10 #include "base/message_loop_proxy.h"
11 #include "chrome/browser/chromeos/gdata/drive_api_operations.h"
12 #include "chrome/browser/chromeos/gdata/gdata_operation_runner.h"
13 #include "chrome/browser/chromeos/gdata/gdata_operations.h"
14 #include "chrome/browser/chromeos/gdata/gdata_util.h"
15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/net/url_util.h"
17 #include "content/public/browser/browser_thread.h"
18
19 using content::BrowserThread;
20
21 namespace gdata {
22
23 DriveAPIService::DriveAPIService()
24 : profile_(NULL),
25 runner_(NULL) {
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
27 }
28
29 DriveAPIService::~DriveAPIService() {
30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
31 }
32
33 void DriveAPIService::Initialize(Profile* profile) {
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
35 profile_ = profile;
36 runner_.reset(new GDataOperationRunner(profile));
37 runner_->Initialize();
38 }
39
40 GDataOperationRegistry* DriveAPIService::operation_registry() const {
41 return runner_->operation_registry();
42 }
43
44 void DriveAPIService::CancelAll() {
45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
46 runner_->CancelAll();
47 }
48
49 void DriveAPIService::Authenticate(const AuthStatusCallback& callback) {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
51 runner_->Authenticate(callback);
52 }
53
54 void DriveAPIService::GetDocuments(const GURL& url,
55 int64 start_changestamp,
56 const std::string& search_query,
57 const std::string& directory_resource_id,
58 const GetDataCallback& callback) {
59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
60
61 if (search_query.empty())
62 GetChangelist(url, start_changestamp, callback);
63 else
64 GetFilelist(url, search_query, callback);
65
66 return;
67 // TODO(kochi): Implement !directory_resource_id.empty() case.
68 NOTREACHED();
69 }
70
71 void DriveAPIService::GetFilelist(const GURL& url,
72 const std::string& search_query,
73 const GetDataCallback& callback) {
74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
75
76 runner_->StartOperationWithRetry(
77 new GetFilelistOperation(operation_registry(),
78 url,
79 search_query,
80 callback));
81 }
82
83 void DriveAPIService::GetChangelist(const GURL& url,
84 int64 start_changestamp,
85 const GetDataCallback& callback) {
86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
87
88 runner_->StartOperationWithRetry(
89 new GetChangelistOperation(operation_registry(),
90 url,
91 start_changestamp,
92 callback));
93 }
94
95 void DriveAPIService::GetDocumentEntry(const std::string& resource_id,
96 const GetDataCallback& callback) {
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
98
99 runner_->StartOperationWithRetry(new GetFileOperation(operation_registry(),
100 resource_id,
101 callback));
102 }
103
104 void DriveAPIService::GetAccountMetadata(const GetDataCallback& callback) {
105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
106
107 runner_->StartOperationWithRetry(
108 new GetAboutOperation(operation_registry(), callback));
109 }
110
111 void DriveAPIService::GetApplicationInfo(const GetDataCallback& callback) {
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
113
114 runner_->StartOperationWithRetry(
115 new GetApplistOperation(operation_registry(), callback));
116 }
117
118 void DriveAPIService::DownloadDocument(
119 const FilePath& virtual_path,
120 const FilePath& local_cache_path,
121 const GURL& document_url,
122 DocumentExportFormat format,
123 const DownloadActionCallback& callback) {
124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
125
126 // TODO(kochi): Implement this.
127 NOTREACHED();
128 }
129
130 void DriveAPIService::DownloadFile(
131 const FilePath& virtual_path,
132 const FilePath& local_cache_path,
133 const GURL& document_url,
134 const DownloadActionCallback& download_action_callback,
135 const GetContentCallback& get_content_callback) {
136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
137
138 // TODO(kochi): Implement this.
139 NOTREACHED();
140 }
141
142 void DriveAPIService::DeleteDocument(const GURL& document_url,
143 const EntryActionCallback& callback) {
144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
145
146 // TODO(kochi): Implement this.
147 NOTREACHED();
148 }
149
150 void DriveAPIService::CreateDirectory(
151 const GURL& parent_content_url,
152 const FilePath::StringType& directory_name,
153 const GetDataCallback& callback) {
154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
155
156 // TODO(kochi): Implement this.
157 NOTREACHED();
158 }
159
160 void DriveAPIService::CopyDocument(const std::string& resource_id,
161 const FilePath::StringType& new_name,
162 const GetDataCallback& callback) {
163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
164
165 // TODO(kochi): Implement this.
166 NOTREACHED();
167 }
168
169 void DriveAPIService::RenameResource(const GURL& resource_url,
170 const FilePath::StringType& new_name,
171 const EntryActionCallback& callback) {
172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
173
174 // TODO(kochi): Implement this.
175 NOTREACHED();
176 }
177
178 void DriveAPIService::AddResourceToDirectory(
179 const GURL& parent_content_url,
180 const GURL& resource_url,
181 const EntryActionCallback& callback) {
182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
183
184 // TODO(kochi): Implement this.
185 NOTREACHED();
186 }
187
188 void DriveAPIService::RemoveResourceFromDirectory(
189 const GURL& parent_content_url,
190 const GURL& resource_url,
191 const std::string& resource_id,
192 const EntryActionCallback& callback) {
193 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
194
195 // TODO(kochi): Implement this.
196 NOTREACHED();
197 }
198
199 void DriveAPIService::InitiateUpload(const InitiateUploadParams& params,
200 const InitiateUploadCallback& callback) {
201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
202
203 // TODO(kochi): Implement this.
204 NOTREACHED();
205 }
206
207 void DriveAPIService::ResumeUpload(const ResumeUploadParams& params,
208 const ResumeUploadCallback& callback) {
209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
210
211 // TODO(kochi): Implement this.
212 NOTREACHED();
213 }
214
215
216 void DriveAPIService::AuthorizeApp(const GURL& resource_url,
217 const std::string& app_ids,
218 const GetDataCallback& callback) {
219 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
220
221 // TODO(kochi): Implement this.
222 NOTREACHED();
223 }
224
225 bool DriveAPIService::HasAccessToken() const {
226 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
227
228 return runner_->auth_service()->HasAccessToken();
229 }
230
231 bool DriveAPIService::HasRefreshToken() const {
232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
233
234 return runner_->auth_service()->HasRefreshToken();
235 }
236
237 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/drive_api_service.h ('k') | chrome/browser/chromeos/gdata/drive_task_executor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698