|
|
Chromium Code Reviews
DescriptionThis CL includes only code refactoring.
Eliminate DetectorType enum in ShapeDetector.cpp. The real work (calling
through mojo interface Detect()) is moved to FaceDetector and BarcodeDetector
respectively, so that ShapeDetector only does the shared work of processing
image source.
BUG=646083, 659139
Committed: https://crrev.com/cf153f33a517e34fdc48026c45a87bd3314b9400
Cr-Commit-Position: refs/heads/master@{#436856}
Patch Set 1 #
Total comments: 2
Patch Set 2 : Remove state info from parent class, add doDetect() pure virtual method. #
Total comments: 16
Patch Set 3 : reillyg@ comments #Patch Set 4 : Add utility function: getSharedBufferOnData() #
Total comments: 5
Patch Set 5 : Move tainting logic into detect() #
Messages
Total messages: 70 (54 generated)
The CQ bit was checked by xianglu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== ShapeDetection: Eliminate DetectorType in ShapeDetector.cpp BUG=646083, 659139 ========== to ========== This CL includes only code refactoring. Eliminate DetectorType in ShapeDetector.cpp. The real work (calling through mojo interface Detect()) is moved to FaceDetector and BarcodeDetector,respectively, so that ShapeDetector only does the shared work of processing image source. BUG=646083, 659139 ==========
Description was changed from ========== This CL includes only code refactoring. Eliminate DetectorType in ShapeDetector.cpp. The real work (calling through mojo interface Detect()) is moved to FaceDetector and BarcodeDetector,respectively, so that ShapeDetector only does the shared work of processing image source. BUG=646083, 659139 ========== to ========== This CL includes only code refactoring. Eliminate DetectorType in ShapeDetector.cpp. The real work (calling through mojo interface Detect()) is moved to FaceDetector and BarcodeDetector, respectively, so that ShapeDetector only does the shared work of processing image source. BUG=646083, 659139 ==========
Description was changed from ========== This CL includes only code refactoring. Eliminate DetectorType in ShapeDetector.cpp. The real work (calling through mojo interface Detect()) is moved to FaceDetector and BarcodeDetector, respectively, so that ShapeDetector only does the shared work of processing image source. BUG=646083, 659139 ========== to ========== This CL includes only code refactoring. Eliminate DetectorType argument in ShapeDetector.cpp. The real work (calling through mojo interface Detect()) is moved to FaceDetector and BarcodeDetector respectively, so that ShapeDetector only does the shared work of processing image source. BUG=646083, 659139 ==========
Description was changed from ========== This CL includes only code refactoring. Eliminate DetectorType argument in ShapeDetector.cpp. The real work (calling through mojo interface Detect()) is moved to FaceDetector and BarcodeDetector respectively, so that ShapeDetector only does the shared work of processing image source. BUG=646083, 659139 ========== to ========== This CL includes only code refactoring. Eliminate DetectorType argument in ShapeDetector.cpp. The real work (calling through mojo interface Detect()) is moved to FaceDetector and BarcodeDetector respectively, so that ShapeDetector only does the shared work of processing image source. BUG=646083, 659139 ==========
The CQ bit was checked by xianglu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== This CL includes only code refactoring. Eliminate DetectorType argument in ShapeDetector.cpp. The real work (calling through mojo interface Detect()) is moved to FaceDetector and BarcodeDetector respectively, so that ShapeDetector only does the shared work of processing image source. BUG=646083, 659139 ========== to ========== This CL includes only code refactoring. Eliminate DetectorType enum in ShapeDetector.cpp. The real work (calling through mojo interface Detect()) is moved to FaceDetector and BarcodeDetector respectively, so that ShapeDetector only does the shared work of processing image source. BUG=646083, 659139 ==========
Patchset #1 (id:1) has been deleted
xianglu@chromium.org changed reviewers: + mcasas@chromium.org
PTAL.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Looking good, but still some more moving things around needed. https://codereview.chromium.org/2557513003/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp (right): https://codereview.chromium.org/2557513003/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp:146: m_imageHeight = img->naturalHeight(); Instead of holding on to |m_sharedBufferHandle|, |m_imageWidth| and |m_imageHeight|, add a virtual ScriptPromise DoDetect(mojo::SharedBufferHandle, int, int) = 0; and implement it in {Barcode/Face}Detector (e.g. it'd encompass the current l.40-52); here you'd just need a return DoDetect(...); In this way you can keep the signature (and name) of these methods: plus it's more robust to return a Promise than a boolean, since in the latter case the caller must parse a true/false and then trust the method to have updated correctly the Promise by means of the Resolver...
The CQ bit was checked by xianglu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by xianglu@chromium.org to run a CQ dry run
Patchset #2 (id:40001) has been deleted
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
PTAL. https://codereview.chromium.org/2557513003/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp (right): https://codereview.chromium.org/2557513003/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp:146: m_imageHeight = img->naturalHeight(); On 2016/12/06 04:40:20, mcasas wrote: > Instead of holding on to |m_sharedBufferHandle|, > |m_imageWidth| and |m_imageHeight|, add a > virtual ScriptPromise DoDetect(mojo::SharedBufferHandle, int, int) = 0; > > and implement it in {Barcode/Face}Detector (e.g. it'd > encompass the current l.40-52); here you'd just need a > return DoDetect(...); > > In this way you can keep the signature (and name) of > these methods: plus it's more robust to return a > Promise than a boolean, since in the latter case the > caller must parse a true/false and then trust the method > to have updated correctly the Promise by means > of the Resolver... Done.
The CQ bit was checked by xianglu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
reillyg@chromium.org changed reviewers: + reillyg@chromium.org
https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/shapedetection/BarcodeDetector.cpp (right): https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/BarcodeDetector.cpp:22: DCHECK(!m_barcodeService.is_bound()); Just DCHECK(!m_barcodeService), though in the constructor it seems like this is check is superfluous. https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/BarcodeDetector.cpp:46: sharedBufferHandle.reset(); This line should be a no-op because std::move(sharedBufferHandle) will have invalidated this variable. https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/shapedetection/BarcodeDetector.h (right): https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/BarcodeDetector.h:36: int); Blink style allows unnamed parameters when the type name makes the variable name redundant. Here it is unclear so please name your parameters. https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp (right): https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp:25: DCHECK(!m_faceService.is_bound()); Same comment. https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp:50: sharedBufferHandle.reset(); Same comment here. https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/shapedetection/FaceDetector.h (right): https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/FaceDetector.h:37: int); Same comment here. https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp (right): https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp:77: resolver, static_cast<HTMLImageElement*>(imageSourceInternal)); It seems to me that since this set of if statements mirror toImageSourceInternal()'s logic we could avoid these casts by just calling the methods like imageSource.getAsHTMLImageElement() here. https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/shapedetection/ShapeDetector.h (right): https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/ShapeDetector.h:41: int) = 0; Same comment.
Patchset #3 (id:60002) has been deleted
Patchset #3 (id:90001) has been deleted
The CQ bit was checked by xianglu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by xianglu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Patchset #3 (id:110001) has been deleted
The CQ bit was checked by xianglu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Patchset #3 (id:130001) has been deleted
The CQ bit was checked by xianglu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by xianglu@chromium.org to run a CQ dry run
Patchset #4 (id:170001) has been deleted
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
PTAL. https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/shapedetection/BarcodeDetector.cpp (right): https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/BarcodeDetector.cpp:22: DCHECK(!m_barcodeService.is_bound()); On 2016/12/06 20:40:12, Reilly Grant wrote: > Just DCHECK(!m_barcodeService), though in the constructor it seems like this is > check is superfluous. Done. https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/BarcodeDetector.cpp:46: sharedBufferHandle.reset(); On 2016/12/06 20:40:12, Reilly Grant wrote: > This line should be a no-op because std::move(sharedBufferHandle) will have > invalidated this variable. Done. https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/shapedetection/BarcodeDetector.h (right): https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/BarcodeDetector.h:36: int); On 2016/12/06 20:40:12, Reilly Grant wrote: > Blink style allows unnamed parameters when the type name makes the variable name > redundant. Here it is unclear so please name your parameters. Done. https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp (right): https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp:25: DCHECK(!m_faceService.is_bound()); On 2016/12/06 20:40:13, Reilly Grant wrote: > Same comment. Done. https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp:50: sharedBufferHandle.reset(); On 2016/12/06 20:40:13, Reilly Grant wrote: > Same comment here. Done. https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/shapedetection/FaceDetector.h (right): https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/FaceDetector.h:37: int); On 2016/12/06 20:40:13, Reilly Grant wrote: > Same comment here. Done. https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp (right): https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp:77: resolver, static_cast<HTMLImageElement*>(imageSourceInternal)); On 2016/12/06 20:40:13, Reilly Grant wrote: > It seems to me that since this set of if statements mirror > toImageSourceInternal()'s logic we could avoid these casts by just calling the > methods like imageSource.getAsHTMLImageElement() here. Removed duplicated logic. I think the only trade-off here is that since wouldTaintOrigin() only works on an explicit canvas source, the elements need to be checked separately in their detectShapesOn...(). https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/modules/shapedetection/ShapeDetector.h (right): https://codereview.chromium.org/2557513003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/modules/shapedetection/ShapeDetector.h:41: int) = 0; On 2016/12/06 20:40:13, Reilly Grant wrote: > Same comment. Done.
lgtm with the comment addressed. https://codereview.chromium.org/2557513003/diff/190001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp (right): https://codereview.chromium.org/2557513003/diff/190001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp:61: return detectShapesOnImageElement(scriptState, resolver, Hmm after removing toImageSourceInternal() you have to pass ScriptState* scriptState to each method and replicate the tainting logic: if (bla->wouldTaintOrigin( scriptState->getExecutionContext()->getSecurityOrigin())) { resolver->reject( DOMException::create(SecurityError, "Source would taint origin.")); return promise; } which is very unfortunate. Instead, leave static CanvasImageSource* toImageSourceInternal( as it was but, like reillyg@ suggests, use the appropriate imageSource.getAsFoo() methods instead of the static_cast<>s
https://codereview.chromium.org/2557513003/diff/190001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp (right): https://codereview.chromium.org/2557513003/diff/190001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp:45: m_faceDetectorOptions.Clone(), Just a note for the future, we could add the options to the IPC used to acquire m_faceService so that it doesn't have to be sent with every detection request. This means we would add a Mojo service FaceDetectorProvider which has a method: Create(FaceDetector& request, FaceDetectorOptions options); https://codereview.chromium.org/2557513003/diff/190001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp (right): https://codereview.chromium.org/2557513003/diff/190001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp:64: !static_cast<ImageBitmap*>(imageSource.getAsImageBitmap()) getAsImageBitmap() already returns an ImageBitmap* so no cast is necessary. I would write this as: } else if (imageSource.isImageBitmap()) { ImageBitmap* imageBitmap = imageSource.getAsImageBitmap(); if (!imageBitmap.isNeutered()) { return detectShapesOnImageBitmap(scriptState, resolver, imageBitmap); } } ...
https://codereview.chromium.org/2557513003/diff/190001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp (right): https://codereview.chromium.org/2557513003/diff/190001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp:61: return detectShapesOnImageElement(scriptState, resolver, On 2016/12/06 at 22:50:12, mcasas wrote: > Hmm after removing toImageSourceInternal() > you have to pass ScriptState* scriptState to > each method and replicate the tainting logic: > > if (bla->wouldTaintOrigin( > scriptState->getExecutionContext()->getSecurityOrigin())) { > resolver->reject( > DOMException::create(SecurityError, "Source would taint origin.")); > return promise; > } > > which is very unfortunate. Instead, leave > static CanvasImageSource* toImageSourceInternal( > as it was but, like reillyg@ suggests, use the > appropriate > imageSource.getAsFoo() > methods instead of the static_cast<>s How about: CanvasImageSource* canvasImageSource; if (imageSource.isFoo()) { canvasImageSource = imageSource.asFoo(); } else if ... { } else { NOTIMPLEMENTED etc from below. } // tainting logic on canvasImageSource if (imageSource.isFoo()) { return detectAsFoo(); } else if ...
https://codereview.chromium.org/2557513003/diff/190001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp (right): https://codereview.chromium.org/2557513003/diff/190001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp:61: return detectShapesOnImageElement(scriptState, resolver, On 2016/12/06 23:03:42, Reilly Grant wrote: > On 2016/12/06 at 22:50:12, mcasas wrote: > > Hmm after removing toImageSourceInternal() > > you have to pass ScriptState* scriptState to > > each method and replicate the tainting logic: > > > > if (bla->wouldTaintOrigin( > > scriptState->getExecutionContext()->getSecurityOrigin())) { > > resolver->reject( > > DOMException::create(SecurityError, "Source would taint origin.")); > > return promise; > > } > > > > which is very unfortunate. Instead, leave > > static CanvasImageSource* toImageSourceInternal( > > as it was but, like reillyg@ suggests, use the > > appropriate > > imageSource.getAsFoo() > > methods instead of the static_cast<>s > > How about: > > CanvasImageSource* canvasImageSource; > if (imageSource.isFoo()) { > canvasImageSource = imageSource.asFoo(); > } else if ... { > > } else { > NOTIMPLEMENTED etc from below. > } > > // tainting logic on canvasImageSource > > if (imageSource.isFoo()) { > return detectAsFoo(); > } else if ... That looks nice, works for me!
The CQ bit was checked by xianglu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: ios-device on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device/builds...)
The CQ bit was checked by xianglu@chromium.org to run a CQ dry run
Patchset #5 (id:210001) has been deleted
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by xianglu@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Patchset #5 (id:230001) has been deleted
reillyg@ PTAL.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: ios-device on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device/builds...)
lgtm
xianglu@chromium.org changed reviewers: + haraken@chromium.org
haraken@ PTAL.
LGTM
The CQ bit was checked by xianglu@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from mcasas@chromium.org Link to the patchset: https://codereview.chromium.org/2557513003/#ps240001 (title: "Move tainting logic into detect()")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 240001, "attempt_start_ts": 1481074183857670,
"parent_rev": "ea00ff7f6d8b4a9557e6dce562235eb68042cccc", "commit_rev":
"bcaf7d826df9938910d429c6862fcc3393808358"}
Message was sent while issue was closed.
Description was changed from ========== This CL includes only code refactoring. Eliminate DetectorType enum in ShapeDetector.cpp. The real work (calling through mojo interface Detect()) is moved to FaceDetector and BarcodeDetector respectively, so that ShapeDetector only does the shared work of processing image source. BUG=646083, 659139 ========== to ========== This CL includes only code refactoring. Eliminate DetectorType enum in ShapeDetector.cpp. The real work (calling through mojo interface Detect()) is moved to FaceDetector and BarcodeDetector respectively, so that ShapeDetector only does the shared work of processing image source. BUG=646083, 659139 ==========
Message was sent while issue was closed.
Committed patchset #5 (id:240001)
Message was sent while issue was closed.
Description was changed from ========== This CL includes only code refactoring. Eliminate DetectorType enum in ShapeDetector.cpp. The real work (calling through mojo interface Detect()) is moved to FaceDetector and BarcodeDetector respectively, so that ShapeDetector only does the shared work of processing image source. BUG=646083, 659139 ========== to ========== This CL includes only code refactoring. Eliminate DetectorType enum in ShapeDetector.cpp. The real work (calling through mojo interface Detect()) is moved to FaceDetector and BarcodeDetector respectively, so that ShapeDetector only does the shared work of processing image source. BUG=646083, 659139 Committed: https://crrev.com/cf153f33a517e34fdc48026c45a87bd3314b9400 Cr-Commit-Position: refs/heads/master@{#436856} ==========
Message was sent while issue was closed.
Patchset 5 (id:??) landed as https://crrev.com/cf153f33a517e34fdc48026c45a87bd3314b9400 Cr-Commit-Position: refs/heads/master@{#436856} |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
