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

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

Issue 2708943002: Create the BackgroundFetchBatchManager and initiate a download. (Closed)
Patch Set: fixed nits Created 3 years, 9 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 "content/browser/background_fetch/background_fetch_context.h" 5 #include "content/browser/background_fetch/background_fetch_context.h"
6 6
7 #include "content/browser/background_fetch/fetch_request.h" 7 #include "content/browser/background_fetch/background_fetch_job_info.h"
8 #include "content/browser/background_fetch/background_fetch_request_info.h"
8 #include "content/browser/service_worker/service_worker_context_wrapper.h" 9 #include "content/browser/service_worker/service_worker_context_wrapper.h"
9 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
10 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/download_manager.h" 12 #include "content/public/browser/download_manager.h"
12 #include "content/public/browser/storage_partition.h" 13 #include "content/public/browser/storage_partition.h"
13 14
14 namespace content { 15 namespace content {
15 16
16 BackgroundFetchContext::BackgroundFetchContext( 17 BackgroundFetchContext::BackgroundFetchContext(
17 BrowserContext* browser_context, 18 BrowserContext* browser_context,
19 StoragePartition* storage_partition,
18 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context) 20 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context)
19 : service_worker_context_(service_worker_context), 21 : service_worker_context_(service_worker_context),
22 background_fetch_job_controller_(browser_context, storage_partition),
20 background_fetch_data_manager_(this) { 23 background_fetch_data_manager_(this) {
21 DCHECK_CURRENTLY_ON(BrowserThread::UI); 24 DCHECK_CURRENTLY_ON(BrowserThread::UI);
22 // TODO(harkness): BackgroundFetchContext should have 25 // TODO(harkness): BackgroundFetchContext should have
23 // ServiceWorkerContextObserver as a parent class and should register as an 26 // ServiceWorkerContextObserver as a parent class and should register as an
24 // observer here. 27 // observer here.
25 } 28 }
26 29
27 BackgroundFetchContext::~BackgroundFetchContext() { 30 BackgroundFetchContext::~BackgroundFetchContext() {
28 DCHECK_CURRENTLY_ON(BrowserThread::UI); 31 DCHECK_CURRENTLY_ON(BrowserThread::UI);
29 } 32 }
30 33
31 void BackgroundFetchContext::Init() { 34 void BackgroundFetchContext::Init() {
32 DCHECK_CURRENTLY_ON(BrowserThread::UI); 35 DCHECK_CURRENTLY_ON(BrowserThread::UI);
33 36
34 // TODO(harkness): Create the Download observer. 37 // TODO(harkness): Create the Download observer.
35 // TODO(harkness): Create the Batch manager.
36 } 38 }
37 39
38 void BackgroundFetchContext::Shutdown() { 40 void BackgroundFetchContext::Shutdown() {
39 DCHECK_CURRENTLY_ON(BrowserThread::UI); 41 DCHECK_CURRENTLY_ON(BrowserThread::UI);
40 } 42 }
41 43
42 void BackgroundFetchContext::CreateRequest(const FetchRequest& fetch_request) { 44 void BackgroundFetchContext::CreateRequest(
43 DCHECK_CURRENTLY_ON(BrowserThread::UI); 45 const BackgroundFetchJobInfo& job_info,
46 std::vector<BackgroundFetchRequestInfo>& request_infos) {
47 DCHECK_GE(1U, request_infos.size());
44 // Inform the data manager about the new download. 48 // Inform the data manager about the new download.
45 background_fetch_data_manager_.CreateRequest(fetch_request); 49 BackgroundFetchJobData* job_data =
46 50 background_fetch_data_manager_.CreateRequest(job_info, request_infos);
47 // TODO(harkness): Make the request to the download manager. 51 // If job_data is null, the DataManager will have logged an error.
52 if (job_data)
53 background_fetch_job_controller_.ProcessJob(job_info.guid(), job_data);
48 } 54 }
49 55
50 } // namespace content 56 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698