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

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

Issue 449323002: Revert 288017 "Parse Drive API responses all at once in the bloc..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 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 | « no previous file | trunk/src/chrome/browser/drive/drive_api_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/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/sequenced_task_runner.h"
11 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/task_runner_util.h"
14 #include "base/values.h"
12 #include "chrome/browser/drive/drive_api_util.h" 15 #include "chrome/browser/drive/drive_api_util.h"
13 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
14 #include "google_apis/drive/auth_service.h" 17 #include "google_apis/drive/auth_service.h"
15 #include "google_apis/drive/drive_api_parser.h" 18 #include "google_apis/drive/drive_api_parser.h"
16 #include "google_apis/drive/drive_api_requests.h" 19 #include "google_apis/drive/drive_api_requests.h"
17 #include "google_apis/drive/gdata_errorcode.h" 20 #include "google_apis/drive/gdata_errorcode.h"
18 #include "google_apis/drive/gdata_wapi_parser.h" 21 #include "google_apis/drive/gdata_wapi_parser.h"
19 #include "google_apis/drive/gdata_wapi_requests.h" 22 #include "google_apis/drive/gdata_wapi_requests.h"
20 #include "google_apis/drive/request_sender.h" 23 #include "google_apis/drive/request_sender.h"
21 #include "google_apis/google_api_keys.h" 24 #include "google_apis/google_api_keys.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 if (open_with_links[i].app_id == app_id) { 142 if (open_with_links[i].app_id == app_id) {
140 callback.Run(HTTP_SUCCESS, open_with_links[i].open_url); 143 callback.Run(HTTP_SUCCESS, open_with_links[i].open_url);
141 return; 144 return;
142 } 145 }
143 } 146 }
144 147
145 // Not found. 148 // Not found.
146 callback.Run(GDATA_OTHER_ERROR, GURL()); 149 callback.Run(GDATA_OTHER_ERROR, GURL());
147 } 150 }
148 151
149 void ExtractShareUrlAndRun(const google_apis::GetShareUrlCallback& callback,
150 google_apis::GDataErrorCode error,
151 scoped_ptr<google_apis::ResourceEntry> entry) {
152 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
153
154 const google_apis::Link* share_link =
155 entry ? entry->GetLinkByType(google_apis::Link::LINK_SHARE) : NULL;
156 callback.Run(error, share_link ? share_link->href() : GURL());
157 }
158
159 // Ignores the |entry|, and runs the |callback|. 152 // Ignores the |entry|, and runs the |callback|.
160 void EntryActionCallbackAdapter( 153 void EntryActionCallbackAdapter(
161 const EntryActionCallback& callback, 154 const EntryActionCallback& callback,
162 GDataErrorCode error, scoped_ptr<FileResource> entry) { 155 GDataErrorCode error, scoped_ptr<FileResource> entry) {
163 callback.Run(error); 156 callback.Run(error);
164 } 157 }
165 158
166 // The resource ID for the root directory for Drive API is defined in the spec: 159 // The resource ID for the root directory for Drive API is defined in the spec:
167 // https://developers.google.com/drive/folder 160 // https://developers.google.com/drive/folder
168 const char kDriveApiRootDirectoryResourceId[] = "root"; 161 const char kDriveApiRootDirectoryResourceId[] = "root";
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 369
377 // Unfortunately "share url" is not yet supported on Drive API v2. 370 // Unfortunately "share url" is not yet supported on Drive API v2.
378 // So, as a fallback, we use GData WAPI protocol for this method. 371 // So, as a fallback, we use GData WAPI protocol for this method.
379 // TODO(hidehiko): Get rid of this implementation when share url is 372 // TODO(hidehiko): Get rid of this implementation when share url is
380 // supported on Drive API v2. 373 // supported on Drive API v2.
381 return sender_->StartRequestWithRetry( 374 return sender_->StartRequestWithRetry(
382 new GetResourceEntryRequest(sender_.get(), 375 new GetResourceEntryRequest(sender_.get(),
383 wapi_url_generator_, 376 wapi_url_generator_,
384 resource_id, 377 resource_id,
385 embed_origin, 378 embed_origin,
386 base::Bind(&ExtractShareUrlAndRun, 379 base::Bind(&util::ParseShareUrlAndRun,
387 callback))); 380 callback)));
388 } 381 }
389 382
390 CancelCallback DriveAPIService::GetAboutResource( 383 CancelCallback DriveAPIService::GetAboutResource(
391 const AboutResourceCallback& callback) { 384 const AboutResourceCallback& callback) {
392 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
393 DCHECK(!callback.is_null()); 386 DCHECK(!callback.is_null());
394 387
395 AboutGetRequest* request = 388 AboutGetRequest* request =
396 new AboutGetRequest(sender_.get(), url_generator_, callback); 389 new AboutGetRequest(sender_.get(), url_generator_, callback);
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 if (CanSendRequest()) { 734 if (CanSendRequest()) {
742 FOR_EACH_OBSERVER( 735 FOR_EACH_OBSERVER(
743 DriveServiceObserver, observers_, OnReadyToSendRequests()); 736 DriveServiceObserver, observers_, OnReadyToSendRequests());
744 } else if (!HasRefreshToken()) { 737 } else if (!HasRefreshToken()) {
745 FOR_EACH_OBSERVER( 738 FOR_EACH_OBSERVER(
746 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); 739 DriveServiceObserver, observers_, OnRefreshTokenInvalid());
747 } 740 }
748 } 741 }
749 742
750 } // namespace drive 743 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | trunk/src/chrome/browser/drive/drive_api_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698