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

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

Issue 371883003: Files.app: Add an private API to get a download URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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"
(...skipping 26 matching lines...) Expand all
37 using google_apis::EntryActionCallback; 37 using google_apis::EntryActionCallback;
38 using google_apis::FileList; 38 using google_apis::FileList;
39 using google_apis::FileListCallback; 39 using google_apis::FileListCallback;
40 using google_apis::FileResource; 40 using google_apis::FileResource;
41 using google_apis::FileResourceCallback; 41 using google_apis::FileResourceCallback;
42 using google_apis::GDATA_OTHER_ERROR; 42 using google_apis::GDATA_OTHER_ERROR;
43 using google_apis::GDATA_PARSE_ERROR; 43 using google_apis::GDATA_PARSE_ERROR;
44 using google_apis::GDataErrorCode; 44 using google_apis::GDataErrorCode;
45 using google_apis::GetContentCallback; 45 using google_apis::GetContentCallback;
46 using google_apis::GetResourceEntryRequest; 46 using google_apis::GetResourceEntryRequest;
47 using google_apis::GetShareUrlCallback; 47 using google_apis::GetUrlCallback;
48 using google_apis::HTTP_NOT_IMPLEMENTED; 48 using google_apis::HTTP_NOT_IMPLEMENTED;
49 using google_apis::HTTP_SUCCESS; 49 using google_apis::HTTP_SUCCESS;
50 using google_apis::InitiateUploadCallback; 50 using google_apis::InitiateUploadCallback;
51 using google_apis::Link; 51 using google_apis::Link;
52 using google_apis::ProgressCallback; 52 using google_apis::ProgressCallback;
53 using google_apis::RequestSender; 53 using google_apis::RequestSender;
54 using google_apis::UploadRangeResponse; 54 using google_apis::UploadRangeResponse;
55 using google_apis::drive::AboutGetRequest; 55 using google_apis::drive::AboutGetRequest;
56 using google_apis::drive::AppsListRequest; 56 using google_apis::drive::AppsListRequest;
57 using google_apis::drive::ChangesListRequest; 57 using google_apis::drive::ChangesListRequest;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // only the total time matters. However, the server seems to have a time limit 94 // only the total time matters. However, the server seems to have a time limit
95 // per single request, which disables us to set the largest value (1000). 95 // per single request, which disables us to set the largest value (1000).
96 // TODO(kinaba): make it larger when the server gets faster. 96 // TODO(kinaba): make it larger when the server gets faster.
97 const int kMaxNumFilesResourcePerRequest = 300; 97 const int kMaxNumFilesResourcePerRequest = 300;
98 const int kMaxNumFilesResourcePerRequestForSearch = 100; 98 const int kMaxNumFilesResourcePerRequestForSearch = 100;
99 99
100 // For performance, we declare all fields we use. 100 // For performance, we declare all fields we use.
101 const char kAboutResourceFields[] = 101 const char kAboutResourceFields[] =
102 "kind,quotaBytesTotal,quotaBytesUsed,largestChangeId,rootFolderId"; 102 "kind,quotaBytesTotal,quotaBytesUsed,largestChangeId,rootFolderId";
103 const char kFileResourceFields[] = 103 const char kFileResourceFields[] =
104 "kind,id,title,createdDate,sharedWithMeDate,mimeType," 104 "kind,id,title,createdDate,sharedWithMeDate,downloadUrl,mimeType,"
105 "md5Checksum,fileSize,labels/trashed,imageMediaMetadata/width," 105 "md5Checksum,fileSize,labels/trashed,imageMediaMetadata/width,"
106 "imageMediaMetadata/height,imageMediaMetadata/rotation,etag," 106 "imageMediaMetadata/height,imageMediaMetadata/rotation,etag,"
107 "parents(id,parentLink),alternateLink," 107 "parents(id,parentLink),alternateLink,"
108 "modifiedDate,lastViewedByMeDate,shared"; 108 "modifiedDate,lastViewedByMeDate,shared";
109 const char kFileResourceOpenWithLinksFields[] = 109 const char kFileResourceOpenWithLinksFields[] =
110 "kind,id,openWithLinks/*"; 110 "kind,id,openWithLinks/*";
111 const char kFileListFields[] = 111 const char kFileListFields[] =
112 "kind,items(kind,id,title,createdDate,sharedWithMeDate," 112 "kind,items(kind,id,title,createdDate,sharedWithMeDate,downloadUrl,"
kinaba 2014/07/09 06:02:48 If we don't store downloadUrl in ResourceMetadata
hashimoto 2014/07/09 07:48:57 When last time I investigated this, "downloadUrl"
113 "mimeType,md5Checksum,fileSize,labels/trashed,imageMediaMetadata/width," 113 "mimeType,md5Checksum,fileSize,labels/trashed,imageMediaMetadata/width,"
114 "imageMediaMetadata/height,imageMediaMetadata/rotation,etag," 114 "imageMediaMetadata/height,imageMediaMetadata/rotation,etag,"
115 "parents(id,parentLink),alternateLink," 115 "parents(id,parentLink),alternateLink,"
116 "modifiedDate,lastViewedByMeDate,shared),nextLink"; 116 "modifiedDate,lastViewedByMeDate,shared),nextLink";
117 const char kChangeListFields[] = 117 const char kChangeListFields[] =
118 "kind,items(file(kind,id,title,createdDate,sharedWithMeDate," 118 "kind,items(file(kind,id,title,createdDate,sharedWithMeDate,downloadUrl,"
kinaba 2014/07/09 06:02:48 ditto
119 "mimeType,md5Checksum,fileSize,labels/trashed,imageMediaMetadata/width," 119 "mimeType,md5Checksum,fileSize,labels/trashed,imageMediaMetadata/width,"
120 "imageMediaMetadata/height,imageMediaMetadata/rotation,etag," 120 "imageMediaMetadata/height,imageMediaMetadata/rotation,etag,"
121 "parents(id,parentLink),alternateLink,modifiedDate," 121 "parents(id,parentLink),alternateLink,modifiedDate,"
122 "lastViewedByMeDate,shared),deleted,id,fileId,modificationDate),nextLink," 122 "lastViewedByMeDate,shared),deleted,id,fileId,modificationDate),nextLink,"
123 "largestChangeId"; 123 "largestChangeId";
124 124
125 void ExtractOpenUrlAndRun(const std::string& app_id, 125 void ExtractOpenUrlAndRun(const std::string& app_id,
126 const AuthorizeAppCallback& callback, 126 const AuthorizeAppCallback& callback,
127 GDataErrorCode error, 127 GDataErrorCode error,
128 scoped_ptr<FileResource> value) { 128 scoped_ptr<FileResource> value) {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
354 DCHECK(!callback.is_null()); 354 DCHECK(!callback.is_null());
355 355
356 FilesGetRequest* request = new FilesGetRequest( 356 FilesGetRequest* request = new FilesGetRequest(
357 sender_.get(), url_generator_, callback); 357 sender_.get(), url_generator_, callback);
358 request->set_file_id(resource_id); 358 request->set_file_id(resource_id);
359 request->set_fields(kFileResourceFields); 359 request->set_fields(kFileResourceFields);
360 return sender_->StartRequestWithRetry(request); 360 return sender_->StartRequestWithRetry(request);
361 } 361 }
362 362
363 CancelCallback DriveAPIService::GetShareUrl( 363 CancelCallback DriveAPIService::GetShareUrl(const std::string& resource_id,
364 const std::string& resource_id, 364 const GURL& embed_origin,
365 const GURL& embed_origin, 365 const GetUrlCallback& callback) {
366 const GetShareUrlCallback& callback) {
367 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 366 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
368 DCHECK(!callback.is_null()); 367 DCHECK(!callback.is_null());
369 368
370 // Unfortunately "share url" is not yet supported on Drive API v2. 369 // Unfortunately "share url" is not yet supported on Drive API v2.
371 // So, as a fallback, we use GData WAPI protocol for this method. 370 // So, as a fallback, we use GData WAPI protocol for this method.
372 // TODO(hidehiko): Get rid of this implementation when share url is 371 // TODO(hidehiko): Get rid of this implementation when share url is
373 // supported on Drive API v2. 372 // supported on Drive API v2.
374 return sender_->StartRequestWithRetry( 373 return sender_->StartRequestWithRetry(
375 new GetResourceEntryRequest(sender_.get(), 374 new GetResourceEntryRequest(sender_.get(),
376 wapi_url_generator_, 375 wapi_url_generator_,
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 if (CanSendRequest()) { 749 if (CanSendRequest()) {
751 FOR_EACH_OBSERVER( 750 FOR_EACH_OBSERVER(
752 DriveServiceObserver, observers_, OnReadyToSendRequests()); 751 DriveServiceObserver, observers_, OnReadyToSendRequests());
753 } else if (!HasRefreshToken()) { 752 } else if (!HasRefreshToken()) {
754 FOR_EACH_OBSERVER( 753 FOR_EACH_OBSERVER(
755 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); 754 DriveServiceObserver, observers_, OnRefreshTokenInvalid());
756 } 755 }
757 } 756 }
758 757
759 } // namespace drive 758 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698