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

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

Issue 12387021: Move the responsibility to convert from JSON to FileResource into drive_api_operations. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Minor fix to address review comments. 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
« no previous file with comments | « chrome/browser/google_apis/drive_api_operations_unittest.cc ('k') | no next file » | 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/google_apis/drive_api_service.h" 5 #include "chrome/browser/google_apis/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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 PostTaskAndReplyWithResult( 82 PostTaskAndReplyWithResult(
83 BrowserThread::GetBlockingPool(), 83 BrowserThread::GetBlockingPool(),
84 FROM_HERE, 84 FROM_HERE,
85 base::Bind(&ParseResourceListOnBlockingPool, 85 base::Bind(&ParseResourceListOnBlockingPool,
86 base::Passed(&value), error), 86 base::Passed(&value), error),
87 base::Bind(&DidParseResourceListOnBlockingPool, 87 base::Bind(&DidParseResourceListOnBlockingPool,
88 callback, base::Owned(error))); 88 callback, base::Owned(error)));
89 } 89 }
90 90
91 // Parses the JSON value to ResourceEntry runs |callback|. 91 // Parses the FileResource value to ResourceEntry and runs |callback|.
92 void ParseResourceEntryAndRun( 92 void ParseResourceEntryAndRun(
93 const GetResourceEntryCallback& callback, 93 const GetResourceEntryCallback& callback,
94 GDataErrorCode error, 94 GDataErrorCode error,
95 scoped_ptr<base::Value> value) { 95 scoped_ptr<FileResource> value) {
96 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); 96 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
97 97
98 if (!value) { 98 if (!value) {
99 callback.Run(error, scoped_ptr<ResourceEntry>()); 99 callback.Run(error, scoped_ptr<ResourceEntry>());
100 return; 100 return;
101 } 101 }
102 102
103 // Parsing FileResource is cheap enough to do on UI thread.
104 scoped_ptr<FileResource> file_resource = FileResource::CreateFrom(*value);
105 if (!file_resource) {
106 callback.Run(GDATA_PARSE_ERROR, scoped_ptr<ResourceEntry>());
107 return;
108 }
109
110 // Converting to ResourceEntry is cheap enough to do on UI thread. 103 // Converting to ResourceEntry is cheap enough to do on UI thread.
111 scoped_ptr<ResourceEntry> entry = 104 scoped_ptr<ResourceEntry> entry =
112 ResourceEntry::CreateFromFileResource(*file_resource); 105 ResourceEntry::CreateFromFileResource(*value);
113 if (!entry) { 106 if (!entry) {
114 callback.Run(GDATA_PARSE_ERROR, scoped_ptr<ResourceEntry>()); 107 callback.Run(GDATA_PARSE_ERROR, scoped_ptr<ResourceEntry>());
115 return; 108 return;
116 } 109 }
117 110
118 callback.Run(error, entry.Pass()); 111 callback.Run(error, entry.Pass());
119 } 112 }
120 113
121 // Parses the AboutResource value to AccountMetadataFeed and runs |callback| 114 // Parses the AboutResource value to AccountMetadataFeed and runs |callback|
122 // on the UI thread once parsing is done. 115 // on the UI thread once parsing is done.
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } 557 }
565 558
566 void DriveAPIService::OnProgressUpdate( 559 void DriveAPIService::OnProgressUpdate(
567 const OperationProgressStatusList& list) { 560 const OperationProgressStatusList& list) {
568 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 561 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
569 FOR_EACH_OBSERVER( 562 FOR_EACH_OBSERVER(
570 DriveServiceObserver, observers_, OnProgressUpdate(list)); 563 DriveServiceObserver, observers_, OnProgressUpdate(list));
571 } 564 }
572 565
573 } // namespace google_apis 566 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/drive_api_operations_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698