Commit 582e2ef7 authored by Lukasz Anforowicz's avatar Lukasz Anforowicz Committed by Commit Bot

Define default values for primitive-type fields of ...NavigationParams.

This CL provides explicit default values for most of the primitive-type
fields of CommonNavigationParams, BeginNavigationParams and
CommitNavigationParams.  The explicit initialization is mostly a
readability aid, since otherwise the auto-generated default constructor
will just call the default constructor of the fields:
    BeginNavigationParams::BeginNavigationParams()
        : initiator_routing_id(),
          headers(),
          load_flags()
    ...
Still, being explicit in the mojom file helps:
1. It makes it clear that the default has been explicitly selected by a
   human, rather then provided by the compiler and/or other tools.
2. It doesn't require the reader to understand that omitting the
   initializer is safe and will zero-initialize POD values.
3. It does make a difference in cases when non-zero defaults are better
  - for example when initializing initiator_routing_id to
  MSG_ROUTING_NONE.  (rather than falling back to zero-initializatio

Note that default initial values cannot be provided for [Native] enums.

Bug: 1107269
Change-Id: I9a1dfc9467d52ff9485cc124ab1859cf50b6b345
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2341892
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796013}
parent 403f8d87
......@@ -97,33 +97,38 @@ struct BeginNavigationParams {
// Routing id of the initiator of the navigation. This routing id may no
// longer be valid by the time the navigation is seen by the browser process,
// if the initiator frame is deleted before the navigation IPC arrives. A
// value of MSG_ROUTING_NONE indicates this navigation is not associated
// with a frame.
int32 initiator_routing_id;
// default value of MSG_ROUTING_NONE indicates this navigation is not
// associated with a frame.
int32 initiator_routing_id = -2; // -2 == MSG_ROUTING_NONE
// Additional HTTP request headers.
string headers;
// net::URLRequest load flags (net::LOAD_NORMAL) by default).
int32 load_flags;
int32 load_flags = 0; // 0 == net::LOAD_NORMAL
// True if the ServiceWorker should be skipped.
bool skip_service_worker;
bool skip_service_worker = false;
// Indicates the request context type.
blink.mojom.RequestContextType request_context_type;
blink.mojom.RequestContextType request_context_type =
blink.mojom.RequestContextType.UNSPECIFIED;
// Indicates the request destination.
network.mojom.RequestDestination request_destination;
network.mojom.RequestDestination request_destination =
network.mojom.RequestDestination.kEmpty;
// The mixed content context type for potential mixed content checks.
//
// [Native] enums are by default initialized to 0
// (i.e. blink::WebMixedContentContextType::kNotMixedContent below).
MixedContentContextType mixed_content_context_type;
// Whether or not the navigation has been initiated by a form submission.
bool is_form_submission;
bool is_form_submission = false;
// Whether or not the navigation has been initiated by a link click.
bool was_initiated_by_link_click;
bool was_initiated_by_link_click = false;
// See WebSearchableFormData for a description of these.
url.mojom.Url searchable_form_url;
......@@ -181,6 +186,8 @@ struct CommonNavigationParams {
blink.mojom.Referrer referrer;
// The type of transition.
//
// [Native] enums are by default initialized to 0 (i.e. PAGE_TRANSITION_LINK).
PageTransition transition;
// Type of navigation.
......@@ -206,7 +213,7 @@ struct CommonNavigationParams {
// Bitmask that has whether or not to request a Preview version of the
// document for various preview types or let the browser decide.
// Defined in third_party/blink/public/common/loader/previews_state.h.
int32 previews_state;
int32 previews_state = 0; // 0 == PREVIEWS_UNSPECIFIED
// The navigationStart time exposed through the Navigation Timing API to JS.
mojo_base.mojom.TimeTicks navigation_start;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment