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

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

Issue 2678273003: Initial framework setup and skeleton for BackgroundFetchContext (Closed)
Patch Set: Remove BackgroundFetchDownloadObserver until it's used. 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/background_fetch/background_fetch_context.h"
6
7 #include "content/browser/background_fetch/fetch_request.h"
8 #include "content/browser/service_worker/service_worker_context_wrapper.h"
9 #include "content/public/browser/browser_context.h"
10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/download_manager.h"
12 #include "content/public/browser/storage_partition.h"
13
14 namespace content {
15
16 BackgroundFetchContext::BackgroundFetchContext(
17 BrowserContext* browser_context,
18 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context)
19 : browser_context_(browser_context),
20 service_worker_context_(service_worker_context),
21 background_fetch_data_manager_(this) {
22 DCHECK_CURRENTLY_ON(BrowserThread::UI);
23
24 service_worker_context_->AddObserver(this);
25 }
26
27 BackgroundFetchContext::~BackgroundFetchContext() {
28 DCHECK_CURRENTLY_ON(BrowserThread::UI);
29
30 service_worker_context_->RemoveObserver(this);
31 }
32
33 void BackgroundFetchContext::Init() {
34 DCHECK_CURRENTLY_ON(BrowserThread::UI);
35
36 // TODO(harkness) Create the Download observer.
37 // TODO(harkness) Create the Data manager.
Peter Beverloo 2017/02/13 18:35:05 nit: delete (see line 21)
harkness 2017/02/14 13:52:46 Done.
38 // TODO(harkness) Create the Batch manager.
39 }
40
41 void BackgroundFetchContext::Shutdown() {
42 DCHECK_CURRENTLY_ON(BrowserThread::UI);
43 }
44
45 void BackgroundFetchContext::OnRegistrationDeleted(int64_t registration_id,
46 const GURL& pattern) {
47 DCHECK_CURRENTLY_ON(BrowserThread::UI);
48 // TODO(harkness) Call into the data manager and delete metadata, this will
49 // a call to the DownloadManager to abort any ongoing downloads.
50 }
51
52 void BackgroundFetchContext::CreateRequest(const FetchRequest& fetch_request) {
53 DCHECK_CURRENTLY_ON(BrowserThread::UI);
54 // Inform the data manager about the new download.
55 background_fetch_data_manager_.CreateRequest(fetch_request);
56
57 // Now make the request to the download manager.
58 // TODO(harkness) Replace this with a call to the batch manager once that is
59 // available.
60 content::StoragePartition* storage_partition =
Peter Beverloo 2017/02/13 18:35:05 drop `content::` everywhere - you are in that name
harkness 2017/02/14 13:52:46 Done.
61 content::BrowserContext::GetStoragePartitionForSite(
62 browser_context_, GURL(fetch_request.origin().Serialize()));
63 std::unique_ptr<content::DownloadUrlParameters> params(
64 new content::DownloadUrlParameters(
65 GURL(fetch_request.url().Serialize()),
66 storage_partition->GetURLRequestContext()));
67 // TODO(harkness) Set up the callback and start the download.
68 }
69
70 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698