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

Side by Side Diff: chrome/browser/google_apis/gdata_wapi_service.cc

Issue 15333013: Replace most of the occurrence of OperationRegistry with OperationRunner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
« no previous file with comments | « chrome/browser/google_apis/gdata_wapi_service.h ('k') | chrome/browser/google_apis/test_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/google_apis/gdata_wapi_service.h" 5 #include "chrome/browser/google_apis/gdata_wapi_service.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return HasRefreshToken(); 146 return HasRefreshToken();
147 } 147 }
148 148
149 void GDataWapiService::CancelAll() { 149 void GDataWapiService::CancelAll() {
150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
151 runner_->CancelAll(); 151 runner_->CancelAll();
152 } 152 }
153 153
154 bool GDataWapiService::CancelForFilePath(const base::FilePath& file_path) { 154 bool GDataWapiService::CancelForFilePath(const base::FilePath& file_path) {
155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
156 return operation_registry()->CancelForFilePath(file_path); 156 return runner_->operation_registry()->CancelForFilePath(file_path);
157 } 157 }
158 158
159 std::string GDataWapiService::GetRootResourceId() const { 159 std::string GDataWapiService::GetRootResourceId() const {
160 return kWapiRootDirectoryResourceId; 160 return kWapiRootDirectoryResourceId;
161 } 161 }
162 162
163 // Because GData WAPI support is expected to be gone somehow soon by migration 163 // Because GData WAPI support is expected to be gone somehow soon by migration
164 // to the Drive API v2, so we'll reuse GetResourceListOperation to implement 164 // to the Drive API v2, so we'll reuse GetResourceListOperation to implement
165 // following methods, instead of cleaning the operation class. 165 // following methods, instead of cleaning the operation class.
166 166
167 void GDataWapiService::GetAllResourceList( 167 void GDataWapiService::GetAllResourceList(
168 const GetResourceListCallback& callback) { 168 const GetResourceListCallback& callback) {
169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
170 DCHECK(!callback.is_null()); 170 DCHECK(!callback.is_null());
171 171
172 runner_->StartOperationWithRetry( 172 runner_->StartOperationWithRetry(
173 new GetResourceListOperation(operation_registry(), 173 new GetResourceListOperation(runner_.get(),
174 url_request_context_getter_, 174 url_request_context_getter_,
175 url_generator_, 175 url_generator_,
176 GURL(), // No override url 176 GURL(), // No override url
177 0, // start changestamp 177 0, // start changestamp
178 std::string(), // empty search query 178 std::string(), // empty search query
179 std::string(), // no directory resource id 179 std::string(), // no directory resource id
180 callback)); 180 callback));
181 } 181 }
182 182
183 void GDataWapiService::GetResourceListInDirectory( 183 void GDataWapiService::GetResourceListInDirectory(
184 const std::string& directory_resource_id, 184 const std::string& directory_resource_id,
185 const GetResourceListCallback& callback) { 185 const GetResourceListCallback& callback) {
186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
187 DCHECK(!directory_resource_id.empty()); 187 DCHECK(!directory_resource_id.empty());
188 DCHECK(!callback.is_null()); 188 DCHECK(!callback.is_null());
189 189
190 runner_->StartOperationWithRetry( 190 runner_->StartOperationWithRetry(
191 new GetResourceListOperation(operation_registry(), 191 new GetResourceListOperation(runner_.get(),
192 url_request_context_getter_, 192 url_request_context_getter_,
193 url_generator_, 193 url_generator_,
194 GURL(), // No override url 194 GURL(), // No override url
195 0, // start changestamp 195 0, // start changestamp
196 std::string(), // empty search query 196 std::string(), // empty search query
197 directory_resource_id, 197 directory_resource_id,
198 callback)); 198 callback));
199 } 199 }
200 200
201 void GDataWapiService::Search(const std::string& search_query, 201 void GDataWapiService::Search(const std::string& search_query,
202 const GetResourceListCallback& callback) { 202 const GetResourceListCallback& callback) {
203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
204 DCHECK(!search_query.empty()); 204 DCHECK(!search_query.empty());
205 DCHECK(!callback.is_null()); 205 DCHECK(!callback.is_null());
206 206
207 runner_->StartOperationWithRetry( 207 runner_->StartOperationWithRetry(
208 new GetResourceListOperation(operation_registry(), 208 new GetResourceListOperation(runner_.get(),
209 url_request_context_getter_, 209 url_request_context_getter_,
210 url_generator_, 210 url_generator_,
211 GURL(), // No override url 211 GURL(), // No override url
212 0, // start changestamp 212 0, // start changestamp
213 search_query, 213 search_query,
214 std::string(), // no directory resource id 214 std::string(), // no directory resource id
215 callback)); 215 callback));
216 } 216 }
217 217
218 void GDataWapiService::SearchByTitle( 218 void GDataWapiService::SearchByTitle(
219 const std::string& title, 219 const std::string& title,
220 const std::string& directory_resource_id, 220 const std::string& directory_resource_id,
221 const GetResourceListCallback& callback) { 221 const GetResourceListCallback& callback) {
222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
223 DCHECK(!title.empty()); 223 DCHECK(!title.empty());
224 DCHECK(!callback.is_null()); 224 DCHECK(!callback.is_null());
225 225
226 runner_->StartOperationWithRetry( 226 runner_->StartOperationWithRetry(
227 new SearchByTitleOperation( 227 new SearchByTitleOperation(
228 operation_registry(), 228 runner_.get(),
229 url_request_context_getter_, 229 url_request_context_getter_,
230 url_generator_, 230 url_generator_,
231 title, 231 title,
232 directory_resource_id, 232 directory_resource_id,
233 callback)); 233 callback));
234 } 234 }
235 235
236 void GDataWapiService::GetChangeList(int64 start_changestamp, 236 void GDataWapiService::GetChangeList(int64 start_changestamp,
237 const GetResourceListCallback& callback) { 237 const GetResourceListCallback& callback) {
238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
239 DCHECK(!callback.is_null()); 239 DCHECK(!callback.is_null());
240 240
241 runner_->StartOperationWithRetry( 241 runner_->StartOperationWithRetry(
242 new GetResourceListOperation(operation_registry(), 242 new GetResourceListOperation(runner_.get(),
243 url_request_context_getter_, 243 url_request_context_getter_,
244 url_generator_, 244 url_generator_,
245 GURL(), // No override url 245 GURL(), // No override url
246 start_changestamp, 246 start_changestamp,
247 std::string(), // empty search query 247 std::string(), // empty search query
248 std::string(), // no directory resource id 248 std::string(), // no directory resource id
249 callback)); 249 callback));
250 } 250 }
251 251
252 void GDataWapiService::ContinueGetResourceList( 252 void GDataWapiService::ContinueGetResourceList(
253 const GURL& override_url, 253 const GURL& override_url,
254 const GetResourceListCallback& callback) { 254 const GetResourceListCallback& callback) {
255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
256 DCHECK(!override_url.is_empty()); 256 DCHECK(!override_url.is_empty());
257 DCHECK(!callback.is_null()); 257 DCHECK(!callback.is_null());
258 258
259 runner_->StartOperationWithRetry( 259 runner_->StartOperationWithRetry(
260 new GetResourceListOperation(operation_registry(), 260 new GetResourceListOperation(runner_.get(),
261 url_request_context_getter_, 261 url_request_context_getter_,
262 url_generator_, 262 url_generator_,
263 override_url, 263 override_url,
264 0, // start changestamp 264 0, // start changestamp
265 std::string(), // empty search query 265 std::string(), // empty search query
266 std::string(), // no directory resource id 266 std::string(), // no directory resource id
267 callback)); 267 callback));
268 } 268 }
269 269
270 void GDataWapiService::GetResourceEntry( 270 void GDataWapiService::GetResourceEntry(
271 const std::string& resource_id, 271 const std::string& resource_id,
272 const GetResourceEntryCallback& callback) { 272 const GetResourceEntryCallback& callback) {
273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
274 DCHECK(!callback.is_null()); 274 DCHECK(!callback.is_null());
275 275
276 runner_->StartOperationWithRetry( 276 runner_->StartOperationWithRetry(
277 new GetResourceEntryOperation( 277 new GetResourceEntryOperation(
278 operation_registry(), 278 runner_.get(),
279 url_request_context_getter_, 279 url_request_context_getter_,
280 url_generator_, 280 url_generator_,
281 resource_id, 281 resource_id,
282 base::Bind(&ParseResourceEntryAndRun, callback))); 282 base::Bind(&ParseResourceEntryAndRun, callback)));
283 } 283 }
284 284
285 void GDataWapiService::GetAboutResource( 285 void GDataWapiService::GetAboutResource(
286 const GetAboutResourceCallback& callback) { 286 const GetAboutResourceCallback& callback) {
287 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 287 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
288 DCHECK(!callback.is_null()); 288 DCHECK(!callback.is_null());
289 289
290 runner_->StartOperationWithRetry( 290 runner_->StartOperationWithRetry(
291 new GetAccountMetadataOperation( 291 new GetAccountMetadataOperation(
292 operation_registry(), 292 runner_.get(),
293 url_request_context_getter_, 293 url_request_context_getter_,
294 url_generator_, 294 url_generator_,
295 base::Bind(&ParseAboutResourceAndRun, callback), 295 base::Bind(&ParseAboutResourceAndRun, callback),
296 false)); // Exclude installed apps. 296 false)); // Exclude installed apps.
297 } 297 }
298 298
299 void GDataWapiService::GetAppList(const GetAppListCallback& callback) { 299 void GDataWapiService::GetAppList(const GetAppListCallback& callback) {
300 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 300 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
301 DCHECK(!callback.is_null()); 301 DCHECK(!callback.is_null());
302 302
303 runner_->StartOperationWithRetry( 303 runner_->StartOperationWithRetry(
304 new GetAccountMetadataOperation( 304 new GetAccountMetadataOperation(
305 operation_registry(), 305 runner_.get(),
306 url_request_context_getter_, 306 url_request_context_getter_,
307 url_generator_, 307 url_generator_,
308 base::Bind(&ParseAppListAndRun, callback), 308 base::Bind(&ParseAppListAndRun, callback),
309 true)); // Include installed apps. 309 true)); // Include installed apps.
310 } 310 }
311 311
312 void GDataWapiService::DownloadFile( 312 void GDataWapiService::DownloadFile(
313 const base::FilePath& virtual_path, 313 const base::FilePath& virtual_path,
314 const base::FilePath& local_cache_path, 314 const base::FilePath& local_cache_path,
315 const GURL& download_url, 315 const GURL& download_url,
316 const DownloadActionCallback& download_action_callback, 316 const DownloadActionCallback& download_action_callback,
317 const GetContentCallback& get_content_callback, 317 const GetContentCallback& get_content_callback,
318 const ProgressCallback& progress_callback) { 318 const ProgressCallback& progress_callback) {
319 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 319 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
320 DCHECK(!download_action_callback.is_null()); 320 DCHECK(!download_action_callback.is_null());
321 // get_content_callback and progress_callback may be null. 321 // get_content_callback and progress_callback may be null.
322 322
323 runner_->StartOperationWithRetry( 323 runner_->StartOperationWithRetry(
324 new DownloadFileOperation(operation_registry(), 324 new DownloadFileOperation(runner_.get(),
325 url_request_context_getter_, 325 url_request_context_getter_,
326 download_action_callback, 326 download_action_callback,
327 get_content_callback, 327 get_content_callback,
328 progress_callback, 328 progress_callback,
329 download_url, 329 download_url,
330 virtual_path, 330 virtual_path,
331 local_cache_path)); 331 local_cache_path));
332 } 332 }
333 333
334 void GDataWapiService::DeleteResource( 334 void GDataWapiService::DeleteResource(
335 const std::string& resource_id, 335 const std::string& resource_id,
336 const std::string& etag, 336 const std::string& etag,
337 const EntryActionCallback& callback) { 337 const EntryActionCallback& callback) {
338 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 338 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
339 DCHECK(!callback.is_null()); 339 DCHECK(!callback.is_null());
340 340
341 runner_->StartOperationWithRetry( 341 runner_->StartOperationWithRetry(
342 new DeleteResourceOperation(operation_registry(), 342 new DeleteResourceOperation(runner_.get(),
343 url_request_context_getter_, 343 url_request_context_getter_,
344 url_generator_, 344 url_generator_,
345 callback, 345 callback,
346 resource_id, 346 resource_id,
347 etag)); 347 etag));
348 } 348 }
349 349
350 void GDataWapiService::AddNewDirectory( 350 void GDataWapiService::AddNewDirectory(
351 const std::string& parent_resource_id, 351 const std::string& parent_resource_id,
352 const std::string& directory_name, 352 const std::string& directory_name,
353 const GetResourceEntryCallback& callback) { 353 const GetResourceEntryCallback& callback) {
354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
355 DCHECK(!callback.is_null()); 355 DCHECK(!callback.is_null());
356 356
357 runner_->StartOperationWithRetry( 357 runner_->StartOperationWithRetry(
358 new CreateDirectoryOperation(operation_registry(), 358 new CreateDirectoryOperation(runner_.get(),
359 url_request_context_getter_, 359 url_request_context_getter_,
360 url_generator_, 360 url_generator_,
361 base::Bind(&ParseResourceEntryAndRun, 361 base::Bind(&ParseResourceEntryAndRun,
362 callback), 362 callback),
363 parent_resource_id, 363 parent_resource_id,
364 directory_name)); 364 directory_name));
365 } 365 }
366 366
367 void GDataWapiService::CopyResource( 367 void GDataWapiService::CopyResource(
368 const std::string& resource_id, 368 const std::string& resource_id,
(...skipping 11 matching lines...) Expand all
380 380
381 void GDataWapiService::CopyHostedDocument( 381 void GDataWapiService::CopyHostedDocument(
382 const std::string& resource_id, 382 const std::string& resource_id,
383 const std::string& new_name, 383 const std::string& new_name,
384 const GetResourceEntryCallback& callback) { 384 const GetResourceEntryCallback& callback) {
385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
386 DCHECK(!callback.is_null()); 386 DCHECK(!callback.is_null());
387 387
388 runner_->StartOperationWithRetry( 388 runner_->StartOperationWithRetry(
389 new CopyHostedDocumentOperation( 389 new CopyHostedDocumentOperation(
390 operation_registry(), 390 runner_.get(),
391 url_request_context_getter_, 391 url_request_context_getter_,
392 url_generator_, 392 url_generator_,
393 base::Bind(&ParseResourceEntryAndRun, callback), 393 base::Bind(&ParseResourceEntryAndRun, callback),
394 resource_id, 394 resource_id,
395 new_name)); 395 new_name));
396 } 396 }
397 397
398 void GDataWapiService::RenameResource( 398 void GDataWapiService::RenameResource(
399 const std::string& resource_id, 399 const std::string& resource_id,
400 const std::string& new_name, 400 const std::string& new_name,
401 const EntryActionCallback& callback) { 401 const EntryActionCallback& callback) {
402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
403 DCHECK(!callback.is_null()); 403 DCHECK(!callback.is_null());
404 404
405 runner_->StartOperationWithRetry( 405 runner_->StartOperationWithRetry(
406 new RenameResourceOperation(operation_registry(), 406 new RenameResourceOperation(runner_.get(),
407 url_request_context_getter_, 407 url_request_context_getter_,
408 url_generator_, 408 url_generator_,
409 callback, 409 callback,
410 resource_id, 410 resource_id,
411 new_name)); 411 new_name));
412 } 412 }
413 413
414 void GDataWapiService::AddResourceToDirectory( 414 void GDataWapiService::AddResourceToDirectory(
415 const std::string& parent_resource_id, 415 const std::string& parent_resource_id,
416 const std::string& resource_id, 416 const std::string& resource_id,
417 const EntryActionCallback& callback) { 417 const EntryActionCallback& callback) {
418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
419 DCHECK(!callback.is_null()); 419 DCHECK(!callback.is_null());
420 420
421 runner_->StartOperationWithRetry( 421 runner_->StartOperationWithRetry(
422 new AddResourceToDirectoryOperation(operation_registry(), 422 new AddResourceToDirectoryOperation(runner_.get(),
423 url_request_context_getter_, 423 url_request_context_getter_,
424 url_generator_, 424 url_generator_,
425 callback, 425 callback,
426 parent_resource_id, 426 parent_resource_id,
427 resource_id)); 427 resource_id));
428 } 428 }
429 429
430 void GDataWapiService::RemoveResourceFromDirectory( 430 void GDataWapiService::RemoveResourceFromDirectory(
431 const std::string& parent_resource_id, 431 const std::string& parent_resource_id,
432 const std::string& resource_id, 432 const std::string& resource_id,
433 const EntryActionCallback& callback) { 433 const EntryActionCallback& callback) {
434 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 434 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
435 DCHECK(!callback.is_null()); 435 DCHECK(!callback.is_null());
436 436
437 runner_->StartOperationWithRetry( 437 runner_->StartOperationWithRetry(
438 new RemoveResourceFromDirectoryOperation(operation_registry(), 438 new RemoveResourceFromDirectoryOperation(runner_.get(),
439 url_request_context_getter_, 439 url_request_context_getter_,
440 url_generator_, 440 url_generator_,
441 callback, 441 callback,
442 parent_resource_id, 442 parent_resource_id,
443 resource_id)); 443 resource_id));
444 } 444 }
445 445
446 void GDataWapiService::InitiateUploadNewFile( 446 void GDataWapiService::InitiateUploadNewFile(
447 const base::FilePath& drive_file_path, 447 const base::FilePath& drive_file_path,
448 const std::string& content_type, 448 const std::string& content_type,
449 int64 content_length, 449 int64 content_length,
450 const std::string& parent_resource_id, 450 const std::string& parent_resource_id,
451 const std::string& title, 451 const std::string& title,
452 const InitiateUploadCallback& callback) { 452 const InitiateUploadCallback& callback) {
453 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 453 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
454 DCHECK(!callback.is_null()); 454 DCHECK(!callback.is_null());
455 DCHECK(!parent_resource_id.empty()); 455 DCHECK(!parent_resource_id.empty());
456 456
457 runner_->StartOperationWithRetry( 457 runner_->StartOperationWithRetry(
458 new InitiateUploadNewFileOperation(operation_registry(), 458 new InitiateUploadNewFileOperation(runner_.get(),
459 url_request_context_getter_, 459 url_request_context_getter_,
460 url_generator_, 460 url_generator_,
461 callback, 461 callback,
462 drive_file_path, 462 drive_file_path,
463 content_type, 463 content_type,
464 content_length, 464 content_length,
465 parent_resource_id, 465 parent_resource_id,
466 title)); 466 title));
467 } 467 }
468 468
469 void GDataWapiService::InitiateUploadExistingFile( 469 void GDataWapiService::InitiateUploadExistingFile(
470 const base::FilePath& drive_file_path, 470 const base::FilePath& drive_file_path,
471 const std::string& content_type, 471 const std::string& content_type,
472 int64 content_length, 472 int64 content_length,
473 const std::string& resource_id, 473 const std::string& resource_id,
474 const std::string& etag, 474 const std::string& etag,
475 const InitiateUploadCallback& callback) { 475 const InitiateUploadCallback& callback) {
476 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 476 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
477 DCHECK(!callback.is_null()); 477 DCHECK(!callback.is_null());
478 DCHECK(!resource_id.empty()); 478 DCHECK(!resource_id.empty());
479 479
480 runner_->StartOperationWithRetry( 480 runner_->StartOperationWithRetry(
481 new InitiateUploadExistingFileOperation(operation_registry(), 481 new InitiateUploadExistingFileOperation(runner_.get(),
482 url_request_context_getter_, 482 url_request_context_getter_,
483 url_generator_, 483 url_generator_,
484 callback, 484 callback,
485 drive_file_path, 485 drive_file_path,
486 content_type, 486 content_type,
487 content_length, 487 content_length,
488 resource_id, 488 resource_id,
489 etag)); 489 etag));
490 } 490 }
491 491
492 void GDataWapiService::ResumeUpload( 492 void GDataWapiService::ResumeUpload(
493 const base::FilePath& drive_file_path, 493 const base::FilePath& drive_file_path,
494 const GURL& upload_url, 494 const GURL& upload_url,
495 int64 start_position, 495 int64 start_position,
496 int64 end_position, 496 int64 end_position,
497 int64 content_length, 497 int64 content_length,
498 const std::string& content_type, 498 const std::string& content_type,
499 const base::FilePath& local_file_path, 499 const base::FilePath& local_file_path,
500 const UploadRangeCallback& callback, 500 const UploadRangeCallback& callback,
501 const ProgressCallback& progress_callback) { 501 const ProgressCallback& progress_callback) {
502 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 502 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
503 DCHECK(!callback.is_null()); 503 DCHECK(!callback.is_null());
504 504
505 runner_->StartOperationWithRetry( 505 runner_->StartOperationWithRetry(
506 new ResumeUploadOperation(operation_registry(), 506 new ResumeUploadOperation(runner_.get(),
507 url_request_context_getter_, 507 url_request_context_getter_,
508 callback, 508 callback,
509 progress_callback, 509 progress_callback,
510 drive_file_path, 510 drive_file_path,
511 upload_url, 511 upload_url,
512 start_position, 512 start_position,
513 end_position, 513 end_position,
514 content_length, 514 content_length,
515 content_type, 515 content_type,
516 local_file_path)); 516 local_file_path));
517 } 517 }
518 518
519 void GDataWapiService::GetUploadStatus( 519 void GDataWapiService::GetUploadStatus(
520 const base::FilePath& drive_file_path, 520 const base::FilePath& drive_file_path,
521 const GURL& upload_url, 521 const GURL& upload_url,
522 int64 content_length, 522 int64 content_length,
523 const UploadRangeCallback& callback) { 523 const UploadRangeCallback& callback) {
524 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 524 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
525 DCHECK(!callback.is_null()); 525 DCHECK(!callback.is_null());
526 526
527 runner_->StartOperationWithRetry( 527 runner_->StartOperationWithRetry(
528 new GetUploadStatusOperation(operation_registry(), 528 new GetUploadStatusOperation(runner_.get(),
529 url_request_context_getter_, 529 url_request_context_getter_,
530 callback, 530 callback,
531 drive_file_path, 531 drive_file_path,
532 upload_url, 532 upload_url,
533 content_length)); 533 content_length));
534 } 534 }
535 535
536 void GDataWapiService::AuthorizeApp(const std::string& resource_id, 536 void GDataWapiService::AuthorizeApp(const std::string& resource_id,
537 const std::string& app_id, 537 const std::string& app_id,
538 const AuthorizeAppCallback& callback) { 538 const AuthorizeAppCallback& callback) {
539 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 539 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
540 DCHECK(!callback.is_null()); 540 DCHECK(!callback.is_null());
541 541
542 runner_->StartOperationWithRetry( 542 runner_->StartOperationWithRetry(
543 new AuthorizeAppOperation( 543 new AuthorizeAppOperation(
544 operation_registry(), 544 runner_.get(),
545 url_request_context_getter_, 545 url_request_context_getter_,
546 url_generator_, 546 url_generator_,
547 callback, 547 callback,
548 resource_id, 548 resource_id,
549 app_id)); 549 app_id));
550 } 550 }
551 551
552 bool GDataWapiService::HasAccessToken() const { 552 bool GDataWapiService::HasAccessToken() const {
553 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 553 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
554 554
555 return runner_->auth_service()->HasAccessToken(); 555 return runner_->auth_service()->HasAccessToken();
556 } 556 }
557 557
558 bool GDataWapiService::HasRefreshToken() const { 558 bool GDataWapiService::HasRefreshToken() const {
559 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 559 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
560 560
561 return runner_->auth_service()->HasRefreshToken(); 561 return runner_->auth_service()->HasRefreshToken();
562 } 562 }
563 563
564 void GDataWapiService::ClearAccessToken() { 564 void GDataWapiService::ClearAccessToken() {
565 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 565 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
566 return runner_->auth_service()->ClearAccessToken(); 566 return runner_->auth_service()->ClearAccessToken();
567 } 567 }
568 568
569 void GDataWapiService::ClearRefreshToken() { 569 void GDataWapiService::ClearRefreshToken() {
570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
571 return runner_->auth_service()->ClearRefreshToken(); 571 return runner_->auth_service()->ClearRefreshToken();
572 } 572 }
573 573
574 OperationRegistry* GDataWapiService::operation_registry() const {
575 return runner_->operation_registry();
576 }
577
578 void GDataWapiService::OnOAuth2RefreshTokenChanged() { 574 void GDataWapiService::OnOAuth2RefreshTokenChanged() {
579 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 575 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
580 if (CanStartOperation()) { 576 if (CanStartOperation()) {
581 FOR_EACH_OBSERVER( 577 FOR_EACH_OBSERVER(
582 DriveServiceObserver, observers_, OnReadyToPerformOperations()); 578 DriveServiceObserver, observers_, OnReadyToPerformOperations());
583 } else if (!HasRefreshToken()) { 579 } else if (!HasRefreshToken()) {
584 FOR_EACH_OBSERVER( 580 FOR_EACH_OBSERVER(
585 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); 581 DriveServiceObserver, observers_, OnRefreshTokenInvalid());
586 } 582 }
587 } 583 }
588 584
589 } // namespace google_apis 585 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/gdata_wapi_service.h ('k') | chrome/browser/google_apis/test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698