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

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

Issue 2745243002: Implement a Mojo service for Background Fetch (Closed)
Patch Set: Implement a Mojo service for Background 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
new file mode 100644
index 0000000000000000000000000000000000000000..8e1808ce23f334abca000a7bcb075d0e00053804
--- /dev/null
+++ b/content/browser/background_fetch/background_fetch_service_impl.cc
@@ -0,0 +1,83 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/background_fetch/background_fetch_service_impl.h"
+
+#include "base/logging.h"
+#include "base/memory/ptr_util.h"
+#include "content/browser/background_fetch/background_fetch_context.h"
+#include "content/browser/service_worker/service_worker_context_wrapper.h"
+#include "content/public/browser/browser_thread.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+
+namespace content {
+
+// static
+void BackgroundFetchServiceImpl::Create(
+ BackgroundFetchContext* background_fetch_context,
+ ServiceWorkerContextWrapper* service_worker_context,
+ blink::mojom::BackgroundFetchServiceRequest request) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ mojo::MakeStrongBinding(base::MakeUnique<BackgroundFetchServiceImpl>(
+ background_fetch_context, service_worker_context),
+ std::move(request));
+}
+
+BackgroundFetchServiceImpl::BackgroundFetchServiceImpl(
+ BackgroundFetchContext* background_fetch_context,
+ ServiceWorkerContextWrapper* service_worker_context)
+ : background_fetch_context_(background_fetch_context),
+ service_worker_context_(service_worker_context) {
+ DCHECK(background_fetch_context);
+ DCHECK(service_worker_context);
+}
+
+BackgroundFetchServiceImpl::~BackgroundFetchServiceImpl() = default;
+
+void BackgroundFetchServiceImpl::UpdateUI(
+ int64_t service_worker_registration_id,
+ const std::string& tag,
+ const std::string& title,
+ const UpdateUICallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ // TODO(peter): Get the BackgroundFetchJobController for the
+ // {service_worker_registration_id, tag} pair and call UpdateUI() on it.
+
+ callback.Run(blink::mojom::BackgroundFetchError::NONE);
+}
+
+void BackgroundFetchServiceImpl::Abort(int64_t service_worker_registration_id,
+ const std::string& tag) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ // TODO(peter): Get the BackgroundFetchJobController for the
+ // {service_worker_registration_id, tag} pair and call Abort() on it.
+}
+
+void BackgroundFetchServiceImpl::GetRegistration(
+ int64_t service_worker_registration_id,
+ const std::string& tag,
+ const GetRegistrationCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ // TODO(peter): Get the registration for {service_worker_registration_id, tag}
+ // and construct a BackgroundFetchRegistrationPtr for it.
+
+ callback.Run(blink::mojom::BackgroundFetchError::NONE,
+ nullptr /* registration */);
+}
+
+void BackgroundFetchServiceImpl::GetTags(int64_t service_worker_registration_id,
+ const GetTagsCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ // TODO(peter): Get the list of active Background Fetches associated with
+ // service_worker_registration_id and share their tags.
+
+ callback.Run(blink::mojom::BackgroundFetchError::NONE,
+ std::vector<std::string>());
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698