chromium/third_party/blink/public/mojom/loader/code_cache.mojom

// 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.

module blink.mojom;

import "mojo/public/mojom/base/big_buffer.mojom";
import "mojo/public/mojom/base/time.mojom";
import "url/mojom/origin.mojom";
import "url/mojom/url.mojom";

// Enumeration of distinct code cache types.
enum CodeCacheType {
  kJavascript,          // Javascript bytecode.
  kWebAssembly,         // WebAssembly compiled module code.
};

// Interface to the code cache in the browser process. Renderer processes
// can use this interface to persistently store and retrieve executable code
// generated for a URL.
interface CodeCacheHost {
  // Requests that the browser cache |data| associated with |url| and
  // |expected_response_time|.
  DidGenerateCacheableMetadata(CodeCacheType cache_type,
                               url.mojom.Url url,
                               mojo_base.mojom.Time expected_response_time,
                               mojo_base.mojom.BigBuffer data);

  FetchCachedCode(CodeCacheType cache_type, url.mojom.Url url) =>
      (mojo_base.mojom.Time response_time, mojo_base.mojom.BigBuffer data);

  ClearCodeCacheEntry(CodeCacheType cache_type, url.mojom.Url url);

  // Requests that the browser cache |data| for the specified CacheStorage entry.
  // TODO(kinuko): Consider making the renderer-side code directly call into the
  // origin's CacheStoragePtr.
  DidGenerateCacheableMetadataInCacheStorage(
      url.mojom.Url url, mojo_base.mojom.Time expected_response_time,
      mojo_base.mojom.BigBuffer data, string cache_storage_cache_name);
};