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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_documents_service.cc

Issue 10831122: gdata cleanup: stop passing Profile* around GData operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. 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 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h" 5 #include "chrome/browser/chromeos/gdata/gdata_documents_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 void DocumentsService::GetDocuments(const GURL& url, 97 void DocumentsService::GetDocuments(const GURL& url,
98 int start_changestamp, 98 int start_changestamp,
99 const std::string& search_query, 99 const std::string& search_query,
100 const std::string& directory_resource_id, 100 const std::string& directory_resource_id,
101 const GetDataCallback& callback) { 101 const GetDataCallback& callback) {
102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
103 103
104 GetDocumentsOperation* operation = 104 GetDocumentsOperation* operation =
105 new GetDocumentsOperation(operation_registry(), 105 new GetDocumentsOperation(operation_registry(),
106 profile_,
107 start_changestamp, 106 start_changestamp,
108 search_query, 107 search_query,
109 directory_resource_id, 108 directory_resource_id,
110 callback); 109 callback);
111 if (!url.is_empty()) 110 if (!url.is_empty())
112 operation->SetUrl(url); 111 operation->SetUrl(url);
113 runner_->StartOperationWithRetry(operation); 112 runner_->StartOperationWithRetry(operation);
114 } 113 }
115 114
116 void DocumentsService::GetDocumentEntry(const std::string& resource_id, 115 void DocumentsService::GetDocumentEntry(const std::string& resource_id,
117 const GetDataCallback& callback) { 116 const GetDataCallback& callback) {
118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
119 118
120 GetDocumentEntryOperation* operation = 119 GetDocumentEntryOperation* operation =
121 new GetDocumentEntryOperation(operation_registry(), 120 new GetDocumentEntryOperation(operation_registry(),
122 profile_,
123 resource_id, 121 resource_id,
124 callback); 122 callback);
125 runner_->StartOperationWithRetry(operation); 123 runner_->StartOperationWithRetry(operation);
126 } 124 }
127 125
128 void DocumentsService::GetAccountMetadata(const GetDataCallback& callback) { 126 void DocumentsService::GetAccountMetadata(const GetDataCallback& callback) {
129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
130 128
131 GetAccountMetadataOperation* operation = 129 GetAccountMetadataOperation* operation =
132 new GetAccountMetadataOperation(operation_registry(), 130 new GetAccountMetadataOperation(operation_registry(), callback);
133 profile_,
134 callback);
135 runner_->StartOperationWithRetry(operation); 131 runner_->StartOperationWithRetry(operation);
136 } 132 }
137 133
138 void DocumentsService::GetAboutResource(const GetDataCallback& callback) { 134 void DocumentsService::GetAboutResource(const GetDataCallback& callback) {
139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
140 136
141 GetAboutOperation* operation = 137 GetAboutOperation* operation =
142 new GetAboutOperation(operation_registry(), profile_, callback); 138 new GetAboutOperation(operation_registry(), callback);
143 runner_->StartOperationWithRetry(operation); 139 runner_->StartOperationWithRetry(operation);
144 } 140 }
145 141
146 void DocumentsService::GetApplicationList(const GetDataCallback& callback) { 142 void DocumentsService::GetApplicationList(const GetDataCallback& callback) {
147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
148 144
149 GetApplistOperation* operation = 145 GetApplistOperation* operation =
150 new GetApplistOperation(operation_registry(), profile_, callback); 146 new GetApplistOperation(operation_registry(), callback);
151 runner_->StartOperationWithRetry(operation); 147 runner_->StartOperationWithRetry(operation);
152 } 148 }
153 149
154 void DocumentsService::DownloadDocument( 150 void DocumentsService::DownloadDocument(
155 const FilePath& virtual_path, 151 const FilePath& virtual_path,
156 const FilePath& local_cache_path, 152 const FilePath& local_cache_path,
157 const GURL& document_url, 153 const GURL& document_url,
158 DocumentExportFormat format, 154 DocumentExportFormat format,
159 const DownloadActionCallback& callback) { 155 const DownloadActionCallback& callback) {
160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 10 matching lines...) Expand all
171 167
172 void DocumentsService::DownloadFile( 168 void DocumentsService::DownloadFile(
173 const FilePath& virtual_path, 169 const FilePath& virtual_path,
174 const FilePath& local_cache_path, 170 const FilePath& local_cache_path,
175 const GURL& document_url, 171 const GURL& document_url,
176 const DownloadActionCallback& download_action_callback, 172 const DownloadActionCallback& download_action_callback,
177 const GetDownloadDataCallback& get_download_data_callback) { 173 const GetDownloadDataCallback& get_download_data_callback) {
178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
179 175
180 runner_->StartOperationWithRetry( 176 runner_->StartOperationWithRetry(
181 new DownloadFileOperation(operation_registry(), profile_, 177 new DownloadFileOperation(operation_registry(),
182 download_action_callback, 178 download_action_callback,
183 get_download_data_callback, document_url, 179 get_download_data_callback, document_url,
184 virtual_path, local_cache_path)); 180 virtual_path, local_cache_path));
185 } 181 }
186 182
187 void DocumentsService::DeleteDocument(const GURL& document_url, 183 void DocumentsService::DeleteDocument(const GURL& document_url,
188 const EntryActionCallback& callback) { 184 const EntryActionCallback& callback) {
189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 185 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
190 186
191 runner_->StartOperationWithRetry( 187 runner_->StartOperationWithRetry(
192 new DeleteDocumentOperation(operation_registry(), profile_, callback, 188 new DeleteDocumentOperation(operation_registry(), callback,
193 document_url)); 189 document_url));
194 } 190 }
195 191
196 void DocumentsService::CreateDirectory( 192 void DocumentsService::CreateDirectory(
197 const GURL& parent_content_url, 193 const GURL& parent_content_url,
198 const FilePath::StringType& directory_name, 194 const FilePath::StringType& directory_name,
199 const GetDataCallback& callback) { 195 const GetDataCallback& callback) {
200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
201 197
202 runner_->StartOperationWithRetry( 198 runner_->StartOperationWithRetry(
203 new CreateDirectoryOperation(operation_registry(), profile_, callback, 199 new CreateDirectoryOperation(operation_registry(), callback,
204 parent_content_url, directory_name)); 200 parent_content_url, directory_name));
205 } 201 }
206 202
207 void DocumentsService::CopyDocument(const std::string& resource_id, 203 void DocumentsService::CopyDocument(const std::string& resource_id,
208 const FilePath::StringType& new_name, 204 const FilePath::StringType& new_name,
209 const GetDataCallback& callback) { 205 const GetDataCallback& callback) {
210 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
211 207
212 runner_->StartOperationWithRetry( 208 runner_->StartOperationWithRetry(
213 new CopyDocumentOperation(operation_registry(), profile_, callback, 209 new CopyDocumentOperation(operation_registry(), callback,
214 resource_id, new_name)); 210 resource_id, new_name));
215 } 211 }
216 212
217 void DocumentsService::RenameResource(const GURL& resource_url, 213 void DocumentsService::RenameResource(const GURL& resource_url,
218 const FilePath::StringType& new_name, 214 const FilePath::StringType& new_name,
219 const EntryActionCallback& callback) { 215 const EntryActionCallback& callback) {
220 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
221 217
222 runner_->StartOperationWithRetry( 218 runner_->StartOperationWithRetry(
223 new RenameResourceOperation(operation_registry(), profile_, callback, 219 new RenameResourceOperation(operation_registry(), callback,
224 resource_url, new_name)); 220 resource_url, new_name));
225 } 221 }
226 222
227 void DocumentsService::AddResourceToDirectory( 223 void DocumentsService::AddResourceToDirectory(
228 const GURL& parent_content_url, 224 const GURL& parent_content_url,
229 const GURL& resource_url, 225 const GURL& resource_url,
230 const EntryActionCallback& callback) { 226 const EntryActionCallback& callback) {
231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
232 228
233 runner_->StartOperationWithRetry( 229 runner_->StartOperationWithRetry(
234 new AddResourceToDirectoryOperation(operation_registry(), 230 new AddResourceToDirectoryOperation(operation_registry(),
235 profile_,
236 callback, 231 callback,
237 parent_content_url, 232 parent_content_url,
238 resource_url)); 233 resource_url));
239 } 234 }
240 235
241 void DocumentsService::RemoveResourceFromDirectory( 236 void DocumentsService::RemoveResourceFromDirectory(
242 const GURL& parent_content_url, 237 const GURL& parent_content_url,
243 const GURL& resource_url, 238 const GURL& resource_url,
244 const std::string& resource_id, 239 const std::string& resource_id,
245 const EntryActionCallback& callback) { 240 const EntryActionCallback& callback) {
246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 241 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
247 242
248 runner_->StartOperationWithRetry( 243 runner_->StartOperationWithRetry(
249 new RemoveResourceFromDirectoryOperation(operation_registry(), 244 new RemoveResourceFromDirectoryOperation(operation_registry(),
250 profile_,
251 callback, 245 callback,
252 parent_content_url, 246 parent_content_url,
253 resource_url, 247 resource_url,
254 resource_id)); 248 resource_id));
255 } 249 }
256 250
257 void DocumentsService::InitiateUpload(const InitiateUploadParams& params, 251 void DocumentsService::InitiateUpload(const InitiateUploadParams& params,
258 const InitiateUploadCallback& callback) { 252 const InitiateUploadCallback& callback) {
259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
260 254
261 if (params.upload_location.is_empty()) { 255 if (params.upload_location.is_empty()) {
262 if (!callback.is_null()) 256 if (!callback.is_null())
263 callback.Run(HTTP_BAD_REQUEST, GURL()); 257 callback.Run(HTTP_BAD_REQUEST, GURL());
264 return; 258 return;
265 } 259 }
266 260
267 runner_->StartOperationWithRetry( 261 runner_->StartOperationWithRetry(
268 new InitiateUploadOperation(operation_registry(), profile_, callback, 262 new InitiateUploadOperation(operation_registry(), callback, params));
269 params));
270 } 263 }
271 264
272 void DocumentsService::ResumeUpload(const ResumeUploadParams& params, 265 void DocumentsService::ResumeUpload(const ResumeUploadParams& params,
273 const ResumeUploadCallback& callback) { 266 const ResumeUploadCallback& callback) {
274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 267 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
275 268
276 runner_->StartOperationWithRetry( 269 runner_->StartOperationWithRetry(
277 new ResumeUploadOperation(operation_registry(), profile_, callback, 270 new ResumeUploadOperation(operation_registry(), callback, params));
278 params));
279 } 271 }
280 272
281 273
282 void DocumentsService::AuthorizeApp(const GURL& resource_url, 274 void DocumentsService::AuthorizeApp(const GURL& resource_url,
283 const std::string& app_ids, 275 const std::string& app_ids,
284 const GetDataCallback& callback) { 276 const GetDataCallback& callback) {
285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
286 278
287 runner_->StartOperationWithRetry( 279 runner_->StartOperationWithRetry(
288 new AuthorizeAppsOperation(operation_registry(), profile_, callback, 280 new AuthorizeAppsOperation(operation_registry(), callback,
289 resource_url, app_ids)); 281 resource_url, app_ids));
290 } 282 }
291 283
292 bool DocumentsService::HasAccessToken() const { 284 bool DocumentsService::HasAccessToken() const {
293 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
294 286
295 return runner_->auth_service()->HasAccessToken(); 287 return runner_->auth_service()->HasAccessToken();
296 } 288 }
297 289
298 bool DocumentsService::HasRefreshToken() const { 290 bool DocumentsService::HasRefreshToken() const {
299 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
300 292
301 return runner_->auth_service()->HasRefreshToken(); 293 return runner_->auth_service()->HasRefreshToken();
302 } 294 }
303 295
304 } // namespace gdata 296 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_contacts_service.cc ('k') | chrome/browser/chromeos/gdata/gdata_operations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698