Implement EmulatedSmartCardContextFactory interception logic. [chromium/src : main]

0 views
Skip to first unread message

Paulina Gacek (Gerrit)

unread,
Jan 12, 2026, 6:03:29 AM (5 days ago) Jan 12
to Alex Moshchuk, Zgroza (Luke) Klimek, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Zgroza (Luke) Klimek

Paulina Gacek removed Alex Moshchuk from this change

Deleted Reviewers:
  • Alex Moshchuk
Open in Gerrit

Related details

Attention is currently required from:
  • Zgroza (Luke) Klimek
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: deleteReviewer
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Id86d1608d759b0e80681d2bb215a2ec66bff447a
Gerrit-Change-Number: 7378813
Gerrit-PatchSet: 12
Gerrit-Owner: Paulina Gacek <paulin...@google.com>
Gerrit-Reviewer: Paulina Gacek <paulin...@google.com>
Gerrit-Reviewer: Zgroza (Luke) Klimek <zgr...@chromium.org>
Gerrit-Attention: Zgroza (Luke) Klimek <zgr...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Patryk Chodur (Gerrit)

unread,
Jan 14, 2026, 5:18:35 AM (3 days ago) Jan 14
to Paulina Gacek, Zgroza (Luke) Klimek, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Paulina Gacek and Zgroza (Luke) Klimek

Patryk Chodur added 3 comments

File content/browser/smart_card/emulation/emulated_smart_card_context_factory.h
Line 69, Patchset 12 (Latest): std::map<std::string, std::unique_ptr<PendingRequest>> pending_requests_;
Patryk Chodur . unresolved

Could you please use `std::unordered_map`? It's usually way faster and should be the default unless you specifically need `std::map` (for example if data needs to be sorted).

File content/browser/smart_card/emulation/emulated_smart_card_context_factory.cc
Line 98, Patchset 12 (Latest): auto* req = static_cast<PendingListReaders*>(base_req.get());
Patryk Chodur . unresolved

Why do we need a `static_cast` here? It's UB if we get it wrong. Maybe there could be two containers with concrete types (`PendingCreateContext` and `PendingListReaders`), or just a single class instead of both `PendingCreateContext` and `PendingListReaders`?

Line 112, Patchset 12 (Latest): auto* req = static_cast<PendingCreateContext*>(base_req.get());
Patryk Chodur . unresolved

Same as above.

Open in Gerrit

Related details

