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

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

Issue 10693109: Use Drive v2 API: enable behind --enable-drive-api flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove boolean use_drive_api Created 8 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/chromeos/gdata/gdata_operations.h" 5 #include "chrome/browser/chromeos/gdata/gdata_operations.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 "https://docs.google.com/feeds/default/private/full"; 60 "https://docs.google.com/feeds/default/private/full";
61 61
62 // URL requesting single document entry whose resource id is specified by "%s". 62 // URL requesting single document entry whose resource id is specified by "%s".
63 const char kGetDocumentEntryURLFormat[] = 63 const char kGetDocumentEntryURLFormat[] =
64 "https://docs.google.com/feeds/default/private/full/%s"; 64 "https://docs.google.com/feeds/default/private/full/%s";
65 65
66 // Metadata feed with things like user quota. 66 // Metadata feed with things like user quota.
67 const char kAccountMetadataURL[] = 67 const char kAccountMetadataURL[] =
68 "https://docs.google.com/feeds/metadata/default"; 68 "https://docs.google.com/feeds/metadata/default";
69 69
70 const char kDriveV2AboutURL[] =
71 "https://www.googleapis.com/drive/v2/about";
72
70 const char kUploadContentRange[] = "Content-Range: bytes "; 73 const char kUploadContentRange[] = "Content-Range: bytes ";
71 const char kUploadContentType[] = "X-Upload-Content-Type: "; 74 const char kUploadContentType[] = "X-Upload-Content-Type: ";
72 const char kUploadContentLength[] = "X-Upload-Content-Length: "; 75 const char kUploadContentLength[] = "X-Upload-Content-Length: ";
73 76
74 #ifndef NDEBUG 77 #ifndef NDEBUG
75 // Use smaller 'page' size while debugging to ensure we hit feed reload 78 // Use smaller 'page' size while debugging to ensure we hit feed reload
76 // almost always. Be careful not to use something too small on account that 79 // almost always. Be careful not to use something too small on account that
77 // have many items because server side 503 error might kick in. 80 // have many items because server side 503 error might kick in.
78 const int kMaxDocumentsPerFeed = 1000; 81 const int kMaxDocumentsPerFeed = 1000;
79 #else 82 #else
80 const int kMaxDocumentsPerFeed = 1000; 83 const int kMaxDocumentsPerFeed = 1000;
81 #endif 84 #endif
82 85
83 // Maximum number of attempts for re-authentication per operation. 86 // Maximum number of attempts for re-authentication per operation.
84 const int kMaxReAuthenticateAttemptsPerOperation = 1; 87 const int kMaxReAuthenticateAttemptsPerOperation = 1;
85 88
86 const char kFeedField[] = "feed"; 89 const char kFeedField[] = "feed";
87 90
88 // Templates for file uploading. 91 // Templates for file uploading.
89 const char kUploadParamConvertKey[] = "convert"; 92 const char kUploadParamConvertKey[] = "convert";
90 const char kUploadParamConvertValue[] = "false"; 93 const char kUploadParamConvertValue[] = "false";
91 const char kUploadResponseLocation[] = "location"; 94 const char kUploadResponseLocation[] = "location";
92 const char kUploadResponseRange[] = "range"; 95 const char kUploadResponseRange[] = "range";
93 96
94 // OAuth scope for the documents API. 97 // OAuth scope for the documents API.
95 const char kDocsListScope[] = "https://docs.google.com/feeds/"; 98 const char kDocsListScope[] = "https://docs.google.com/feeds/";
96 const char kSpreadsheetsScope[] = "https://spreadsheets.google.com/feeds/"; 99 const char kSpreadsheetsScope[] = "https://spreadsheets.google.com/feeds/";
97 const char kUserContentScope[] = "https://docs.googleusercontent.com/"; 100 const char kUserContentScope[] = "https://docs.googleusercontent.com/";
98 101
102 // OAuth scope for Google Drive v2 API
103 // See https://developers.google.com/drive/scopes.
104 // Tokens with scope https://docs.google.com/feeds are accepted and treated
105 // the same as tokens with scope https://www.googleapis.com/auth/drive and
106 // this is not necessary for the migration period.
107 const char kDriveScope[] = "https://www.googleapis.com/auth/drive";
108
99 // Adds additional parameters for API version, output content type and to show 109 // Adds additional parameters for API version, output content type and to show
100 // folders in the feed are added to document feed URLs. 110 // folders in the feed are added to document feed URLs.
101 GURL AddStandardUrlParams(const GURL& url) { 111 GURL AddStandardUrlParams(const GURL& url) {
102 GURL result = 112 GURL result =
103 chrome_common_net::AppendOrReplaceQueryParameter(url, "v", "3"); 113 chrome_common_net::AppendOrReplaceQueryParameter(url, "v", "3");
104 result = 114 result =
105 chrome_common_net::AppendOrReplaceQueryParameter(result, "alt", "json"); 115 chrome_common_net::AppendOrReplaceQueryParameter(result, "alt", "json");
106 return result; 116 return result;
107 } 117 }
108 118
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 GetAccountMetadataOperation::GetAccountMetadataOperation( 576 GetAccountMetadataOperation::GetAccountMetadataOperation(
567 GDataOperationRegistry* registry, 577 GDataOperationRegistry* registry,
568 Profile* profile, 578 Profile* profile,
569 const GetDataCallback& callback) 579 const GetDataCallback& callback)
570 : GetDataOperation(registry, profile, callback) { 580 : GetDataOperation(registry, profile, callback) {
571 } 581 }
572 582
573 GetAccountMetadataOperation::~GetAccountMetadataOperation() {} 583 GetAccountMetadataOperation::~GetAccountMetadataOperation() {}
574 584
575 GURL GetAccountMetadataOperation::GetURL() const { 585 GURL GetAccountMetadataOperation::GetURL() const {
576 return AddMetadataUrlParams(GURL(kAccountMetadataURL)); 586 return gdata::util::IsDriveV2ApiEnabled() ?
587 GURL(kDriveV2AboutURL) : AddMetadataUrlParams(GURL(kAccountMetadataURL));
577 } 588 }
satorux1 2012/07/12 07:49:06 Not sure if it's worth sharing GetAccountMetadataO
kochi 2012/07/13 10:33:52 gdata_operations.cc split is done: https://src.chr
578 589
579 //============================ DownloadFileOperation =========================== 590 //============================ DownloadFileOperation ===========================
580 591
581 DownloadFileOperation::DownloadFileOperation( 592 DownloadFileOperation::DownloadFileOperation(
582 GDataOperationRegistry* registry, 593 GDataOperationRegistry* registry,
583 Profile* profile, 594 Profile* profile,
584 const DownloadActionCallback& download_action_callback, 595 const DownloadActionCallback& download_action_callback,
585 const GetDownloadDataCallback& get_download_data_callback, 596 const GetDownloadDataCallback& get_download_data_callback,
586 const GURL& document_url, 597 const GURL& document_url,
587 const FilePath& virtual_path, 598 const FilePath& virtual_path,
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 return true; 1236 return true;
1226 } 1237 }
1227 1238
1228 void ResumeUploadOperation::OnURLFetchUploadProgress( 1239 void ResumeUploadOperation::OnURLFetchUploadProgress(
1229 const net::URLFetcher* source, int64 current, int64 total) { 1240 const net::URLFetcher* source, int64 current, int64 total) {
1230 // Adjust the progress values according to the range currently uploaded. 1241 // Adjust the progress values according to the range currently uploaded.
1231 NotifyProgress(params_.start_range + current, params_.content_length); 1242 NotifyProgress(params_.start_range + current, params_.content_length);
1232 } 1243 }
1233 1244
1234 } // namespace gdata 1245 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698