Commit 055b2ac2 authored by Richard Knoll's avatar Richard Knoll Committed by Commit Bot

[Nearby] Handle profile shutdown

After the Shutdown() method is called on a BCKS, the profile must not be
used anymore. This CL cleans up current usages of the |profile_| during
shutdown and adds DCHECKs where we're sure it it still valid.

Bug: 1125056
Change-Id: I847bf7e6a96abefcc370bb5761f438ed3369c4a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2400459Reviewed-by: default avatarJames Vecore <vecore@google.com>
Commit-Queue: Richard Knoll <knollr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805658}
parent 507b512d
......@@ -124,7 +124,6 @@ void FakeNearbyConnectionsManager::Cancel(int64_t payload_id) {
}
void FakeNearbyConnectionsManager::ClearIncomingPayloads() {
DCHECK(!is_shutdown());
base::ScopedAllowBlockingForTesting allow_blocking;
incoming_payloads_.clear();
......
......@@ -68,6 +68,7 @@ class NearbySharingServiceImpl
~NearbySharingServiceImpl() override;
// NearbySharingService:
void Shutdown() override;
StatusCodes RegisterSendSurface(
TransferUpdateCallback* transfer_callback,
ShareTargetDiscoveredCallback* discovery_callback,
......
......@@ -369,6 +369,9 @@ class NearbySharingServiceImplTest : public testing::Test {
}
void TearDown() override {
if (service_)
service_->Shutdown();
if (profile_) {
DownloadCoreServiceFactory::GetForBrowserContext(profile_)
->SetDownloadManagerDelegateForTesting(nullptr);
......@@ -925,6 +928,7 @@ TEST_F(NearbySharingServiceImplTest, AddsNearbyProcessObserver) {
}
TEST_F(NearbySharingServiceImplTest, RemovesNearbyProcessObserver) {
service_->Shutdown();
service_.reset();
EXPECT_FALSE(mock_nearby_process_manager().observers_.might_have_observers());
}
......
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