Skip to content

Commit

Permalink
Reland "Allow querying StoragePartition path during NetworkContext cr…
Browse files Browse the repository at this point in the history
…eation"

This is a reland of 8f0166a
No modification has been made to original CL:1735572, so TBRing.

Reason for reland without modification:
The original change was reverted due to failures in the
EnterpriseEnrollmentTest.StoragePartitionUpdated browsertest.
From local testing, it seems to have been flaky and this CL has not made
the flakiness significantly worse.
In the meantime, I've submitted CL:1746181 to make the test not flaky.

TBR=jam@chromium.org

Original change's description:
> Allow querying StoragePartition path during NetworkContext creation
>
> When creating a NetworkCon NetworkContext for a StoragePartition, ensure
> that the StoragePartition is already in the StoragePartitionImplMap and
> its GetPath member can be called.
>
> This requires changing from the sequence:
> (1) StoragePartitionImpl::Create <-- also creates NetworkContext
> (2) put into StoragePartitionImpl map
> to the sequence:
> (1) StoragePartitionImpl::Create <-- does not create NetworkContext
> (2) put into StoragePartitionImpl map
> (3) StoragePartitionImpl::Initialize <-- creates NetworkContext
>
> DCHECKs guard that no other functions except for GetPath() and
> browser_context() are called until StoragePartitionImpl::Initialize has
> returned.
>
> Bug: 939344
> Test: All tests still pass
> Change-Id: Ib5fdd5dae6c53e773ac5ba4575c671b1ad3595cc
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1735572
> Commit-Queue: Pavol Marko <pmarko@chromium.org>
> Reviewed-by: John Abd-El-Malek <jam@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#685582}

Bug: 939344
Change-Id: Id7e0988051805ae5640211b422755ce3485beab4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1746182
Reviewed-by: Pavol Marko <pmarko@chromium.org>
Commit-Queue: Pavol Marko <pmarko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685900}
  • Loading branch information
Pavol Marko authored and Commit Bot committed Aug 11, 2019
1 parent 7fab8d8 commit d593774
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ void BackgroundSyncServiceImplTestHarness::CreateStoragePartition() {
storage_partition_impl_ = StoragePartitionImpl::Create(
embedded_worker_helper_->browser_context(), /* in_memory= */ true,
base::FilePath(), /* partition_domain= */ "");
storage_partition_impl_->Initialize();
embedded_worker_helper_->context_wrapper()->set_storage_partition(
storage_partition_impl_.get());
}
Expand Down
8 changes: 5 additions & 3 deletions content/browser/cookie_store/cookie_store_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,11 @@ class CookieStoreManagerTest
base::BindOnce([](bool success) {
CHECK(success) << "Initialize failed";
}));
storage_partition_impl_ = base::WrapUnique(
new StoragePartitionImpl(worker_test_helper_->browser_context(),
user_data_directory_.GetPath(), nullptr));
storage_partition_impl_ = StoragePartitionImpl::Create(
worker_test_helper_->browser_context(), true /* in_memory */,
base::FilePath() /* relative_partition_path */,
std::string() /* partition_domain */);
storage_partition_impl_->Initialize();
::network::mojom::NetworkContext* network_context =
storage_partition_impl_->GetNetworkContext();
cookie_store_context_->ListenToCookieChanges(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class ServiceWorkerRegistrationTest : public testing::Test {
storage_partition_impl_ = StoragePartitionImpl::Create(
helper_->browser_context(), /* in_memory= */ true, base::FilePath(),
/* partition_domain= */ "");
storage_partition_impl_->Initialize();
helper_->context_wrapper()->set_storage_partition(
storage_partition_impl_.get());

Expand Down

0 comments on commit d593774

Please sign in to comment.