Issue metadata
Sign in to add a comment
|
TestingProfile::CreateNetworkContext causing an infinite loop |
||||||||||||||||||||||||
Issue description
```
network::mojom::NetworkContextPtr TestingProfile::CreateNetworkContext(
bool in_memory,
const base::FilePath& relative_partition_path) {
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
network::mojom::NetworkContextPtr network_context;
mojo::MakeRequest(&network_context);
return network_context;
}
return nullptr;
}
```
Together with
```
void StoragePartitionImpl::InitNetworkContext() {
network_context_ = GetContentClient()->browser()->CreateNetworkContext(
browser_context_, is_in_memory_, relative_partition_path_);
// ...
network_context_.set_connection_error_handler(base::BindOnce(
&StoragePartitionImpl::InitNetworkContext, weak_factory_.GetWeakPtr()));
```
Seems to cause an infinite loop since the returned |NetworkContextPtr| will trigger connection error handler immediately.
I'm working on a patch to strong bind a |network::TestNetworkContext|, which should at least fix the following two tests:
-ArcAuthServiceChildAccountTest.ChildTransition
-FileManagerPrivateApiTest.OnFileChanged
Not sure why it only happens on Chrome OS though.
,
Sep 27
Hmmmm sorry but I don't quite get the suggestion here. IIUC |TestingProfile::CreateNetworkContext()| has to return a valid pointer as discussed in: https://chromium-review.googlesource.com/c/chromium/src/+/963402/7/chrome/test/base/testing_profile.cc#994 And my plan was to change it to: ``` network::mojom::NetworkContextPtr TestingProfile::CreateNetworkContext( bool in_memory, const base::FilePath& relative_partition_path) { if (base::FeatureList::IsEnabled(network::features::kNetworkService)) { network::mojom::NetworkContextPtr network_context; mojo::MakeStrongBinding(std::make_unique<network::TestNetworkContext>(), mojo::MakeRequest(&network_context)); return network_context; } return nullptr; } ``` Does that sound reasonable? Thanks!
,
Sep 27
A mojo interface that is never listened to on the other end is still a valid pointer. Calls can be made on it as will (And will never be responded to).
```
network::mojom::NetworkContextPtr TestingProfile::CreateNetworkContext(
bool in_memory,
const base::FilePath& relative_partition_path) {
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
network::mojom::NetworkContextPtr network_context;
network_context_request_ = mojo::MakeRequest(&network_context);
return network_context;
}
return nullptr;
}
```
Should do basically the same thing, except it won't drop anything. NetworkContext will DCHECK if Callback objects are passed to it, since it will drop them on the floor, and mojo has a hard requirement that Callbacks passed across a Mojo interface must be invoked (Unless the mojo pipe is closed first). They can't just be destroyed. Just not binding the request resolves that issue.
,
Sep 27
Ah I see, thanks for the explanation!
,
Sep 28
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/3431fc62c19d86cef97b82b3369093b5516da138 commit 3431fc62c19d86cef97b82b3369093b5516da138 Author: Chong Zhang <chongz@chromium.org> Date: Fri Sep 28 01:21:50 2018 NetworkService: Cache network_context_request_ in TestingProfile This patch affects tests only. We want to cache the |network_context_request_| to avoid triggering connection error handler infinitely. (Also organized unrelated BackgroundFetchBrowserTest.* tests) Bug: 889965 Change-Id: I9fc67b03f19b8a9575db7714ea57ec41fc0a7711 Reviewed-on: https://chromium-review.googlesource.com/1249727 Commit-Queue: Chong Zhang <chongz@chromium.org> Reviewed-by: Matt Menke <mmenke@chromium.org> Cr-Commit-Position: refs/heads/master@{#594946} [modify] https://crrev.com/3431fc62c19d86cef97b82b3369093b5516da138/chrome/test/base/testing_profile.cc [modify] https://crrev.com/3431fc62c19d86cef97b82b3369093b5516da138/chrome/test/base/testing_profile.h [modify] https://crrev.com/3431fc62c19d86cef97b82b3369093b5516da138/testing/buildbot/filters/mojo.fyi.chromeos.network_browser_tests.filter
,
Sep 28
|
|||||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||||
Comment 1 by mmenke@chromium.org
, Sep 27