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

Side by Side Diff: chrome/browser/google_apis/gdata_wapi_service.cc

Issue 11530004: google_apis: DriveServiceInterface::GetResourceEntry() returns ResourceEntry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years 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/google_apis/gdata_wapi_service.h" 5 #include "chrome/browser/google_apis/gdata_wapi_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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return; 100 return;
101 } 101 }
102 102
103 base::PostTaskAndReplyWithResult( 103 base::PostTaskAndReplyWithResult(
104 BrowserThread::GetBlockingPool(), 104 BrowserThread::GetBlockingPool(),
105 FROM_HERE, 105 FROM_HERE,
106 base::Bind(&ParseResourceListOnBlockingPool, base::Passed(&value)), 106 base::Bind(&ParseResourceListOnBlockingPool, base::Passed(&value)),
107 base::Bind(&DidParseResourceListOnBlockingPool, callback, error)); 107 base::Bind(&DidParseResourceListOnBlockingPool, callback, error));
108 } 108 }
109 109
110 // Parses the JSON value to ResourceEntry runs |callback|.
111 void ParseResourceEntryAndRun(const GetResourceEntryCallback& callback,
112 GDataErrorCode error,
113 scoped_ptr<base::Value> value) {
114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
115
116 if (!value) {
117 callback.Run(error, scoped_ptr<ResourceEntry>());
118 return;
119 }
120
121 // Parsing ResourceEntry is cheap enough to do on UI thread.
122 scoped_ptr<ResourceEntry> entry =
123 google_apis::ResourceEntry::ExtractAndParse(*value);
124 if (!entry) {
125 callback.Run(GDATA_PARSE_ERROR, scoped_ptr<ResourceEntry>());
126 return;
127 }
128
129 callback.Run(error, entry.Pass());
130 }
131
110 // OAuth2 scopes for the documents API. 132 // OAuth2 scopes for the documents API.
111 const char kDocsListScope[] = "https://docs.google.com/feeds/"; 133 const char kDocsListScope[] = "https://docs.google.com/feeds/";
112 const char kSpreadsheetsScope[] = "https://spreadsheets.google.com/feeds/"; 134 const char kSpreadsheetsScope[] = "https://spreadsheets.google.com/feeds/";
113 const char kUserContentScope[] = "https://docs.googleusercontent.com/"; 135 const char kUserContentScope[] = "https://docs.googleusercontent.com/";
114 const char kDriveAppsScope[] = "https://www.googleapis.com/auth/drive.apps"; 136 const char kDriveAppsScope[] = "https://www.googleapis.com/auth/drive.apps";
115 137
116 } // namespace 138 } // namespace
117 139
118 GDataWapiService::GDataWapiService( 140 GDataWapiService::GDataWapiService(
119 net::URLRequestContextGetter* url_request_context_getter, 141 net::URLRequestContextGetter* url_request_context_getter,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 url, 228 url,
207 static_cast<int>(start_changestamp), 229 static_cast<int>(start_changestamp),
208 search_query, 230 search_query,
209 shared_with_me, 231 shared_with_me,
210 directory_resource_id, 232 directory_resource_id,
211 base::Bind(&ParseResourceListAndRun, callback))); 233 base::Bind(&ParseResourceListAndRun, callback)));
212 } 234 }
213 235
214 void GDataWapiService::GetResourceEntry( 236 void GDataWapiService::GetResourceEntry(
215 const std::string& resource_id, 237 const std::string& resource_id,
216 const GetDataCallback& callback) { 238 const GetResourceEntryCallback& callback) {
217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 239 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
218 DCHECK(!callback.is_null()); 240 DCHECK(!callback.is_null());
219 241
220 runner_->StartOperationWithRetry( 242 runner_->StartOperationWithRetry(
221 new GetResourceEntryOperation(operation_registry(), 243 new GetResourceEntryOperation(
222 url_request_context_getter_, 244 operation_registry(),
223 url_generator_, 245 url_request_context_getter_,
224 resource_id, 246 url_generator_,
225 callback)); 247 resource_id,
248 base::Bind(&ParseResourceEntryAndRun, callback)));
226 } 249 }
227 250
228 void GDataWapiService::GetAccountMetadata(const GetDataCallback& callback) { 251 void GDataWapiService::GetAccountMetadata(const GetDataCallback& callback) {
229 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
230 DCHECK(!callback.is_null()); 253 DCHECK(!callback.is_null());
231 254
232 runner_->StartOperationWithRetry( 255 runner_->StartOperationWithRetry(
233 new GetAccountMetadataOperation(operation_registry(), 256 new GetAccountMetadataOperation(operation_registry(),
234 url_request_context_getter_, 257 url_request_context_getter_,
235 url_generator_, 258 url_generator_,
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 DriveServiceObserver, observers_, OnProgressUpdate(list)); 470 DriveServiceObserver, observers_, OnProgressUpdate(list));
448 } 471 }
449 472
450 void GDataWapiService::OnAuthenticationFailed(GDataErrorCode error) { 473 void GDataWapiService::OnAuthenticationFailed(GDataErrorCode error) {
451 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 474 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
452 FOR_EACH_OBSERVER( 475 FOR_EACH_OBSERVER(
453 DriveServiceObserver, observers_, OnAuthenticationFailed(error)); 476 DriveServiceObserver, observers_, OnAuthenticationFailed(error));
454 } 477 }
455 478
456 } // namespace google_apis 479 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/gdata_wapi_service.h ('k') | chrome/browser/google_apis/mock_drive_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698