Attention is currently required from:
  • Paulina Gacek
  • Zgroza (Luke) Klimek
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id86d1608d759b0e80681d2bb215a2ec66bff447a
    Gerrit-Change-Number: 7378813
    Gerrit-PatchSet: 12
    Gerrit-Owner: Paulina Gacek <paulin...@google.com>
    Gerrit-Reviewer: Patryk Chodur <pch...@google.com>
    Gerrit-Reviewer: Paulina Gacek <paulin...@google.com>
    Gerrit-Reviewer: Zgroza (Luke) Klimek <zgr...@chromium.org>
    Gerrit-Attention: Paulina Gacek <paulin...@google.com>
    Gerrit-Attention: Zgroza (Luke) Klimek <zgr...@chromium.org>
    Gerrit-Comment-Date: Wed, 14 Jan 2026 10:18:22 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Paulina Gacek (Gerrit)

    unread,
    Jan 15, 2026, 5:01:20 AM (2 days ago) Jan 15
    to Patryk Chodur, Zgroza (Luke) Klimek, Chromium LUCI CQ, chromium...@chromium.org
    Attention needed from Patryk Chodur and Zgroza (Luke) Klimek

    Paulina Gacek added 3 comments

    File content/browser/smart_card/emulation/emulated_smart_card_context_factory.h
    Line 69, Patchset 12: std::map<std::string, std::unique_ptr<PendingRequest>> pending_requests_;
    Patryk Chodur . resolved

    Could you please use `std::unordered_map`? It's usually way faster and should be the default unless you specifically need `std::map` (for example if data needs to be sorted).

    Paulina Gacek

    Done

    File content/browser/smart_card/emulation/emulated_smart_card_context_factory.cc
    Line 98, Patchset 12: auto* req = static_cast<PendingListReaders*>(base_req.get());
    Patryk Chodur . resolved

    Why do we need a `static_cast` here? It's UB if we get it wrong. Maybe there could be two containers with concrete types (`PendingCreateContext` and `PendingListReaders`), or just a single class instead of both `PendingCreateContext` and `PendingListReaders`?

    Paulina Gacek

    Good point, thanks. To avoid UB without introducing multiple maps (which would become messy as I add more request types later), I added a type tag to the base class. The code now verifies the request type explicitly before casting.

    Line 112, Patchset 12: auto* req = static_cast<PendingCreateContext*>(base_req.get());
    Patryk Chodur . resolved

    Same as above.

    Paulina Gacek

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Patryk Chodur
    • Zgroza (Luke) Klimek
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Id86d1608d759b0e80681d2bb215a2ec66bff447a
      Gerrit-Change-Number: 7378813
      Gerrit-PatchSet: 13
      Gerrit-Owner: Paulina Gacek <paulin...@google.com>
      Gerrit-Reviewer: Patryk Chodur <pch...@google.com>
      Gerrit-Reviewer: Paulina Gacek <paulin...@google.com>
      Gerrit-Reviewer: Zgroza (Luke) Klimek <zgr...@chromium.org>
      Gerrit-Attention: Patryk Chodur <pch...@google.com>
      Gerrit-Attention: Zgroza (Luke) Klimek <zgr...@chromium.org>
      Gerrit-Comment-Date: Thu, 15 Jan 2026 10:01:06 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Patryk Chodur <pch...@google.com>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Patryk Chodur (Gerrit)

      unread,
      Jan 15, 2026, 5:22:06 AM (2 days ago) Jan 15
      to Paulina Gacek, Zgroza (Luke) Klimek, Chromium LUCI CQ, chromium...@chromium.org
      Attention needed from Paulina Gacek and Zgroza (Luke) Klimek

      Patryk Chodur voted Code-Review+1

      Code-Review+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Paulina Gacek
      • Zgroza (Luke) Klimek
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Id86d1608d759b0e80681d2bb215a2ec66bff447a
        Gerrit-Change-Number: 7378813
        Gerrit-PatchSet: 13
        Gerrit-Owner: Paulina Gacek <paulin...@google.com>
        Gerrit-Reviewer: Patryk Chodur <pch...@google.com>
        Gerrit-Reviewer: Paulina Gacek <paulin...@google.com>
        Gerrit-Reviewer: Zgroza (Luke) Klimek <zgr...@chromium.org>
        Gerrit-Attention: Paulina Gacek <paulin...@google.com>
        Gerrit-Attention: Zgroza (Luke) Klimek <zgr...@chromium.org>
        Gerrit-Comment-Date: Thu, 15 Jan 2026 10:21:52 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Zgroza (Luke) Klimek (Gerrit)

        unread,
        Jan 16, 2026, 11:19:52 AM (yesterday) Jan 16
        to Paulina Gacek, Patryk Chodur, Chromium LUCI CQ, chromium...@chromium.org
        Attention needed from Paulina Gacek

        Zgroza (Luke) Klimek added 4 comments

        Commit Message
        Line 7, Patchset 15 (Latest):Implement EmulatedSmartCardContextFactory interception logic.
        Zgroza (Luke) Klimek . unresolved

        Nit: I would prefer saying something like
        ```suggestion
        Implement EmulatedSmartCardContextFactory CDP implementation.
        ```
        since, unless I see something wrong, there's not yet any actual interception here yet, just the implementation of a thing that will be intercepting when the interception logic is here.

        Line 7, Patchset 15 (Latest):Implement EmulatedSmartCardContextFactory interception logic.
        Zgroza (Luke) Klimek . unresolved

        Can You add `SmartCardEmulation: ...` to CL titles in this entire chain, as well as the corresponding hashtag (I think this will be added automatically but idk)? It helps with finding CLs relevant to a feature.

        File content/browser/BUILD.gn
        Line 2561, Patchset 15 (Latest): # TODO(crbug.com/470349523): Migrate more smart card files to use this flag.
        Zgroza (Luke) Klimek . unresolved

        Actually, can this entire block be merged with [those](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/BUILD.gn;l=2670;drc=e6b9ce5422805a5459232191b770d746a525e15e), either by moving it or moving those file inclusions here? It'd be nice to have all the smart card files included here in the same place.

        File content/browser/smart_card/emulation/emulated_smart_card_context_factory.h
        Line 43, Patchset 15 (Latest): void OnListReaders(
        Zgroza (Luke) Klimek . unresolved

        I have a feeling that those methods belong in `EmulatedSmartCardContext` class, as those functionalities depend on the context. Why are they here?

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Paulina Gacek
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Id86d1608d759b0e80681d2bb215a2ec66bff447a
          Gerrit-Change-Number: 7378813
          Gerrit-PatchSet: 15
          Gerrit-Owner: Paulina Gacek <paulin...@google.com>
          Gerrit-Reviewer: Patryk Chodur <pch...@google.com>
          Gerrit-Reviewer: Paulina Gacek <paulin...@google.com>
          Gerrit-Reviewer: Zgroza (Luke) Klimek <zgr...@chromium.org>
          Gerrit-Attention: Paulina Gacek <paulin...@google.com>
          Gerrit-Comment-Date: Fri, 16 Jan 2026 16:19:32 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Zgroza (Luke) Klimek (Gerrit)

          unread,
          7:53 AM (5 hours ago) 7:53 AM
          to Paulina Gacek, Patryk Chodur, Chromium LUCI CQ, chromium...@chromium.org
          Attention needed from Paulina Gacek

          Zgroza (Luke) Klimek added 4 comments

          File content/browser/smart_card/emulation/emulated_smart_card_context_factory.h
          Line 78, Patchset 15 (Latest): raw_ptr<EmulatedSmartCardNotifier> notifier_;
          Zgroza (Luke) Klimek . unresolved

          I... don't particularly like `raw_ptr`s. What is the lifetime of `EmulatedSmartCardNotifier`, what owns it? (In here just tests, but what will own it by design in the future?)

          If this is trivially correct here, please at least add a comment on why. Otherwise, depending on the ownership, maybe `WeakPtr` or something?

          Line 43, Patchset 15 (Latest): void OnListReaders(
          Zgroza (Luke) Klimek . unresolved

          I have a feeling that those methods belong in `EmulatedSmartCardContext` class, as those functionalities depend on the context. Why are they here?

          Zgroza (Luke) Klimek

          To add to this: if the reason is that this class is currently the only one that has access to the `notifier_`, I have a feeling that this might not be a good choice from the single responsibility perspective (this class is responsible not only for creating `Context`s, but also for relaying all the responses from the other classes).

          In essence, I think that `notifier_` probably should be directly accessible from all of the classes that have the functionality of notifying, having `EmulatedSmartCardContextFactory` as universal proxy for this is not in line with its purpose.

          Line 29, Patchset 15 (Latest): // The handler must outlive this factory.
          Zgroza (Luke) Klimek . unresolved

          As below, what will ensure this?

          File content/test/BUILD.gn
          Line 3419, Patchset 15 (Latest): if (enable_smart_card) {
          Zgroza (Luke) Klimek . unresolved
          Gerrit-Comment-Date: Sat, 17 Jan 2026 12:53:20 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Zgroza (Luke) Klimek <zgr...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy
          Reply all
          Reply to author
          Forward
          0 new messages