|
|
Created:
7 years, 11 months ago by hidehiko Modified:
7 years, 11 months ago CC:
chromium-reviews, achuith+watch_chromium.org, oshima+watch_chromium.org, stevenjb+watch_chromium.org, nkostylev+watch_chromium.org, davemoore+watch_chromium.org Base URL:
http://git.chromium.org/chromium/src.git@master Visibility:
Public. |
DescriptionRun parsing JSON into ResourceList on blocking pool.
This CL moves the parsing JSON task from UI thread to blocking pool.
Along the change, thin struct OnParseResourceListCompletedParams is introduced
for memory management and adapt callback arguments.
BUG=165088
TEST=Ran unit_tests and chromeos_unittests.
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=175793
Patch Set 1 #Patch Set 2 : Add more descriptive comments. #
Total comments: 2
Patch Set 3 : use base::Passed(scoped_ptr*) instead of base::Passed(scoped_ptr::RValue). #
Total comments: 6
Patch Set 4 : Rename completion callback. #Patch Set 5 : Remove DidParseResourceListOnBlockingPoolParams. #Patch Set 6 : Rebase #Messages
Total messages: 13 (0 generated)
Thank you for your review in advance, - hidehiko
lgtm with a nit. https://codereview.chromium.org/11783025/diff/2001/chrome/browser/chromeos/dr... File chrome/browser/chromeos/drive/drive_api_service.cc (right): https://codereview.chromium.org/11783025/diff/2001/chrome/browser/chromeos/dr... chrome/browser/chromeos/drive/drive_api_service.cc:92: base::Passed(value.Pass()), params), You can use base::Passed(&value).
Thank you for your review. https://codereview.chromium.org/11783025/diff/2001/chrome/browser/chromeos/dr... File chrome/browser/chromeos/drive/drive_api_service.cc (right): https://codereview.chromium.org/11783025/diff/2001/chrome/browser/chromeos/dr... chrome/browser/chromeos/drive/drive_api_service.cc:92: base::Passed(value.Pass()), params), On 2013/01/08 11:53:16, kinaba wrote: > You can use base::Passed(&value). Good to know. Thank you!
https://codereview.chromium.org/11783025/diff/5001/chrome/browser/chromeos/dr... File chrome/browser/chromeos/drive/drive_api_service.cc (right): https://codereview.chromium.org/11783025/diff/5001/chrome/browser/chromeos/dr... chrome/browser/chromeos/drive/drive_api_service.cc:70: void OnParseResourceListCompleted( Please rename this to DidParseResourceListOnBlockingPool. This naming convention, just adding "Did" is easier. https://codereview.chromium.org/11783025/diff/5001/chrome/browser/chromeos/dr... chrome/browser/chromeos/drive/drive_api_service.cc:83: new OnParseResourceListCompletedParams; I think you don't need a struct.
Could you take another look? https://codereview.chromium.org/11783025/diff/5001/chrome/browser/chromeos/dr... File chrome/browser/chromeos/drive/drive_api_service.cc (right): https://codereview.chromium.org/11783025/diff/5001/chrome/browser/chromeos/dr... chrome/browser/chromeos/drive/drive_api_service.cc:70: void OnParseResourceListCompleted( On 2013/01/09 00:25:20, satorux1 wrote: > Please rename this to DidParseResourceListOnBlockingPool. > > This naming convention, just adding "Did" is easier. Done. https://codereview.chromium.org/11783025/diff/5001/chrome/browser/chromeos/dr... chrome/browser/chromeos/drive/drive_api_service.cc:83: new OnParseResourceListCompletedParams; On 2013/01/09 00:25:20, satorux1 wrote: > I think you don't need a struct. At the moment we need, IMHO, though there are some alternatives: 1) Run callback if value is NULL here immediately. (though, handling the callback would be distributed in this method and DidParseResourceListOnBlockingPool). 2) Overwrite the error code with GDATA_PARSE_ERROR if value is NULL. Then we can remove error code handling in ParseResourceListOnBlockingPool so that we can remove params here. (I'm not very sure if we can overwrite it or not, though.) 3) Check if error code is HTTP_SUCCESS or not in DidParseResourceListOnBlockingPool. If so, and the parsing is failed (i.e. ParseResourceListOnBlockingPool returns NULL), overwrite error code with GDATA_PARSE_ERROR. 4) Pass the ownership of |value| to DidParseResourceListOnBlockingPool, instead give ParseResourceListOnBlockingPool the raw pointer to |value|. So that DidParseResourceListOnBlockingPool can know if the parsing is failed, or JSON value was empty (though the handling code may be less clear). 5) Use new for google_apis::GDataErrorCode and scoped_ptr<google_apis::ResourceList> individually, here. Then pass their ownership to the DidParseResourceListOnBlockingPool. 6) Keep the current structure (use the struct). 7) something else? Which is better in this project?
https://codereview.chromium.org/11783025/diff/5001/chrome/browser/chromeos/dr... File chrome/browser/chromeos/drive/drive_api_service.cc (right): https://codereview.chromium.org/11783025/diff/5001/chrome/browser/chromeos/dr... chrome/browser/chromeos/drive/drive_api_service.cc:83: new OnParseResourceListCompletedParams; On 2013/01/09 05:21:51, hidehiko wrote: > On 2013/01/09 00:25:20, satorux1 wrote: > > I think you don't need a struct. > > At the moment we need, IMHO, though there are some alternatives: > 1) Run callback if value is NULL here immediately. (though, handling the > callback would be distributed in this method and > DidParseResourceListOnBlockingPool). > 2) Overwrite the error code with GDATA_PARSE_ERROR if value is NULL. Then we can > remove error code handling in ParseResourceListOnBlockingPool so that we can > remove params here. (I'm not very sure if we can overwrite it or not, though.) > 3) Check if error code is HTTP_SUCCESS or not in > DidParseResourceListOnBlockingPool. If so, and the parsing is failed (i.e. > ParseResourceListOnBlockingPool returns NULL), overwrite error code with > GDATA_PARSE_ERROR. > 4) Pass the ownership of |value| to DidParseResourceListOnBlockingPool, instead > give ParseResourceListOnBlockingPool the raw pointer to |value|. So that > DidParseResourceListOnBlockingPool can know if the parsing is failed, or JSON > value was empty (though the handling code may be less clear). > 5) Use new for google_apis::GDataErrorCode and > scoped_ptr<google_apis::ResourceList> individually, here. Then pass their > ownership to the DidParseResourceListOnBlockingPool. > 6) Keep the current structure (use the struct). > 7) something else? > > Which is better in this project? I thought we could do something like: google_apis::GDataErrorCode* error = new google_apis::GDataErrorCode(in_error); base::PostTaskAndReplyWithResult( BrowserThread::GetBlockingPool(), FROM_HERE, base::Bind(&ParseResourceListOnBlockingPool, base::Passed(&value), error), base::Bind(&DidParseResourceListOnBlockingPool, callback, base::Owned(error))); scoped_ptr<ResourceList> ParseResourceListOnBlockingPool( scoped_ptr<base::Value> value, GDataErrorCode* error) { ... return resource_list.Pass(); } void DidParseResourceListOnBlockingPool( const google_apis::GetResourceListCallback& callback, GDataErrorCode* error, scoped_ptr<ResourceList> resource_list) callback.Run(*error, resource_list.Pass()); }
Couold you take another look? https://codereview.chromium.org/11783025/diff/5001/chrome/browser/chromeos/dr... File chrome/browser/chromeos/drive/drive_api_service.cc (right): https://codereview.chromium.org/11783025/diff/5001/chrome/browser/chromeos/dr... chrome/browser/chromeos/drive/drive_api_service.cc:83: new OnParseResourceListCompletedParams; On 2013/01/09 05:34:15, satorux1 wrote: > On 2013/01/09 05:21:51, hidehiko wrote: > > On 2013/01/09 00:25:20, satorux1 wrote: > > > I think you don't need a struct. > > > > At the moment we need, IMHO, though there are some alternatives: > > 1) Run callback if value is NULL here immediately. (though, handling the > > callback would be distributed in this method and > > DidParseResourceListOnBlockingPool). > > 2) Overwrite the error code with GDATA_PARSE_ERROR if value is NULL. Then we > can > > remove error code handling in ParseResourceListOnBlockingPool so that we can > > remove params here. (I'm not very sure if we can overwrite it or not, though.) > > 3) Check if error code is HTTP_SUCCESS or not in > > DidParseResourceListOnBlockingPool. If so, and the parsing is failed (i.e. > > ParseResourceListOnBlockingPool returns NULL), overwrite error code with > > GDATA_PARSE_ERROR. > > 4) Pass the ownership of |value| to DidParseResourceListOnBlockingPool, > instead > > give ParseResourceListOnBlockingPool the raw pointer to |value|. So that > > DidParseResourceListOnBlockingPool can know if the parsing is failed, or JSON > > value was empty (though the handling code may be less clear). > > 5) Use new for google_apis::GDataErrorCode and > > scoped_ptr<google_apis::ResourceList> individually, here. Then pass their > > ownership to the DidParseResourceListOnBlockingPool. > > 6) Keep the current structure (use the struct). > > 7) something else? > > > > Which is better in this project? > > I thought we could do something like: > > google_apis::GDataErrorCode* error = new > google_apis::GDataErrorCode(in_error); > base::PostTaskAndReplyWithResult( > BrowserThread::GetBlockingPool(), > FROM_HERE, > base::Bind(&ParseResourceListOnBlockingPool, base::Passed(&value), error), > base::Bind(&DidParseResourceListOnBlockingPool, callback, > base::Owned(error))); > > scoped_ptr<ResourceList> ParseResourceListOnBlockingPool( > scoped_ptr<base::Value> value, > GDataErrorCode* error) { > ... > > return resource_list.Pass(); > } > > > void DidParseResourceListOnBlockingPool( > const google_apis::GetResourceListCallback& callback, > GDataErrorCode* error, > scoped_ptr<ResourceList> resource_list) > callback.Run(*error, resource_list.Pass()); > } > I see. Done.
LGTM. Thanks!
Thank you, Satoru, for you review. Rebased. Kazuhiro, could you kindly take a look, too?
On 2013/01/09 11:31:01, hidehiko wrote: > Thank you, Satoru, for you review. > > Rebased. Kazuhiro, could you kindly take a look, too? Still LGTM. Thanks!
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/hidehiko@chromium.org/11783025/18001
Message was sent while issue was closed.
Change committed as 175793 |