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

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

Issue 2833793002: Added AddDownload communication path and observers
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 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_client_proxy.h" 5 #include "content/browser/background_fetch/background_fetch_client_proxy.h"
6 6
7 #include "content/browser/background_fetch/background_fetch_context.h" 7 #include "content/browser/background_fetch/background_fetch_context.h"
8 #include "content/browser/background_fetch/background_fetch_registration_id.h" 8 #include "content/browser/background_fetch/background_fetch_registration_id.h"
9 #include "content/common/background_fetch/background_fetch_types.h"
10 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
10 12
11 namespace content { 13 namespace content {
12 14
13 BackgroundFetchClientProxy::BackgroundFetchClientProxy( 15 BackgroundFetchClientProxy::BackgroundFetchClientProxy(
16 BrowserContext* browser_context,
14 BackgroundFetchContext* background_fetch_context) 17 BackgroundFetchContext* background_fetch_context)
15 : background_fetch_context_(background_fetch_context) { 18 : browser_context_(browser_context),
19 background_fetch_context_(background_fetch_context),
20 weak_ptr_factory_(this) {
16 DCHECK(background_fetch_context); 21 DCHECK(background_fetch_context);
22 DCHECK(browser_context);
17 } 23 }
18 24
19 BackgroundFetchClientProxy::~BackgroundFetchClientProxy() = default; 25 BackgroundFetchClientProxy::~BackgroundFetchClientProxy() = default;
20 26
27 base::WeakPtr<BackgroundFetchClientProxy>
28 BackgroundFetchClientProxy::GetWeakPtr() {
29 return weak_ptr_factory_.GetWeakPtr();
30 }
31
32 void BackgroundFetchClientProxy::AddDownload(
Peter Beverloo 2017/04/20 16:27:55 Why do we call this "Download"?
harkness 2017/04/21 14:55:20 I went with Download because all of the Background
Peter Beverloo 2017/04/24 14:39:14 I mean, yeah, this feature is not just about downl
33 const std::string& registration_id,
34 const BackgroundFetchOptions& options) {
35 BackgroundFetchClient* client = browser_context_->GetBackgroundFetchClient();
36 if (client) {
37 client->AddDownload(registration_id, options.title,
38 options.total_download_size);
39 }
40 }
41
21 void BackgroundFetchClientProxy::CleanupAllTasks() { 42 void BackgroundFetchClientProxy::CleanupAllTasks() {
22 DCHECK_CURRENTLY_ON(BrowserThread::UI); 43 DCHECK_CURRENTLY_ON(BrowserThread::UI);
23 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 44 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
24 base::Bind(&BackgroundFetchContext::CleanupAllTasks, 45 base::Bind(&BackgroundFetchContext::CleanupAllTasks,
25 background_fetch_context_)); 46 background_fetch_context_));
26 } 47 }
27 48
28 void BackgroundFetchClientProxy::CancelDownload( 49 void BackgroundFetchClientProxy::CancelDownload(
29 const std::string& registration_id) { 50 const std::string& registration_id) {
30 DCHECK_CURRENTLY_ON(BrowserThread::UI); 51 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return; 88 return;
68 } 89 }
69 90
70 BrowserThread::PostTask( 91 BrowserThread::PostTask(
71 BrowserThread::IO, FROM_HERE, 92 BrowserThread::IO, FROM_HERE,
72 base::Bind(&BackgroundFetchContext::ResumeFetch, 93 base::Bind(&BackgroundFetchContext::ResumeFetch,
73 background_fetch_context_, deserialized_id)); 94 background_fetch_context_, deserialized_id));
74 } 95 }
75 96
76 } // namespace content 97 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698