Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: content/browser/background_fetch/background_fetch_service_unittest.cc

Issue 2973233002: [Background Fetch] Cleanup/fix thread safety (Closed)
Patch Set: Remove n.b. from comments Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <map> 5 #include <map>
6 #include <memory> 6 #include <memory>
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 base::Unretained(this), run_loop.QuitClosure(), 114 base::Unretained(this), run_loop.QuitClosure(),
115 out_error, out_tags)); 115 out_error, out_tags));
116 116
117 run_loop.Run(); 117 run_loop.Run();
118 } 118 }
119 119
120 // BackgroundFetchTestBase overrides: 120 // BackgroundFetchTestBase overrides:
121 void SetUp() override { 121 void SetUp() override {
122 BackgroundFetchTestBase::SetUp(); 122 BackgroundFetchTestBase::SetUp();
123 123
124 // StoragePartition creates its own BackgroundFetchContext, but this test
125 // doesn't use that since it has the wrong ServiceWorkerContextWrapper; this
126 // test just uses the StoragePartition to get a URLRequestContext.
124 StoragePartitionImpl* storage_partition = 127 StoragePartitionImpl* storage_partition =
125 static_cast<StoragePartitionImpl*>( 128 static_cast<StoragePartitionImpl*>(
126 BrowserContext::GetDefaultStoragePartition(browser_context())); 129 BrowserContext::GetDefaultStoragePartition(browser_context()));
127
128 context_ = new BackgroundFetchContext( 130 context_ = new BackgroundFetchContext(
129 browser_context(), storage_partition, 131 browser_context(),
130 make_scoped_refptr(embedded_worker_test_helper()->context_wrapper())); 132 make_scoped_refptr(embedded_worker_test_helper()->context_wrapper()));
131 context_->InitializeOnIOThread( 133 context_->InitializeOnIOThread(
132 make_scoped_refptr(storage_partition->GetURLRequestContext())); 134 make_scoped_refptr(storage_partition->GetURLRequestContext()));
133 135
134 service_ = base::MakeUnique<BackgroundFetchServiceImpl>( 136 service_ = base::MakeUnique<BackgroundFetchServiceImpl>(
135 0 /* render_process_id */, context_); 137 0 /* render_process_id */, context_);
136 } 138 }
137 139
138 void TearDown() override { 140 void TearDown() override {
139 BackgroundFetchTestBase::TearDown(); 141 BackgroundFetchTestBase::TearDown();
140 142
141 service_.reset(); 143 service_.reset();
142 144
143 context_->Shutdown();
144 context_ = nullptr; 145 context_ = nullptr;
145 146
146 // Give pending shutdown operations a chance to finish. 147 // Give pending shutdown operations a chance to finish.
147 base::RunLoop().RunUntilIdle(); 148 base::RunLoop().RunUntilIdle();
148 } 149 }
149 150
150 private: 151 private:
151 void DidGetRegistration( 152 void DidGetRegistration(
152 base::Closure quit_closure, 153 base::Closure quit_closure,
153 blink::mojom::BackgroundFetchError* out_error, 154 blink::mojom::BackgroundFetchError* out_error,
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 const bool has_alternative_tag = 705 const bool has_alternative_tag =
705 tags[0] == kAlternativeTag || tags[1] == kAlternativeTag; 706 tags[0] == kAlternativeTag || tags[1] == kAlternativeTag;
706 707
707 EXPECT_TRUE(has_example_tag); 708 EXPECT_TRUE(has_example_tag);
708 EXPECT_TRUE(has_alternative_tag); 709 EXPECT_TRUE(has_alternative_tag);
709 } 710 }
710 } 711 }
711 712
712 } // namespace 713 } // namespace
713 } // namespace content 714 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698