Commit 895a6f05 authored by George Burgess IV's avatar George Burgess IV Committed by Commit Bot

components: force relative ordering of unsequenced statements

In

```
void foo(std::unique_ptr<Bar> x) {
  x->run(std::move(x));
}
```

The order in which `x->run` is 'evaluated' is unsequenced with the
`move` out of `x` into a param. Force the intended order here by
grabbing the intended pointer in a prior statement.

Bug: None
Change-Id: Iab0af546c6f0640dfc6977256d7a6a55277dbbf0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2202971Reviewed-by: default avatarRachel Blum <groby@chromium.org>
Commit-Queue: George Burgess <gbiv@chromium.org>
Cr-Commit-Position: refs/heads/master@{#778967}
parent 51f874a6
...@@ -377,7 +377,9 @@ void PerFrameContentTranslateDriver::OnPageContents( ...@@ -377,7 +377,9 @@ void PerFrameContentTranslateDriver::OnPageContents(
// Run language detection of contents in a sandboxed utility process. // Run language detection of contents in a sandboxed utility process.
mojo::Remote<language_detection::mojom::LanguageDetectionService> service = mojo::Remote<language_detection::mojom::LanguageDetectionService> service =
language_detection::LaunchLanguageDetectionService(); language_detection::LaunchLanguageDetectionService();
service->DetermineLanguage( // Ensure that we call `service.get()` _before_ moving out of `service` below.
auto* raw_service = service.get();
raw_service->DetermineLanguage(
contents, contents,
base::BindOnce(&PerFrameContentTranslateDriver::OnPageContentsLanguage, base::BindOnce(&PerFrameContentTranslateDriver::OnPageContentsLanguage,
weak_pointer_factory_.GetWeakPtr(), std::move(service))); weak_pointer_factory_.GetWeakPtr(), std::move(service)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment