
HasDataResource checks if there exists a resource for a given resource ID without actually decompressing the data. This is specifically useful to WebUI renderer processes when the WebUI In-Process Resource Loading feature is turned on. In this scenario, the renderer process receives resource IDs from the browser process which may or may not point to a file it has memory-mapped. (This uncertainty occurs because these resource IDs come from the browser process which has broader file access and assumes that it is the one accessing the resources. The browser process does not assume any knowledge about the access privileges of the renderer process, so it cannot pre-filter these resource IDs.) In production, the renderer process is not expected to receive resource IDs pointing to files other than 'resources.pak', so calling HasDataResource there would be more defensive than functional. Where this can happen is in some browser tests, for example, which add additional data sources pointing to an ad-hoc memory-mapped 'browser_tests.pak' file, which is not memory-mapped in renderer processes. If the renderer process finds that it cannot access the resource, then it should fall back to requesting it from the browser process. This new method makes the resource existence check feasible. The aforementioned fallback logic will be added in a future commit. Bug: 362511750 Change-Id: I567ed75d0c2a9d2a862673536f255e2eada32740 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5932328 Reviewed-by: Sean Topping <seantopping@chromium.org> Commit-Queue: Alex Yang <aycyang@chromium.org> Reviewed-by: Kentaro Hara <haraken@chromium.org> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Reviewed-by: Scott Violet <sky@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Cr-Commit-Position: refs/heads/main@{#1369499}
73 lines
2.8 KiB
C++
73 lines
2.8 KiB
C++
// Copyright 2014 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_
|
|
#define CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#include "base/task/sequenced_task_runner.h"
|
|
#include "base/task/single_thread_task_runner.h"
|
|
#include "base/timer/timer.h"
|
|
#include "build/build_config.h"
|
|
#include "components/webcrypto/webcrypto_impl.h"
|
|
#include "content/common/content_export.h"
|
|
#include "third_party/blink/public/common/input/web_gesture_device.h"
|
|
#include "third_party/blink/public/platform/platform.h"
|
|
#include "third_party/blink/public/platform/web_url_error.h"
|
|
#include "third_party/blink/public/public_buildflags.h"
|
|
|
|
namespace webcrypto {
|
|
class WebCryptoImpl;
|
|
} // namespace webcrypto
|
|
|
|
namespace content {
|
|
|
|
class CONTENT_EXPORT BlinkPlatformImpl : public blink::Platform {
|
|
public:
|
|
BlinkPlatformImpl();
|
|
explicit BlinkPlatformImpl(
|
|
scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner);
|
|
~BlinkPlatformImpl() override;
|
|
|
|
// blink::Platform implementation.
|
|
bool IsURLSavableForSavableResource(const blink::WebURL& url) override;
|
|
size_t MaxDecodedImageBytes() override;
|
|
bool IsLowEndDevice() override;
|
|
void RecordAction(const blink::UserMetricsAction&) override;
|
|
bool HasDataResource(int resource_id) const override;
|
|
blink::WebData GetDataResource(int resource_id,
|
|
ui::ResourceScaleFactor scale_factor) override;
|
|
std::string GetDataResourceString(int resource_id) override;
|
|
blink::WebString QueryLocalizedString(int resource_id) override;
|
|
blink::WebString QueryLocalizedString(int resource_id,
|
|
const blink::WebString& value) override;
|
|
blink::WebString QueryLocalizedString(
|
|
int resource_id,
|
|
const blink::WebString& value1,
|
|
const blink::WebString& value2) override;
|
|
void SuddenTerminationChanged(bool enabled) override {}
|
|
blink::WebCrypto* Crypto() override;
|
|
blink::ThreadSafeBrowserInterfaceBrokerProxy* GetBrowserInterfaceBroker()
|
|
override;
|
|
scoped_refptr<base::SingleThreadTaskRunner> GetIOTaskRunner() const override;
|
|
scoped_refptr<base::SequencedTaskRunner>
|
|
GetMediaStreamVideoSourceVideoTaskRunner() const override;
|
|
std::unique_ptr<NestedMessageLoopRunner> CreateNestedMessageLoopRunner()
|
|
const override;
|
|
|
|
private:
|
|
scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_;
|
|
scoped_refptr<base::SequencedTaskRunner>
|
|
media_stream_video_source_video_task_runner_;
|
|
const scoped_refptr<blink::ThreadSafeBrowserInterfaceBrokerProxy>
|
|
browser_interface_broker_proxy_;
|
|
webcrypto::WebCryptoImpl web_crypto_;
|
|
};
|
|
|
|
} // namespace content
|
|
|
|
#endif // CONTENT_CHILD_BLINK_PLATFORM_IMPL_H_
|