aw_websocket_handshake_throttle_provider.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ANDROID_WEBVIEW_RENDERER_AW_WEBSOCKET_HANDSHAKE_THROTTLE_PROVIDER_H_
  5. #define ANDROID_WEBVIEW_RENDERER_AW_WEBSOCKET_HANDSHAKE_THROTTLE_PROVIDER_H_
  6. #include <memory>
  7. #include "base/threading/thread_checker.h"
  8. #include "components/safe_browsing/content/common/safe_browsing.mojom.h"
  9. #include "mojo/public/cpp/bindings/pending_remote.h"
  10. #include "mojo/public/cpp/bindings/remote.h"
  11. #include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h"
  12. #include "third_party/blink/public/platform/websocket_handshake_throttle_provider.h"
  13. namespace android_webview {
  14. // This must be constructed on the render thread, and then used and destructed
  15. // on a single thread, which can be different from the render thread.
  16. class AwWebSocketHandshakeThrottleProvider final
  17. : public blink::WebSocketHandshakeThrottleProvider {
  18. public:
  19. explicit AwWebSocketHandshakeThrottleProvider(
  20. blink::ThreadSafeBrowserInterfaceBrokerProxy* broker);
  21. AwWebSocketHandshakeThrottleProvider& operator=(
  22. const AwWebSocketHandshakeThrottleProvider&) = delete;
  23. ~AwWebSocketHandshakeThrottleProvider() override;
  24. // Implements blink::WebSocketHandshakeThrottleProvider.
  25. std::unique_ptr<blink::WebSocketHandshakeThrottleProvider> Clone(
  26. scoped_refptr<base::SingleThreadTaskRunner> task_runner) override;
  27. std::unique_ptr<blink::WebSocketHandshakeThrottle> CreateThrottle(
  28. int render_frame_id,
  29. scoped_refptr<base::SingleThreadTaskRunner> task_runner) override;
  30. private:
  31. // This copy constructor works in conjunction with Clone(), not intended for
  32. // general use.
  33. AwWebSocketHandshakeThrottleProvider(
  34. const AwWebSocketHandshakeThrottleProvider& other);
  35. mojo::PendingRemote<safe_browsing::mojom::SafeBrowsing> safe_browsing_remote_;
  36. mojo::Remote<safe_browsing::mojom::SafeBrowsing> safe_browsing_;
  37. THREAD_CHECKER(thread_checker_);
  38. };
  39. } // namespace android_webview
  40. #endif // ANDROID_WEBVIEW_RENDERER_AW_WEBSOCKET_HANDSHAKE_THROTTLE_PROVIDER_H_