Commit 489e4e2c authored by Rayan Kanso's avatar Rayan Kanso Committed by Commit Bot

Initial boilerplate for the DevTools background services feature

The CL adds a general-purpose feature flag, and creates
DevToolsBackgroundServicesContext which is part of the StoragePartition.

The context will be responsible for logging the events from the relevant
features (BackgroundFetch/BackgroundSync), and will be accessible from
the soon-to-be-added DevTools protocol handler (via the StoragePartition)
to perform the reads/writes.

Bug: 927726

Change-Id: I7c48a1bac742b9e6e8eaed52f8e69eace6c25f1b
Reviewed-on: https://chromium-review.googlesource.com/c/1407077
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630067}
parent c78e1aaf
......@@ -629,6 +629,8 @@ jumbo_source_set("browser") {
"devtools/browser_devtools_agent_host.h",
"devtools/devtools_agent_host_impl.cc",
"devtools/devtools_agent_host_impl.h",
"devtools/devtools_background_services_context.cc",
"devtools/devtools_background_services_context.h",
"devtools/devtools_frame_trace_recorder.cc",
"devtools/devtools_frame_trace_recorder.h",
"devtools/devtools_http_handler.cc",
......
// Copyright 2019 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/devtools/devtools_background_services_context.h"
namespace content {
DevToolsBackgroundServicesContext::DevToolsBackgroundServicesContext(
BrowserContext* browser_context,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context)
: browser_context_(browser_context),
service_worker_context_(std::move(service_worker_context)) {}
DevToolsBackgroundServicesContext::~DevToolsBackgroundServicesContext() =
default;
} // namespace content
// Copyright 2019 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.
#ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BACKGROUND_SERVICES_CONTEXT_H_
#define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BACKGROUND_SERVICES_CONTEXT_H_
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/common/content_export.h"
namespace content {
class BrowserContext;
class ServiceWorkerContextWrapper;
// This class is responsible for persisting the debugging events for the
// relevant Web Platform Features. The contexts of the feature will have a
// reference to this, and perform the logging operation.
// This class is also responsible for reading back the data to the DevTools
// client, as the protocol handler will have access to an instance of the
// context.
class CONTENT_EXPORT DevToolsBackgroundServicesContext
: public base::RefCountedThreadSafe<DevToolsBackgroundServicesContext> {
public:
DevToolsBackgroundServicesContext(
BrowserContext* browser_context,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context);
private:
friend class base::RefCountedThreadSafe<DevToolsBackgroundServicesContext>;
~DevToolsBackgroundServicesContext();
BrowserContext* browser_context_;
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
DISALLOW_COPY_AND_ASSIGN(DevToolsBackgroundServicesContext);
};
} // namespace content
#endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_BACKGROUND_SERVICES_CONTEXT_H_
......@@ -689,6 +689,10 @@ std::unique_ptr<StoragePartitionImpl> StoragePartitionImpl::Create(
partition->service_worker_context_);
partition->platform_notification_context_->Initialize();
partition->devtools_background_services_context_ =
base::MakeRefCounted<DevToolsBackgroundServicesContext>(
context, partition->service_worker_context_);
partition->background_fetch_context_ =
base::MakeRefCounted<BackgroundFetchContext>(
context, partition->service_worker_context_,
......@@ -917,6 +921,11 @@ StoragePartitionImpl::GetGeneratedCodeCacheContext() {
return generated_code_cache_context_.get();
}
DevToolsBackgroundServicesContext*
StoragePartitionImpl::GetDevToolsBackgroundServicesContext() {
return devtools_background_services_context_.get();
}
void StoragePartitionImpl::OpenLocalStorage(
const url::Origin& origin,
blink::mojom::StorageAreaRequest request,
......
......@@ -21,6 +21,7 @@
#include "content/browser/bluetooth/bluetooth_allowed_devices_map.h"
#include "content/browser/broadcast_channel/broadcast_channel_provider.h"
#include "content/browser/cache_storage/cache_storage_context_impl.h"
#include "content/browser/devtools/devtools_background_services_context.h"
#include "content/browser/dom_storage/dom_storage_context_wrapper.h"
#include "content/browser/idle/idle_manager.h"
#include "content/browser/indexed_db/indexed_db_context_impl.h"
......@@ -151,6 +152,7 @@ class CONTENT_EXPORT StoragePartitionImpl
BlobRegistryWrapper* GetBlobRegistry();
PrefetchURLLoaderService* GetPrefetchURLLoaderService();
CookieStoreContext* GetCookieStoreContext();
DevToolsBackgroundServicesContext* GetDevToolsBackgroundServicesContext();
// blink::mojom::StoragePartitionService interface.
void OpenLocalStorage(const url::Origin& origin,
......@@ -338,6 +340,8 @@ class CONTENT_EXPORT StoragePartitionImpl
scoped_refptr<PrefetchURLLoaderService> prefetch_url_loader_service_;
scoped_refptr<CookieStoreContext> cookie_store_context_;
scoped_refptr<GeneratedCodeCacheContext> generated_code_cache_context_;
scoped_refptr<DevToolsBackgroundServicesContext>
devtools_background_services_context_;
// BindingSet for StoragePartitionService, using the process id as the
// binding context type. The process id can subsequently be used during
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment