context_url.cc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2019 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 "gpu/ipc/service/context_url.h"
  5. #include <utility>
  6. #include "base/hash/hash.h"
  7. #include "components/crash/core/common/crash_key.h"
  8. namespace gpu {
  9. // static
  10. void ContextUrl::SetActiveUrl(const gpu::ContextUrl& active_url) {
  11. bool is_chrome = active_url.url().scheme() == "chrome";
  12. {
  13. static crash_reporter::CrashKeyString<128> crash_key(
  14. "gpu-url-chunk-chrome");
  15. crash_key.Set(is_chrome ? active_url.url().possibly_invalid_spec() : "");
  16. }
  17. if (is_chrome)
  18. return;
  19. // Skip setting crash key when URL hash hasn't changed.
  20. static size_t last_url_hash = 0;
  21. if (active_url.hash() == last_url_hash)
  22. return;
  23. last_url_hash = active_url.hash();
  24. // Note that the url is intentionally excluded from WebView and WebLayer
  25. // crash dumps using an allowlist for privacy reasons. See
  26. // kWebViewCrashKeyAllowList and kWebLayerCrashKeyAllowList.
  27. {
  28. static crash_reporter::CrashKeyString<1024> crash_key("gpu-url-chunk");
  29. crash_key.Set(active_url.url().possibly_invalid_spec());
  30. }
  31. }
  32. ContextUrl::ContextUrl(GURL url)
  33. : url_(std::move(url)),
  34. url_hash_(base::Hash(url_.possibly_invalid_spec())) {}
  35. } // namespace gpu