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

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

Issue 2770343002: Teach Background Fetch how to start a new fetch. (Closed)
Patch Set: Teach Background Fetch how to start a new fetch. 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/background_fetch/background_fetch_service_impl.cc
diff --git a/content/browser/background_fetch/background_fetch_service_impl.cc b/content/browser/background_fetch/background_fetch_service_impl.cc
index 582827e4c4da1b7ced6d64310ccd89142f78bcf7..143be0fc9c24c0d7da002babdaa41673f396c66a 100644
--- a/content/browser/background_fetch/background_fetch_service_impl.cc
+++ b/content/browser/background_fetch/background_fetch_service_impl.cc
@@ -8,8 +8,9 @@
#include "base/memory/ptr_util.h"
#include "base/optional.h"
#include "content/browser/background_fetch/background_fetch_context.h"
-#include "content/browser/service_worker/service_worker_context_wrapper.h"
+#include "content/browser/background_fetch/background_fetch_registration_id.h"
#include "content/common/background_fetch/background_fetch_types.h"
+#include "content/common/service_worker/service_worker_types.h"
#include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "url/origin.h"
@@ -19,22 +20,17 @@ namespace content {
// static
void BackgroundFetchServiceImpl::Create(
scoped_refptr<BackgroundFetchContext> background_fetch_context,
- scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
blink::mojom::BackgroundFetchServiceRequest request) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
mojo::MakeStrongBinding(base::MakeUnique<BackgroundFetchServiceImpl>(
- std::move(background_fetch_context),
- std::move(service_worker_context)),
+ std::move(background_fetch_context)),
std::move(request));
}
BackgroundFetchServiceImpl::BackgroundFetchServiceImpl(
- scoped_refptr<BackgroundFetchContext> background_fetch_context,
- scoped_refptr<ServiceWorkerContextWrapper> service_worker_context)
- : background_fetch_context_(std::move(background_fetch_context)),
- service_worker_context_(std::move(service_worker_context)) {
+ scoped_refptr<BackgroundFetchContext> background_fetch_context)
+ : background_fetch_context_(std::move(background_fetch_context)) {
DCHECK(background_fetch_context_);
- DCHECK(service_worker_context_);
}
BackgroundFetchServiceImpl::~BackgroundFetchServiceImpl() = default;
@@ -45,18 +41,19 @@ void BackgroundFetchServiceImpl::Fetch(int64_t service_worker_registration_id,
const BackgroundFetchOptions& options,
const FetchCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ BackgroundFetchRegistrationId registration_id(service_worker_registration_id,
+ origin, tag);
- // TODO(peter): Create a new job with the BackgroundFetchContext for the
- // given tag, requests and options. For now we return a registration that's
- // based on the given |options|, to make sure round-trip is covered.
+ // TODO(peter): Make sure |tag| isn't empty.
+ // TODO(peter): Make sure there are >0 |requests|.
- BackgroundFetchRegistration registration;
- registration.tag = tag;
- registration.icons = options.icons;
- registration.title = options.title;
- registration.total_download_size = options.total_download_size;
+ std::vector<ServiceWorkerFetchRequest> requests;
+ requests.emplace_back(GURL("https://example.com/image.png"), "POST",
+ ServiceWorkerHeaderMap(), Referrer(),
+ false /* is_reload */);
- callback.Run(blink::mojom::BackgroundFetchError::NONE, registration);
+ background_fetch_context_->StartFetch(registration_id, requests, options,
+ callback);
}
void BackgroundFetchServiceImpl::UpdateUI(

Powered by Google App Engine
This is Rietveld 408576698