aw_render_thread_observer.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (c) 2012 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. #include "android_webview/renderer/aw_render_thread_observer.h"
  5. #include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
  6. #include "third_party/blink/public/platform/web_cache.h"
  7. #include "third_party/blink/public/platform/web_network_state_notifier.h"
  8. namespace android_webview {
  9. AwRenderThreadObserver::AwRenderThreadObserver() {
  10. }
  11. AwRenderThreadObserver::~AwRenderThreadObserver() {
  12. }
  13. void AwRenderThreadObserver::RegisterMojoInterfaces(
  14. blink::AssociatedInterfaceRegistry* associated_interfaces) {
  15. // base::Unretained can be used here because the associated_interfaces
  16. // is owned by the RenderThread and will live for the duration of the
  17. // RenderThread.
  18. associated_interfaces->AddInterface<mojom::Renderer>(
  19. base::BindRepeating(&AwRenderThreadObserver::OnRendererAssociatedRequest,
  20. base::Unretained(this)));
  21. }
  22. void AwRenderThreadObserver::UnregisterMojoInterfaces(
  23. blink::AssociatedInterfaceRegistry* associated_interfaces) {
  24. associated_interfaces->RemoveInterface(mojom::Renderer::Name_);
  25. }
  26. void AwRenderThreadObserver::OnRendererAssociatedRequest(
  27. mojo::PendingAssociatedReceiver<mojom::Renderer> receiver) {
  28. receiver_.Bind(std::move(receiver));
  29. }
  30. void AwRenderThreadObserver::ClearCache() {
  31. blink::WebCache::Clear();
  32. }
  33. void AwRenderThreadObserver::SetJsOnlineProperty(bool network_up) {
  34. blink::WebNetworkStateNotifier::SetOnLine(network_up);
  35. }
  36. } // namespace android_webview