// Copyright 2018 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_BROWSER_CODE_CACHE_GENERATED_CODE_CACHE_H_ #define CONTENT_BROWSER_CODE_CACHE_GENERATED_CODE_CACHE_H_ #include <map> #include <queue> #include "base/containers/queue.h" #include "base/files/file_path.h" #include "base/memory/weak_ptr.h" #include "base/timer/timer.h" #include "content/browser/code_cache/simple_lru_cache.h" #include "content/common/content_export.h" #include "mojo/public/cpp/base/big_buffer.h" #include "net/base/io_buffer.h" #include "net/base/network_isolation_key.h" #include "net/disk_cache/disk_cache.h" #include "url/origin.h" namespace content { // Cache for storing generated code from the renderer on the disk. This cache // uses |resource_url| + |origin_lock| as a key for storing the generated code. // |resource_url| is the url corresponding to the requested resource. // |origin_lock| is the origin that the renderer which requested this resource // is locked to. This is used to enforce site isolation policy on cached code. // For example, if SitePerProcess is enabled and http://script.com/script1.js is // requested by http://example.com, then http://script.com/script.js is the // resource_url and http://example.com is the origin_lock. // // The key is generated by concatenating the serialized url and origin lock // with a separator in between. The separator is non-valid URL characters, to // prevent any attacks by crafting the URLs. |origin_lock| could be empty when // renderer is not locked to an origin (ex:SitePerProcess is disabled) and it // is safe to use only |resource_url| as the key in such cases. // // This uses a simple disk_cache backend. It just stores one data stream and // stores response_time + generated code as one data blob. // // There exists one cache per storage partition and is owned by the storage // partition. This cache is created, accessed and destroyed on the I/O // thread. class CONTENT_EXPORT GeneratedCodeCache { … }; } // namespace content #endif // CONTENT_BROWSER_CODE_CACHE_GENERATED_CODE_CACHE_H_