Skip to content

fix: provide paths for all NetworkContextFilePaths keys - #31777

Merged
VerteDinde merged 8 commits into
mainfrom
fix-network-paths
Nov 15, 2021
Merged

VerteDinde merged 8 commits into
mainfrom
fix-network-paths

Conversation

@MarshallOfSound

Copy link
Copy Markdown
Member

Chromium is currently migrating file paths for the network service to a different path, as such a bunch of path calculations were moved into a config struct that we weren't fully populating.

This populates the struct identically to //chrome.

Refs: https://source.chromium.org/chromium/chromium/src/+/main:services/network/public/mojom/network_context.mojom;l=219;drc=b6e40f8ab247ea209bcecff994386a70a4169e9d
Refs: https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/net/profile_network_context_service.cc;l=712;drc=b6e40f8ab247ea209bcecff994386a70a4169e9d;bpv=1;bpt=1

Notes: ~/.config/{App Name} will no longer be incorrectly deleted if it is a symlink on unix systems

@MarshallOfSound MarshallOfSound added semver/patch backwards-compatible bug fixes fast-track 🚅 Indicates that this PR is intended to bypass the 24 hour rule. Needs approval from Releases target/16-x-y labels Nov 9, 2021

@VerteDinde VerteDinde left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍

@deepak1556 deepak1556 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.Append(chrome::kNetworkDataDirname);
network_context_params->file_paths->unsandboxed_data_path = path;
network_context_params->file_paths->trigger_migration =
features::ShouldTriggerNetworkDataMigration();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to include chrome/browser/browser_features.h

@deepak1556 deepak1556 Nov 9, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops forgot that we don't build the entire //chrome/browser target as part of https://github.com/electron/electron/blob/main/chromium_src/BUILD.gn#L13. Will need to add //chrome/browser/browser_features.h, //chrome/browser/browser_features.cc to address ci failure.

@deepak1556

Copy link
Copy Markdown
Member

TriggerNetworkDataMigration feature is currently disabled, chrome is experimenting it with via field trial. Do we plan to enable it separately for main ?

@MarshallOfSound

Copy link
Copy Markdown
Member Author

@deepak1556 My plan was to pick it up when Chrome flipped it to ENABLED_BY_DEFAULT. Folks with the ability to toggle flags remotely like field trials (we have that capability) can also run there own rollouts if they choose. I wouldn't want to roll this out before Chrome has it at 100%

@zcbenz zcbenz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Windows code calls SystemNetworkContextManager::IsNetworkSandboxEnabled() which is implemented in chrome/browser/net/system_network_context_manager.cc, I don't think we can simply include that file to build since it seems to have lots of dependencies.

lld-link: error: undefined symbol: public: static bool __cdecl SystemNetworkContextManager::IsNetworkSandboxEnabled(void)
>>> referenced by .\..\..\chrome\browser\browser_features.cc:99

As a workaround you can probably just define it somewhere in Electron.

#if defined(OS_WIN)
bool SystemNetworkContextManager::IsNetworkSandboxEnabled() {
    auto* local_state = g_browser_process->local_state();
  if (local_state &&
      local_state->HasPrefPath(prefs::kNetworkServiceSandboxEnabled)) {
    return local_state->GetBoolean(prefs::kNetworkServiceSandboxEnabled);
  }
  return sandbox::policy::features::IsNetworkSandboxEnabled();
}
#endif

@deepak1556

deepak1556 commented Nov 10, 2021 •

Copy link
Copy Markdown
Member

We maintain a synonymous version of SystemNetworkContextManager https://github.com/electron/electron/blob/main/shell/browser/net/system_network_context_manager.h where it can be defined normally.

But this one would be a special case, as we are building //chrome/browser/browser_features.h in the //chromium_src:chrome target which is set to static_library and not source_set, we would need to define these under //electron/chromium_src and not inside //electron.

Another way would be declare //chrome/browser/browser_features.h as part of //electron target and then we can define stuff inside //electron. This would better for long term, since there has been ongoing work to remove source copies from //electron/chromium_src and now we are down to just the build file, the next step was to merge it to our main build file eliminating chromium_src directory (@miniak is working on it)

@ckerr ckerr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just here to provide that critically-needed fifth approval

@jkleinsc jkleinsc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows fails to build

@MarshallOfSound
MarshallOfSound dismissed jkleinsc’s stale review November 15, 2021 19:29

CI will be fixed, don't want to leave this blocked

@trop

trop Bot commented Nov 15, 2021

Copy link
Copy Markdown
Contributor

@VerteDinde has manually backported this PR to "16-x-y", please check out #31852

@VerteDinde
VerteDinde merged commit 246884c into main Nov 15, 2021
@VerteDinde
VerteDinde deleted the fix-network-paths branch November 15, 2021 23:26
@release-clerk

release-clerk Bot commented Nov 15, 2021

Copy link
Copy Markdown

Release Notes Persisted

~/.config/{App Name} will no longer be incorrectly deleted if it is a symlink on unix systems

@trop

trop Bot commented Nov 15, 2021

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "16-x-y" cleanly;
you will need to perform this backport manually.

t57ser pushed a commit to t57ser/electron that referenced this pull request Jan 25, 2022
* fix: provide paths for all NetworkContextFilePaths keys

* chore: include chrome features header

* chore: build browser_features

* yolo

* add pref service

* fix: include sandbox policy features

* fix pref key

* fix: gate pref key to OS_WIN

Co-authored-by: VerteDinde <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fast-track 🚅 Indicates that this PR is intended to bypass the 24 hour rule. Needs approval from Releases semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants