Commit d4ee9073 authored by Stuart Langley's avatar Stuart Langley Committed by Commit Bot

Merge IndexedDBClient and IndexedDBClientImpl.

IndexedDBClientImpl is no longer required now that the web/ layer has been
removed and it's contents moved to modules/ and core/.

Bug: 731490
Change-Id: Ia5720f6326e742b606002ddddcafb5cd5a24e460
Reviewed-on: https://chromium-review.googlesource.com/597570Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Stuart Langley <slangley@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491930}
parent bbefdd9b
......@@ -50,7 +50,7 @@
#include "modules/filesystem/LocalFileSystemClient.h"
#include "modules/gamepad/NavigatorGamepad.h"
#include "modules/imagebitmap/ImageBitmapRenderingContext.h"
#include "modules/indexeddb/IndexedDBClientImpl.h"
#include "modules/indexeddb/IndexedDBClient.h"
#include "modules/indexeddb/InspectorIndexedDBAgent.h"
#include "modules/installation/InstallationServiceImpl.h"
#include "modules/installedapp/InstalledAppController.h"
......@@ -157,7 +157,7 @@ void ModulesInitializer::InstallSupplements(LocalFrame& frame) const {
ProvidePushControllerTo(frame, client->PushClient());
ProvideUserMediaTo(frame,
UserMediaClientImpl::Create(client->UserMediaClient()));
ProvideIndexedDBClientTo(frame, IndexedDBClientImpl::Create(frame));
ProvideIndexedDBClientTo(frame, IndexedDBClient::Create(frame));
ProvideLocalFileSystemTo(frame, LocalFileSystemClient::Create());
NavigatorContentUtils::ProvideTo(
*frame.DomWindow()->navigator(),
......@@ -183,7 +183,7 @@ void ModulesInitializer::ProvideLocalFileSystemToWorker(
void ModulesInitializer::ProvideIndexedDBClientToWorker(
WorkerClients& worker_clients) const {
::blink::ProvideIndexedDBClientToWorker(
&worker_clients, IndexedDBClientImpl::Create(worker_clients));
&worker_clients, IndexedDBClient::Create(worker_clients));
}
MediaControls* ModulesInitializer::CreateMediaControls(
......
......@@ -47,7 +47,7 @@
#include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerInspectorProxy.h"
#include "core/workers/WorkerScriptLoader.h"
#include "modules/indexeddb/IndexedDBClientImpl.h"
#include "modules/indexeddb/IndexedDBClient.h"
#include "modules/serviceworkers/ServiceWorkerContainerClient.h"
#include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
#include "modules/serviceworkers/ServiceWorkerGlobalScopeProxy.h"
......@@ -376,7 +376,7 @@ void WebEmbeddedWorkerImpl::StartWorkerThread() {
WorkerClients* worker_clients = WorkerClients::Create();
ProvideIndexedDBClientToWorker(worker_clients,
IndexedDBClientImpl::Create(*worker_clients));
IndexedDBClient::Create(*worker_clients));
ProvideContentSettingsClientToWorker(worker_clients,
std::move(content_settings_client_));
......
......@@ -61,8 +61,6 @@ blink_modules_sources("indexeddb") {
"IndexedDB.h",
"IndexedDBClient.cpp",
"IndexedDBClient.h",
"IndexedDBClientImpl.cpp",
"IndexedDBClientImpl.h",
"InspectorIndexedDBAgent.cpp",
"InspectorIndexedDBAgent.h",
"WebIDBCallbacksImpl.cpp",
......
......@@ -4,14 +4,27 @@
#include "modules/indexeddb/IndexedDBClient.h"
#include "bindings/core/v8/WorkerOrWorkletScriptController.h"
#include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h"
#include "core/frame/ContentSettingsClient.h"
#include "core/frame/LocalFrame.h"
#include "core/workers/WorkerClients.h"
#include "core/workers/WorkerContentSettingsClient.h"
#include "core/workers/WorkerGlobalScope.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "public/platform/WebSecurityOrigin.h"
namespace blink {
IndexedDBClient* IndexedDBClient::Create(LocalFrame& frame) {
return new IndexedDBClient(frame);
}
IndexedDBClient* IndexedDBClient::Create(WorkerClients& worker_clients) {
return new IndexedDBClient(worker_clients);
}
IndexedDBClient::IndexedDBClient(LocalFrame& frame)
: Supplement<LocalFrame>(frame) {}
......@@ -29,6 +42,26 @@ IndexedDBClient* IndexedDBClient::From(ExecutionContext* context) {
Supplement<WorkerClients>::From(clients, SupplementName()));
}
bool IndexedDBClient::AllowIndexedDB(ExecutionContext* context,
const String& name) {
DCHECK(context->IsContextThread());
SECURITY_DCHECK(context->IsDocument() || context->IsWorkerGlobalScope());
if (context->IsDocument()) {
Document* document = ToDocument(context);
LocalFrame* frame = document->GetFrame();
if (!frame)
return false;
DCHECK(frame->GetContentSettingsClient());
return frame->GetContentSettingsClient()->AllowIndexedDB(
name, context->GetSecurityOrigin());
}
WorkerGlobalScope& worker_global_scope = *ToWorkerGlobalScope(context);
return WorkerContentSettingsClient::From(worker_global_scope)
->AllowIndexedDB(name);
}
const char* IndexedDBClient::SupplementName() {
return "IndexedDBClient";
}
......
......@@ -41,30 +41,31 @@ class ExecutionContext;
class LocalFrame;
class WorkerClients;
class MODULES_EXPORT IndexedDBClient
: public GarbageCollectedFinalized<IndexedDBClient>,
public Supplement<LocalFrame>,
public Supplement<WorkerClients> {
class IndexedDBClient : public GarbageCollected<IndexedDBClient>,
public Supplement<LocalFrame>,
public Supplement<WorkerClients> {
USING_GARBAGE_COLLECTED_MIXIN(IndexedDBClient);
WTF_MAKE_NONCOPYABLE(IndexedDBClient);
public:
explicit IndexedDBClient(LocalFrame&);
explicit IndexedDBClient(WorkerClients&);
virtual ~IndexedDBClient() {}
static IndexedDBClient* Create(LocalFrame&);
static IndexedDBClient* Create(WorkerClients&);
DECLARE_VIRTUAL_TRACE();
virtual bool AllowIndexedDB(ExecutionContext*, const String& name) = 0;
bool AllowIndexedDB(ExecutionContext*, const String& name);
static IndexedDBClient* From(ExecutionContext*);
static const char* SupplementName();
private:
explicit IndexedDBClient(LocalFrame&);
explicit IndexedDBClient(WorkerClients&);
};
MODULES_EXPORT void ProvideIndexedDBClientTo(LocalFrame&, IndexedDBClient*);
void ProvideIndexedDBClientTo(LocalFrame&, IndexedDBClient*);
MODULES_EXPORT void ProvideIndexedDBClientToWorker(WorkerClients*,
IndexedDBClient*);
void ProvideIndexedDBClientToWorker(WorkerClients*, IndexedDBClient*);
} // namespace blink
......
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "modules/indexeddb/IndexedDBClientImpl.h"
#include "bindings/core/v8/WorkerOrWorkletScriptController.h"
#include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h"
#include "core/frame/ContentSettingsClient.h"
#include "core/workers/WorkerContentSettingsClient.h"
#include "core/workers/WorkerGlobalScope.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "public/platform/WebSecurityOrigin.h"
#include "public/web/WebKit.h"
namespace blink {
IndexedDBClient* IndexedDBClientImpl::Create(LocalFrame& frame) {
return new IndexedDBClientImpl(frame);
}
IndexedDBClient* IndexedDBClientImpl::Create(WorkerClients& worker_clients) {
return new IndexedDBClientImpl(worker_clients);
}
IndexedDBClientImpl::IndexedDBClientImpl(LocalFrame& frame)
: IndexedDBClient(frame) {}
IndexedDBClientImpl::IndexedDBClientImpl(WorkerClients& worker_clients)
: IndexedDBClient(worker_clients) {}
bool IndexedDBClientImpl::AllowIndexedDB(ExecutionContext* context,
const String& name) {
DCHECK(context->IsContextThread());
SECURITY_DCHECK(context->IsDocument() || context->IsWorkerGlobalScope());
if (context->IsDocument()) {
Document* document = ToDocument(context);
LocalFrame* frame = document->GetFrame();
if (!frame)
return false;
DCHECK(frame->GetContentSettingsClient());
return frame->GetContentSettingsClient()->AllowIndexedDB(
name, context->GetSecurityOrigin());
}
WorkerGlobalScope& worker_global_scope = *ToWorkerGlobalScope(context);
return WorkerContentSettingsClient::From(worker_global_scope)
->AllowIndexedDB(name);
}
} // namespace blink
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef IndexedDBClientImpl_h
#define IndexedDBClientImpl_h
#include "modules/ModulesExport.h"
#include "modules/indexeddb/IndexedDBClient.h"
namespace blink {
class ExecutionContext;
// This class is used to bypass the disallowed dependency from modules/ to web/
// to call allowIndexedDB() from modules/. ChromeClient is a mechanism to bypass
// the dependency but we cannot use ChromeClient here because
// IndexedDBClientImpl is used by worker threads but ChromeClient works only
// for the main thread.
class IndexedDBClientImpl final : public IndexedDBClient {
public:
MODULES_EXPORT static IndexedDBClient* Create(LocalFrame&);
MODULES_EXPORT static IndexedDBClient* Create(WorkerClients&);
bool AllowIndexedDB(ExecutionContext*, const String& name) override;
private:
explicit IndexedDBClientImpl(LocalFrame&);
explicit IndexedDBClientImpl(WorkerClients&);
};
} // namespace blink
#endif // IndexedDBClientImpl_h
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