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

Unified Diff: content/browser/background_fetch/background_fetch_context.cc

Issue 2806713002: Some minor fixes for Background Fetch (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/background_fetch/background_fetch_context.cc
diff --git a/content/browser/background_fetch/background_fetch_context.cc b/content/browser/background_fetch/background_fetch_context.cc
index 11e58e55e29e346b3f6401a6ff88453894faa52f..f27666efc7abae886b1838eaba08b7b4ed69fa96 100644
--- a/content/browser/background_fetch/background_fetch_context.cc
+++ b/content/browser/background_fetch/background_fetch_context.cc
@@ -44,14 +44,18 @@ BackgroundFetchContext::BackgroundFetchContext(
event_dispatcher_(base::MakeUnique<BackgroundFetchEventDispatcher>(
std::move(service_worker_context))) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- request_context_ =
- make_scoped_refptr(storage_partition->GetURLRequestContext());
}
BackgroundFetchContext::~BackgroundFetchContext() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
+void BackgroundFetchContext::InitializeOnIOThread(
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ request_context_getter_ = request_context_getter;
+}
+
void BackgroundFetchContext::Shutdown() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
@@ -146,12 +150,12 @@ void BackgroundFetchContext::CreateController(
std::unique_ptr<BackgroundFetchJobController> controller =
base::MakeUnique<BackgroundFetchJobController>(
registration_id, options, data_manager_.get(), browser_context_,
- request_context_,
+ request_context_getter_,
base::BindOnce(&BackgroundFetchContext::DidCompleteJob, this));
// TODO(peter): We should actually be able to use Background Fetch in layout
// tests. That requires a download manager and a request context.
- if (request_context_) {
+ if (request_context_getter_) {
// Start fetching the |initial_requests| immediately. At some point in the
// future we may want a more elaborate scheduling mechanism here.
controller->Start(std::move(initial_requests));

Powered by Google App Engine
This is Rietveld 408576698