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

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

Issue 2708943002: Create the BackgroundFetchBatchManager and initiate a download. (Closed)
Patch Set: Integrated code review comments and added BackgroundFetchDataManager::BatchData which feeds FetchRe… Created 3 years, 10 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/batch_request.h"
7 #include "content/browser/background_fetch/fetch_request.h" 8 #include "content/browser/background_fetch/fetch_request.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_batch_manager_(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(
45 const BatchRequest& batch_request,
46 const std::vector<FetchRequest>& fetch_requests) {
43 DCHECK_CURRENTLY_ON(BrowserThread::UI); 47 DCHECK_CURRENTLY_ON(BrowserThread::UI);
Peter Beverloo 2017/02/24 02:05:15 qq: why UI?
harkness 2017/02/24 11:47:10 Left over from an initial plan. Once I move the Da
48 DCHECK_GE(1U, fetch_requests.size());
44 // Inform the data manager about the new download. 49 // Inform the data manager about the new download.
45 background_fetch_data_manager_.CreateRequest(fetch_request); 50 BackgroundFetchDataManager::BatchData* batch_data =
51 background_fetch_data_manager_.CreateRequest(batch_request,
52 fetch_requests);
53 DCHECK(batch_data);
Peter Beverloo 2017/02/24 02:05:15 We shouldn't crash the entire browser when a Servi
harkness 2017/02/24 11:47:10 Good point, and the error logging is already done
46 54
47 // TODO(harkness): Make the request to the download manager. 55 background_fetch_batch_manager_.ProcessBatch(batch_request.guid(),
56 batch_data);
48 } 57 }
49 58
50 } // namespace content 59 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698