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

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

Issue 12388017: Move the responsibility to convert from JSON to AccountMetadata into gdata_wapi_operations. (Closed) Base URL: http://git.chromium.org/chromium/src.git@b148632_gdata_wapi_get_about_resource_impl
Patch Set: Created 7 years, 9 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
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 scoped_ptr<ResourceEntry> entry = 87 scoped_ptr<ResourceEntry> entry =
88 google_apis::ResourceEntry::ExtractAndParse(*value); 88 google_apis::ResourceEntry::ExtractAndParse(*value);
89 if (!entry) { 89 if (!entry) {
90 callback.Run(GDATA_PARSE_ERROR, scoped_ptr<ResourceEntry>()); 90 callback.Run(GDATA_PARSE_ERROR, scoped_ptr<ResourceEntry>());
91 return; 91 return;
92 } 92 }
93 93
94 callback.Run(error, entry.Pass()); 94 callback.Run(error, entry.Pass());
95 } 95 }
96 96
97 // Parses the JSON value to AccountMetadataFeed on the blocking pool and runs
98 // |callback| on the UI thread once parsing is done.
99 void ParseAccounetMetadataAndRun(const GetAccountMetadataCallback& callback,
100 GDataErrorCode error,
101 scoped_ptr<base::Value> value) {
102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
103 DCHECK(!callback.is_null());
104
105 if (!value) {
106 callback.Run(error, scoped_ptr<AccountMetadataFeed>());
107 return;
108 }
109
110 // Parsing AccountMetadataFeed is cheap enough to do on UI thread.
111 scoped_ptr<AccountMetadataFeed> entry =
112 google_apis::AccountMetadataFeed::CreateFrom(*value);
113 if (!entry) {
114 callback.Run(GDATA_PARSE_ERROR, scoped_ptr<AccountMetadataFeed>());
115 return;
116 }
117
118 callback.Run(error, entry.Pass());
119 }
120
121 // Extracts the open link url from the JSON Feed. Used by AuthorizeApp(). 97 // Extracts the open link url from the JSON Feed. Used by AuthorizeApp().
122 void ExtractOpenLinkAndRun(const std::string app_id, 98 void ExtractOpenLinkAndRun(const std::string app_id,
123 const AuthorizeAppCallback& callback, 99 const AuthorizeAppCallback& callback,
124 GDataErrorCode error, 100 GDataErrorCode error,
125 scoped_ptr<ResourceEntry> entry) { 101 scoped_ptr<ResourceEntry> entry) {
126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
127 103
128 // Entry not found in the feed. 104 // Entry not found in the feed.
129 if (!entry) { 105 if (!entry) {
130 callback.Run(error, GURL()); 106 callback.Run(error, GURL());
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 void GDataWapiService::GetAccountMetadata( 250 void GDataWapiService::GetAccountMetadata(
275 const GetAccountMetadataCallback& callback) { 251 const GetAccountMetadataCallback& callback) {
276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
277 DCHECK(!callback.is_null()); 253 DCHECK(!callback.is_null());
278 254
279 runner_->StartOperationWithRetry( 255 runner_->StartOperationWithRetry(
280 new GetAccountMetadataOperation( 256 new GetAccountMetadataOperation(
281 operation_registry(), 257 operation_registry(),
282 url_request_context_getter_, 258 url_request_context_getter_,
283 url_generator_, 259 url_generator_,
284 base::Bind(&ParseAccounetMetadataAndRun, callback))); 260 callback));
285 } 261 }
286 262
287 void GDataWapiService::GetAboutResource( 263 void GDataWapiService::GetAboutResource(
288 const GetAboutResourceCallback& callback) { 264 const GetAboutResourceCallback& callback) {
289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 265 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
290 DCHECK(!callback.is_null()); 266 DCHECK(!callback.is_null());
291 267
292 // TODO(hidehiko): Implement this. 268 // TODO(hidehiko): Implement this.
293 NOTREACHED(); 269 NOTREACHED();
294 } 270 }
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 } 541 }
566 542
567 void GDataWapiService::OnProgressUpdate( 543 void GDataWapiService::OnProgressUpdate(
568 const OperationProgressStatusList& list) { 544 const OperationProgressStatusList& list) {
569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
570 FOR_EACH_OBSERVER( 546 FOR_EACH_OBSERVER(
571 DriveServiceObserver, observers_, OnProgressUpdate(list)); 547 DriveServiceObserver, observers_, OnProgressUpdate(list));
572 } 548 }
573 549
574 } // namespace google_apis 550 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/gdata_wapi_operations_unittest.cc ('k') | chrome/browser/google_apis/test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698