[remoting] Make SessionOptions strongly typed [chromium/src : main]

0 views
Skip to first unread message

Yuwei Huang (Gerrit)

unread,
Jul 31, 2026, 10:13:40 PM (2 days ago) Jul 31
to chromium...@chromium.org, chromotin...@chromium.org

Yuwei Huang added 2 comments

File remoting/base/session_options.cc
Line 66, Patchset 2 (Latest): {"Enable-Sck-Capturer", nullptr},
Yuwei Huang . unresolved

Is there a reason you need to map unsupported keys to `nullptr`? If you remove these then you could also remove null checks and simplify the code.

Line 112, Patchset 2 (Latest): return std::nullopt;
Yuwei Huang . unresolved

In the old logic, we unsupported keys are technically just ignored. Is there a reason you just short-circuit here and return nullopt? I guess allowing it to be half-parsed could be important for compatibility.

Thinking more about this, maybethis function should not be nullable. In the worse case, it may just return an empty `SessionOptions`. WDYT?

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement 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: Icb4c445e8715fb2398c36f345656f85111b86a0c
Gerrit-Change-Number: 8183649
Gerrit-PatchSet: 2
Gerrit-Owner: Yuwei Huang <yuw...@chromium.org>
Gerrit-Comment-Date: Sat, 01 Aug 2026 02:13:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Yuwei Huang (Gerrit)

unread,
Jul 31, 2026, 11:48:27 PM (2 days ago) Jul 31
to Chromium LUCI CQ, chromium...@chromium.org, chromotin...@chromium.org

Yuwei Huang added 3 comments

File remoting/base/session_options.cc
Line 46, Patchset 4 (Latest):std::ostream& operator<<(std::ostream& os, const std::optional<T>& opt) {
Yuwei Huang . unresolved

It is generally discouraged to define operators for `std::` types (like `std::optional`), even locally in an anonymous namespace, as it can occasionally lead to ambiguous overload errors if a future header eventually introduces one.

Since this is just for formatting fields, you could format them directly inside `SessionOptions::operator<<` (or use a named helper function like `PrintOptional`) to avoid defining a global-like operator for a standard type.

Line 66, Patchset 2: {"Enable-Sck-Capturer", nullptr},
Yuwei Huang . resolved

Is there a reason you need to map unsupported keys to `nullptr`? If you remove these then you could also remove null checks and simplify the code.

Yuwei Huang

Done

Line 112, Patchset 2: return std::nullopt;
Yuwei Huang . resolved

In the old logic, we unsupported keys are technically just ignored. Is there a reason you just short-circuit here and return nullopt? I guess allowing it to be half-parsed could be important for compatibility.

Thinking more about this, maybethis function should not be nullable. In the worse case, it may just return an empty `SessionOptions`. WDYT?

Yuwei Huang

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement 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: Icb4c445e8715fb2398c36f345656f85111b86a0c
Gerrit-Change-Number: 8183649
Gerrit-PatchSet: 4
Gerrit-Owner: Yuwei Huang <yuw...@chromium.org>
Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
Gerrit-Comment-Date: Sat, 01 Aug 2026 03:48:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Yuwei Huang <yuw...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Yuwei Huang (Gerrit)

unread,
Aug 1, 2026, 12:19:47 AM (yesterday) Aug 1
to Joe Downing, Chromium LUCI CQ, chromium...@chromium.org, chromotin...@chromium.org
Attention needed from Joe Downing

Yuwei Huang voted and added 2 comments

Votes added by Yuwei Huang

Commit-Queue+1

2 comments

Patchset-level comments
File-level comment, Patchset 5 (Latest):
Yuwei Huang . resolved

PTAL thanks!

File remoting/base/session_options.cc
Line 46, Patchset 4:std::ostream& operator<<(std::ostream& os, const std::optional<T>& opt) {
Yuwei Huang . resolved

It is generally discouraged to define operators for `std::` types (like `std::optional`), even locally in an anonymous namespace, as it can occasionally lead to ambiguous overload errors if a future header eventually introduces one.

Since this is just for formatting fields, you could format them directly inside `SessionOptions::operator<<` (or use a named helper function like `PrintOptional`) to avoid defining a global-like operator for a standard type.

Yuwei Huang

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Joe Downing
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement 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: Icb4c445e8715fb2398c36f345656f85111b86a0c
    Gerrit-Change-Number: 8183649
    Gerrit-PatchSet: 5
    Gerrit-Owner: Yuwei Huang <yuw...@chromium.org>
    Gerrit-Reviewer: Joe Downing <joe...@chromium.org>
    Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
    Gerrit-Attention: Joe Downing <joe...@chromium.org>
    Gerrit-Comment-Date: Sat, 01 Aug 2026 04:19:32 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Yuwei Huang <yuw...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Joe Downing (Gerrit)

    unread,
    Aug 1, 2026, 4:19:56 PM (15 hours ago) Aug 1
    to Yuwei Huang, Chromium LUCI CQ, chromium...@chromium.org, chromotin...@chromium.org
    Attention needed from Yuwei Huang

    Joe Downing voted and added 4 comments

    Votes added by Joe Downing

    Code-Review+1

    4 comments

    File remoting/base/session_options.h
    Line 62, Patchset 5 (Latest): // Encoder speed for VP9 video codec.
    // Corresponding option key: Vp9-Encoder-Speed
    std::optional<int> vp9_encoder_speed;
    Joe Downing . resolved

    Not related to the structure of this file but I feel like a fair number of this options are now the default behavior and could be removed (allow_dirctx, enable_sck, vp9_speed, av1_speed for sure). Please consider removing them in a follow-up CL.

    File remoting/base/session_options.cc
    Line 54, Patchset 5 (Latest):const base::flat_map<std::string_view, std::optional<bool> SessionOptions::*>&
    Joe Downing . unresolved

    optional: This is a mouthful, consider using a typedef for these long types.

    Line 130, Patchset 5 (Latest): LOG(WARNING) << "Unsupported session option key: " << key;
    Joe Downing . resolved

    If/when we remove support for the outdated session options above, we should probably 'retire' them so they don't trigger warnings.

    File remoting/base/session_options_unittest.cc
    Line 17, Patchset 5 (Latest): dict.Set("Detect-Updated-Region", "true");
    Joe Downing . unresolved

    Is it worth putting this in a constant file? It's not critical but we do it in several other places in the code for constants that are used in tests.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Yuwei Huang
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement 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: Icb4c445e8715fb2398c36f345656f85111b86a0c
      Gerrit-Change-Number: 8183649
      Gerrit-PatchSet: 5
      Gerrit-Owner: Yuwei Huang <yuw...@chromium.org>
      Gerrit-Reviewer: Joe Downing <joe...@chromium.org>
      Gerrit-Reviewer: Yuwei Huang <yuw...@chromium.org>
      Gerrit-Attention: Yuwei Huang <yuw...@chromium.org>
      Gerrit-Comment-Date: Sat, 01 Aug 2026 20:19:41 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages