forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaw_websocket_handshake_throttle_provider.cc
62 lines (52 loc) · 2.3 KB
/
aw_websocket_handshake_throttle_provider.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "android_webview/renderer/aw_websocket_handshake_throttle_provider.h"
#include <utility>
#include "base/feature_list.h"
#include "base/memory/ptr_util.h"
#include "components/safe_browsing/content/renderer/websocket_sb_handshake_throttle.h"
#include "components/safe_browsing/core/features.h"
#include "content/public/common/content_features.h"
#include "content/public/renderer/render_thread.h"
#include "third_party/blink/public/platform/websocket_handshake_throttle.h"
namespace android_webview {
AwWebSocketHandshakeThrottleProvider::AwWebSocketHandshakeThrottleProvider(
blink::ThreadSafeBrowserInterfaceBrokerProxy* broker) {
DETACH_FROM_THREAD(thread_checker_);
broker->GetInterface(safe_browsing_remote_.InitWithNewPipeAndPassReceiver());
}
AwWebSocketHandshakeThrottleProvider::~AwWebSocketHandshakeThrottleProvider() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
}
AwWebSocketHandshakeThrottleProvider::AwWebSocketHandshakeThrottleProvider(
const AwWebSocketHandshakeThrottleProvider& other) {
DETACH_FROM_THREAD(thread_checker_);
if (other.safe_browsing_) {
other.safe_browsing_->Clone(
safe_browsing_remote_.InitWithNewPipeAndPassReceiver());
}
}
std::unique_ptr<blink::WebSocketHandshakeThrottleProvider>
AwWebSocketHandshakeThrottleProvider::Clone(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (safe_browsing_remote_) {
safe_browsing_.Bind(std::move(safe_browsing_remote_),
std::move(task_runner));
}
return base::WrapUnique(new AwWebSocketHandshakeThrottleProvider(*this));
}
std::unique_ptr<blink::WebSocketHandshakeThrottle>
AwWebSocketHandshakeThrottleProvider::CreateThrottle(
int render_frame_id,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (safe_browsing_remote_) {
safe_browsing_.Bind(std::move(safe_browsing_remote_),
std::move(task_runner));
}
return std::make_unique<safe_browsing::WebSocketSBHandshakeThrottle>(
safe_browsing_.get(), render_frame_id);
}
} // namespace android_webview