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

Side by Side Diff: chrome/browser/drive/drive_api_service.cc

Issue 18506002: drive/syncFS: Switch to ID based download URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase! Created 7 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
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/drive/drive_api_service.h" 5 #include "chrome/browser/drive/drive_api_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"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/task_runner_util.h" 12 #include "base/task_runner_util.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/drive/drive_api_util.h" 14 #include "chrome/browser/drive/drive_api_util.h"
15 #include "chrome/browser/google_apis/auth_service.h" 15 #include "chrome/browser/google_apis/auth_service.h"
16 #include "chrome/browser/google_apis/drive_api_parser.h" 16 #include "chrome/browser/google_apis/drive_api_parser.h"
17 #include "chrome/browser/google_apis/drive_api_requests.h" 17 #include "chrome/browser/google_apis/drive_api_requests.h"
18 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 18 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
19 #include "chrome/browser/google_apis/request_sender.h" 19 #include "chrome/browser/google_apis/request_sender.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 21
22 using content::BrowserThread; 22 using content::BrowserThread;
23 using google_apis::AppList; 23 using google_apis::AppList;
24 using google_apis::AuthorizeAppCallback; 24 using google_apis::AuthorizeAppCallback;
25 using google_apis::CancelCallback; 25 using google_apis::CancelCallback;
26 using google_apis::ChangeList; 26 using google_apis::ChangeList;
27 using google_apis::DownloadActionCallback; 27 using google_apis::DownloadActionCallback;
28 using google_apis::DownloadFileRequestBase;
29 using google_apis::EntryActionCallback; 28 using google_apis::EntryActionCallback;
30 using google_apis::FileList; 29 using google_apis::FileList;
31 using google_apis::FileResource; 30 using google_apis::FileResource;
32 using google_apis::GDATA_OTHER_ERROR; 31 using google_apis::GDATA_OTHER_ERROR;
33 using google_apis::GDATA_PARSE_ERROR; 32 using google_apis::GDATA_PARSE_ERROR;
34 using google_apis::GDataErrorCode; 33 using google_apis::GDataErrorCode;
35 using google_apis::GetAboutRequest; 34 using google_apis::GetAboutRequest;
36 using google_apis::GetAboutResourceCallback; 35 using google_apis::GetAboutResourceCallback;
37 using google_apis::GetAppListCallback; 36 using google_apis::GetAppListCallback;
38 using google_apis::GetApplistRequest; 37 using google_apis::GetApplistRequest;
39 using google_apis::GetChangelistRequest; 38 using google_apis::GetChangelistRequest;
40 using google_apis::GetContentCallback; 39 using google_apis::GetContentCallback;
41 using google_apis::GetFileRequest; 40 using google_apis::GetFileRequest;
42 using google_apis::GetFilelistRequest; 41 using google_apis::GetFilelistRequest;
43 using google_apis::GetResourceEntryCallback; 42 using google_apis::GetResourceEntryCallback;
44 using google_apis::GetResourceListCallback; 43 using google_apis::GetResourceListCallback;
45 using google_apis::HTTP_SUCCESS; 44 using google_apis::HTTP_SUCCESS;
46 using google_apis::InitiateUploadCallback; 45 using google_apis::InitiateUploadCallback;
47 using google_apis::ProgressCallback; 46 using google_apis::ProgressCallback;
48 using google_apis::RequestSender; 47 using google_apis::RequestSender;
49 using google_apis::ResourceEntry; 48 using google_apis::ResourceEntry;
50 using google_apis::ResourceList; 49 using google_apis::ResourceList;
51 using google_apis::UploadRangeCallback; 50 using google_apis::UploadRangeCallback;
52 using google_apis::UploadRangeResponse; 51 using google_apis::UploadRangeResponse;
53 using google_apis::drive::ContinueGetFileListRequest; 52 using google_apis::drive::ContinueGetFileListRequest;
54 using google_apis::drive::CopyResourceRequest; 53 using google_apis::drive::CopyResourceRequest;
55 using google_apis::drive::CreateDirectoryRequest; 54 using google_apis::drive::CreateDirectoryRequest;
56 using google_apis::drive::DeleteResourceRequest; 55 using google_apis::drive::DeleteResourceRequest;
56 using google_apis::drive::DownloadFileRequest;
57 using google_apis::drive::GetUploadStatusRequest; 57 using google_apis::drive::GetUploadStatusRequest;
58 using google_apis::drive::InitiateUploadExistingFileRequest; 58 using google_apis::drive::InitiateUploadExistingFileRequest;
59 using google_apis::drive::InitiateUploadNewFileRequest; 59 using google_apis::drive::InitiateUploadNewFileRequest;
60 using google_apis::drive::InsertResourceRequest; 60 using google_apis::drive::InsertResourceRequest;
61 using google_apis::drive::RenameResourceRequest; 61 using google_apis::drive::RenameResourceRequest;
62 using google_apis::drive::ResumeUploadRequest; 62 using google_apis::drive::ResumeUploadRequest;
63 using google_apis::drive::TouchResourceRequest; 63 using google_apis::drive::TouchResourceRequest;
64 using google_apis::drive::TrashResourceRequest; 64 using google_apis::drive::TrashResourceRequest;
65 65
66 namespace drive { 66 namespace drive {
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 DCHECK(!callback.is_null()); 476 DCHECK(!callback.is_null());
477 477
478 return sender_->StartRequestWithRetry(new GetApplistRequest( 478 return sender_->StartRequestWithRetry(new GetApplistRequest(
479 sender_.get(), 479 sender_.get(),
480 url_generator_, 480 url_generator_,
481 base::Bind(&ParseAppListAndRun, callback))); 481 base::Bind(&ParseAppListAndRun, callback)));
482 } 482 }
483 483
484 CancelCallback DriveAPIService::DownloadFile( 484 CancelCallback DriveAPIService::DownloadFile(
485 const base::FilePath& local_cache_path, 485 const base::FilePath& local_cache_path,
486 const GURL& download_url, 486 const std::string& resource_id,
487 const DownloadActionCallback& download_action_callback, 487 const DownloadActionCallback& download_action_callback,
488 const GetContentCallback& get_content_callback, 488 const GetContentCallback& get_content_callback,
489 const ProgressCallback& progress_callback) { 489 const ProgressCallback& progress_callback) {
490 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 490 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
491 DCHECK(!download_action_callback.is_null()); 491 DCHECK(!download_action_callback.is_null());
492 // get_content_callback may be null. 492 // get_content_callback may be null.
493 493
494 // TODO(kinaba): crbug.com/254025: use resource_id based download request.
495 return sender_->StartRequestWithRetry( 494 return sender_->StartRequestWithRetry(
496 new DownloadFileRequestBase(sender_.get(), 495 new DownloadFileRequest(sender_.get(),
497 download_action_callback, 496 url_generator_,
498 get_content_callback, 497 resource_id,
499 progress_callback, 498 local_cache_path,
500 download_url, 499 download_action_callback,
501 local_cache_path)); 500 get_content_callback,
501 progress_callback));
502 } 502 }
503 503
504 CancelCallback DriveAPIService::DeleteResource( 504 CancelCallback DriveAPIService::DeleteResource(
505 const std::string& resource_id, 505 const std::string& resource_id,
506 const std::string& etag, 506 const std::string& etag,
507 const EntryActionCallback& callback) { 507 const EntryActionCallback& callback) {
508 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 508 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
509 DCHECK(!callback.is_null()); 509 DCHECK(!callback.is_null());
510 510
511 return sender_->StartRequestWithRetry(new TrashResourceRequest( 511 return sender_->StartRequestWithRetry(new TrashResourceRequest(
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 if (CanSendRequest()) { 754 if (CanSendRequest()) {
755 FOR_EACH_OBSERVER( 755 FOR_EACH_OBSERVER(
756 DriveServiceObserver, observers_, OnReadyToSendRequests()); 756 DriveServiceObserver, observers_, OnReadyToSendRequests());
757 } else if (!HasRefreshToken()) { 757 } else if (!HasRefreshToken()) {
758 FOR_EACH_OBSERVER( 758 FOR_EACH_OBSERVER(
759 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); 759 DriveServiceObserver, observers_, OnRefreshTokenInvalid());
760 } 760 }
761 } 761 }
762 762
763 } // namespace drive 763 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/drive/drive_api_service.h ('k') | chrome/browser/drive/drive_service_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698