OSSCA Chromium

기여 목록 / 8427279

chrome/browser/component_updater: migrate to crypto/hash APIs

BrowserrefactorMerged

chrome/browser/component_updater의 7개 파일에서 폐기 예정인 crypto/sha2.h를 crypto/hash.h로 마이그레이션한 컨트리뷰션입니다.

문제 설명

  • crypto/sha2.h는 제거 예정이며 헤더에 명시되어 있음
    • This interface is deprecated and being removed: https://crbug.com/374310081
    • New users should use crypto/hash instead.
  • chrome/browser/component_updater 아래 7개 파일이 여전히 이 헤더를 include
  • crypto::kSHA256Length 사용 8곳 (전부 static_assert 또는 DCHECK 내부)

해결 내용

  1. include 교체: crypto/sha2.h → crypto/hash.h (6개 파일)
  2. 상수 치환: crypto::kSHA256Length → crypto::hash::kSha256Size (8곳)
  3. translate_kit_component_installer.cc는 include만 있고 crypto:: 사용처가 없어 제거만 수행
- static_assert(std::size(kSodaPublicKeySHA256) == crypto::kSHA256Length);
+ static_assert(std::size(kSodaPublicKeySHA256) == crypto::hash::kSha256Size);
  • 반환 타입이 달라지는 SHA256Hash / SHA256HashString 호출은 이 범위에 없어 상수 치환만으로 완결
  • crypto/hash.h와 crypto/sha2.h 모두 component("crypto") 타겟 소속이라 BUILD.gn·DEPS 변경 불필요
    • chrome/browser/component_updater/DEPS에 crypto 항목 없음을 확인 (다른 멘티 CL에서 DEPS 누락이 CQ 실패로 이어진 사례가 있어 선확인)

테스트 방법

  1. autoninja -C out/Default chrome unit_tests 빌드 통과
  2. ./out/Default/unit_tests --gtest_filter="PlatformRuntimeComponentInstallerTest*:RegisterTranslateKitComponentTest*" → 11/11 통과
  3. git cl format --dry-run 통과
  4. CQ dry-run 통과 (멘토 요청)
    • cros_component_installer_chromeos.cc는 BUILD.gn에서 is_chromeos 가드라 macOS 로컬 빌드에 미포함 → 이 파일만 CQ 봇에서 검증

배운 점

  • 체크아웃이 크게 밀린 상태에서 rebase 시 소스와 도구 버전이 어긋날 수 있음
    • .gn이 설정하는 변수를 구버전 gn 바이너리가 인식하지 못해 gn gen 실패
    • gn은 CIPD가 관리하므로 git rebase로 갱신되지 않음. gclient sync 필요
  • conflict 해결 시 업스트림 변경을 보존하는 판단이 필요
    • 상수가 kPublicKeySHA256 → kLegacyBaseModelPublicKeySHA256으로 개명되어 있어 개명분을 살리고 타입만 치환
    • 업스트림이 제거한 include(network_service_instance.h)는 되살리지 않음
  • CL 제목은 변경 대상 디렉터리를 접두어로 사용하는 것이 관례
    • 우산 이슈 제목(//crypto: ...)을 그대로 쓰면 실제 변경 위치와 어긋남

참고 자료