OLD | NEW |
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/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
14 #include "base/threading/sequenced_worker_pool.h" | 14 #include "base/threading/sequenced_worker_pool.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/drive/drive_api_util.h" | 16 #include "chrome/browser/drive/drive_api_util.h" |
17 #include "chrome/browser/google_apis/auth_service.h" | 17 #include "chrome/browser/google_apis/auth_service.h" |
18 #include "chrome/browser/google_apis/drive_api_parser.h" | 18 #include "chrome/browser/google_apis/drive_api_parser.h" |
19 #include "chrome/browser/google_apis/drive_api_requests.h" | 19 #include "chrome/browser/google_apis/drive_api_requests.h" |
20 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 20 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
21 #include "chrome/browser/google_apis/request_sender.h" | 21 #include "chrome/browser/google_apis/request_sender.h" |
22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
23 | 23 |
24 using content::BrowserThread; | 24 using content::BrowserThread; |
25 using google_apis::AppList; | 25 using google_apis::AppList; |
26 using google_apis::AuthorizeAppCallback; | 26 using google_apis::AuthorizeAppCallback; |
27 using google_apis::CancelCallback; | 27 using google_apis::CancelCallback; |
28 using google_apis::ChangeList; | 28 using google_apis::ChangeList; |
29 using google_apis::DownloadActionCallback; | 29 using google_apis::DownloadActionCallback; |
30 using google_apis::DownloadFileRequestBase; | |
31 using google_apis::EntryActionCallback; | 30 using google_apis::EntryActionCallback; |
32 using google_apis::FileList; | 31 using google_apis::FileList; |
33 using google_apis::FileResource; | 32 using google_apis::FileResource; |
34 using google_apis::GDATA_OTHER_ERROR; | 33 using google_apis::GDATA_OTHER_ERROR; |
35 using google_apis::GDATA_PARSE_ERROR; | 34 using google_apis::GDATA_PARSE_ERROR; |
36 using google_apis::GDataErrorCode; | 35 using google_apis::GDataErrorCode; |
37 using google_apis::GetAboutRequest; | 36 using google_apis::GetAboutRequest; |
38 using google_apis::GetAboutResourceCallback; | 37 using google_apis::GetAboutResourceCallback; |
39 using google_apis::GetAppListCallback; | 38 using google_apis::GetAppListCallback; |
40 using google_apis::GetApplistRequest; | 39 using google_apis::GetApplistRequest; |
41 using google_apis::GetChangelistRequest; | 40 using google_apis::GetChangelistRequest; |
42 using google_apis::GetContentCallback; | 41 using google_apis::GetContentCallback; |
43 using google_apis::GetFileRequest; | 42 using google_apis::GetFileRequest; |
44 using google_apis::GetFilelistRequest; | 43 using google_apis::GetFilelistRequest; |
45 using google_apis::GetResourceEntryCallback; | 44 using google_apis::GetResourceEntryCallback; |
46 using google_apis::GetResourceListCallback; | 45 using google_apis::GetResourceListCallback; |
47 using google_apis::HTTP_SUCCESS; | 46 using google_apis::HTTP_SUCCESS; |
48 using google_apis::InitiateUploadCallback; | 47 using google_apis::InitiateUploadCallback; |
49 using google_apis::ProgressCallback; | 48 using google_apis::ProgressCallback; |
50 using google_apis::RequestSender; | 49 using google_apis::RequestSender; |
51 using google_apis::ResourceEntry; | 50 using google_apis::ResourceEntry; |
52 using google_apis::ResourceList; | 51 using google_apis::ResourceList; |
53 using google_apis::UploadRangeCallback; | 52 using google_apis::UploadRangeCallback; |
54 using google_apis::UploadRangeResponse; | 53 using google_apis::UploadRangeResponse; |
55 using google_apis::drive::ContinueGetFileListRequest; | 54 using google_apis::drive::ContinueGetFileListRequest; |
56 using google_apis::drive::CopyResourceRequest; | 55 using google_apis::drive::CopyResourceRequest; |
57 using google_apis::drive::CreateDirectoryRequest; | 56 using google_apis::drive::CreateDirectoryRequest; |
58 using google_apis::drive::DeleteResourceRequest; | 57 using google_apis::drive::DeleteResourceRequest; |
| 58 using google_apis::drive::DownloadFileRequest; |
59 using google_apis::drive::GetUploadStatusRequest; | 59 using google_apis::drive::GetUploadStatusRequest; |
60 using google_apis::drive::InitiateUploadExistingFileRequest; | 60 using google_apis::drive::InitiateUploadExistingFileRequest; |
61 using google_apis::drive::InitiateUploadNewFileRequest; | 61 using google_apis::drive::InitiateUploadNewFileRequest; |
62 using google_apis::drive::InsertResourceRequest; | 62 using google_apis::drive::InsertResourceRequest; |
63 using google_apis::drive::RenameResourceRequest; | 63 using google_apis::drive::RenameResourceRequest; |
64 using google_apis::drive::ResumeUploadRequest; | 64 using google_apis::drive::ResumeUploadRequest; |
65 using google_apis::drive::TouchResourceRequest; | 65 using google_apis::drive::TouchResourceRequest; |
66 using google_apis::drive::TrashResourceRequest; | 66 using google_apis::drive::TrashResourceRequest; |
67 | 67 |
68 namespace drive { | 68 namespace drive { |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 DCHECK(!callback.is_null()); | 463 DCHECK(!callback.is_null()); |
464 | 464 |
465 return sender_->StartRequestWithRetry(new GetApplistRequest( | 465 return sender_->StartRequestWithRetry(new GetApplistRequest( |
466 sender_.get(), | 466 sender_.get(), |
467 url_generator_, | 467 url_generator_, |
468 base::Bind(&ParseAppListAndRun, callback))); | 468 base::Bind(&ParseAppListAndRun, callback))); |
469 } | 469 } |
470 | 470 |
471 CancelCallback DriveAPIService::DownloadFile( | 471 CancelCallback DriveAPIService::DownloadFile( |
472 const base::FilePath& local_cache_path, | 472 const base::FilePath& local_cache_path, |
473 const GURL& download_url, | 473 const std::string& resource_id, |
474 const DownloadActionCallback& download_action_callback, | 474 const DownloadActionCallback& download_action_callback, |
475 const GetContentCallback& get_content_callback, | 475 const GetContentCallback& get_content_callback, |
476 const ProgressCallback& progress_callback) { | 476 const ProgressCallback& progress_callback) { |
477 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 477 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
478 DCHECK(!download_action_callback.is_null()); | 478 DCHECK(!download_action_callback.is_null()); |
479 // get_content_callback may be null. | 479 // get_content_callback may be null. |
480 | 480 |
481 // TODO(kinaba): crbug.com/254025: use resource_id based download request. | |
482 return sender_->StartRequestWithRetry( | 481 return sender_->StartRequestWithRetry( |
483 new DownloadFileRequestBase(sender_.get(), | 482 new DownloadFileRequest(sender_.get(), |
484 download_action_callback, | 483 url_generator_, |
485 get_content_callback, | 484 resource_id, |
486 progress_callback, | 485 local_cache_path, |
487 download_url, | 486 download_action_callback, |
488 local_cache_path)); | 487 get_content_callback, |
| 488 progress_callback)); |
489 } | 489 } |
490 | 490 |
491 CancelCallback DriveAPIService::DeleteResource( | 491 CancelCallback DriveAPIService::DeleteResource( |
492 const std::string& resource_id, | 492 const std::string& resource_id, |
493 const std::string& etag, | 493 const std::string& etag, |
494 const EntryActionCallback& callback) { | 494 const EntryActionCallback& callback) { |
495 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 495 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
496 DCHECK(!callback.is_null()); | 496 DCHECK(!callback.is_null()); |
497 | 497 |
498 return sender_->StartRequestWithRetry(new TrashResourceRequest( | 498 return sender_->StartRequestWithRetry(new TrashResourceRequest( |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 if (CanSendRequest()) { | 741 if (CanSendRequest()) { |
742 FOR_EACH_OBSERVER( | 742 FOR_EACH_OBSERVER( |
743 DriveServiceObserver, observers_, OnReadyToSendRequests()); | 743 DriveServiceObserver, observers_, OnReadyToSendRequests()); |
744 } else if (!HasRefreshToken()) { | 744 } else if (!HasRefreshToken()) { |
745 FOR_EACH_OBSERVER( | 745 FOR_EACH_OBSERVER( |
746 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); | 746 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); |
747 } | 747 } |
748 } | 748 } |
749 | 749 |
750 } // namespace drive | 750 } // namespace drive |
OLD | NEW |