Skip to content

Commit

Permalink
Use SEQUENCE_CHECKER in AwURLLoaderThrottleProvider
Browse files Browse the repository at this point in the history
We are planning to conduct an experiment to move Blink's resource
loading logic off the main thread. To run the loading logic in the
background thread using SequencedTaskRunner, we need to replace
THREAD_CHECKER in URLLoaderThrottleProvider with SEQUENCE_CHECKER.

Bug: 1410609
Change-Id: I5619231c226a272e88dba7ed24ad8ed30f0c75e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4764690
Reviewed-by: Bo Liu <boliu@chromium.org>
Commit-Queue: Tsuyoshi Horo <horo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1182354}
  • Loading branch information
horo-t authored and Chromium LUCI CQ committed Aug 10, 2023
1 parent c83d94d commit 89e00b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions android_webview/renderer/aw_url_loader_throttle_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ AwURLLoaderThrottleProvider::AwURLLoaderThrottleProvider(
blink::ThreadSafeBrowserInterfaceBrokerProxy* broker,
blink::URLLoaderThrottleProviderType type)
: type_(type) {
DETACH_FROM_THREAD(thread_checker_);
DETACH_FROM_SEQUENCE(sequence_checker_);
broker->GetInterface(safe_browsing_remote_.InitWithNewPipeAndPassReceiver());
}

AwURLLoaderThrottleProvider::AwURLLoaderThrottleProvider(
const AwURLLoaderThrottleProvider& other)
: type_(other.type_) {
DETACH_FROM_THREAD(thread_checker_);
DETACH_FROM_SEQUENCE(sequence_checker_);
if (other.safe_browsing_) {
other.safe_browsing_->Clone(
safe_browsing_remote_.InitWithNewPipeAndPassReceiver());
Expand All @@ -36,21 +36,21 @@ AwURLLoaderThrottleProvider::AwURLLoaderThrottleProvider(

std::unique_ptr<blink::URLLoaderThrottleProvider>
AwURLLoaderThrottleProvider::Clone() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DETACH_FROM_SEQUENCE(sequence_checker_);
if (safe_browsing_remote_)
safe_browsing_.Bind(std::move(safe_browsing_remote_));
return base::WrapUnique(new AwURLLoaderThrottleProvider(*this));
}

AwURLLoaderThrottleProvider::~AwURLLoaderThrottleProvider() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
}

blink::WebVector<std::unique_ptr<blink::URLLoaderThrottle>>
AwURLLoaderThrottleProvider::CreateThrottles(
int render_frame_id,
const blink::WebURLRequest& request) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);

blink::WebVector<std::unique_ptr<blink::URLLoaderThrottle>> throttles;

Expand Down
9 changes: 5 additions & 4 deletions android_webview/renderer/aw_url_loader_throttle_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef ANDROID_WEBVIEW_RENDERER_AW_URL_LOADER_THROTTLE_PROVIDER_H_
#define ANDROID_WEBVIEW_RENDERER_AW_URL_LOADER_THROTTLE_PROVIDER_H_

#include "base/threading/thread_checker.h"
#include "base/sequence_checker.h"
#include "components/safe_browsing/content/common/safe_browsing.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
Expand All @@ -14,8 +14,9 @@

namespace android_webview {

// Instances must be constructed on the render thread, and then used and
// destructed on a single thread, which can be different from the render thread.
// Instances must be constructed on the render main thread, and then used and
// destructed on a single sequence, which can be different from the render main
// thread.
class AwURLLoaderThrottleProvider : public blink::URLLoaderThrottleProvider {
public:
AwURLLoaderThrottleProvider(
Expand Down Expand Up @@ -44,7 +45,7 @@ class AwURLLoaderThrottleProvider : public blink::URLLoaderThrottleProvider {
mojo::PendingRemote<safe_browsing::mojom::SafeBrowsing> safe_browsing_remote_;
mojo::Remote<safe_browsing::mojom::SafeBrowsing> safe_browsing_;

THREAD_CHECKER(thread_checker_);
SEQUENCE_CHECKER(sequence_checker_);
};

} // namespace android_webview
Expand Down

0 comments on commit 89e00b6

Please sign in to comment.