202 lines
7.8 KiB
Protocol Buffer
202 lines
7.8 KiB
Protocol Buffer
// Copyright 2011 Google Inc.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
// Author: abliss@google.com (Adam Bliss)
|
|
|
|
// Protobuf to encapsulate custom metadata about a resource (not including real
|
|
// HTTP Headers).
|
|
|
|
syntax = "proto2";
|
|
|
|
import "net/instaweb/spriter/public/image_spriter.proto";
|
|
import "net/instaweb/rewriter/dependencies.proto";
|
|
import "net/instaweb/rewriter/input_info.proto";
|
|
|
|
package net_instaweb;
|
|
|
|
message ImageDim {
|
|
optional int32 width = 1 [ default = -1 ];
|
|
optional int32 height = 2 [ default = -1 ];
|
|
};
|
|
|
|
// Information about an images indirectly associated with this resource.
|
|
message AssociatedImageInfo {
|
|
optional string url = 1;
|
|
optional ImageDim dimensions = 2;
|
|
};
|
|
|
|
// The cached result of a rewrite. This is the value of a map where the key
|
|
// is a sequence of input URLs and a filter id. The input array
|
|
// tells us which inputs are used to construct this output; it must be
|
|
// interpreted using the URL-sequence that was used to form the key.
|
|
// Next free tag: 27
|
|
message CachedResult {
|
|
// Tags 1-7 are for internal use by output_resource.
|
|
|
|
// When this is false we have previously processed the URL and have marked
|
|
// down that we cannot do anything with it.
|
|
optional bool optimizable = 1 [ default = true ];
|
|
|
|
// The cached URL of this result. If this CachedResult was actually
|
|
// fetched from the cache and is not a new one produced by
|
|
// EnsureCachedResultCreated this will be valid if and only if
|
|
// optimizable is true.
|
|
optional string url = 2;
|
|
|
|
// tags 3, 4 deleted and should not be reused.
|
|
|
|
// Changes to custom metadata by clients done after we are written to
|
|
// cache are lost, and it's extremely easy to get it wrong. To catch
|
|
// mistakes like that, we mark a CachedResult as 'frozen' upon save,
|
|
// and DCHECK any modifications.
|
|
optional bool frozen = 5;
|
|
|
|
// If the URL is optimizable, this will contain the hash of the encoded
|
|
// resource.
|
|
optional string hash = 6;
|
|
|
|
// If the URL is optimizable, this will contain the extension for the
|
|
// encoded resource, not including the leading "."
|
|
optional string extension = 7;
|
|
|
|
// Tags 11+ are for use by individual filters. 8-10 have been used
|
|
// in the past and should not be reused.
|
|
|
|
// Dimensions of an image file, in pixels. Used by
|
|
// image_rewrite_filter. Note that these dimensions are not
|
|
// necessarily the same as the properties of the img tag,
|
|
// represented by ResourceContext below.
|
|
optional ImageDim image_file_dims = 11;
|
|
|
|
// Filters that produce inlined data --- either due to inlining an external
|
|
// resource or rewriting one that's already inline --- use this field to
|
|
// cache either their input or the output. In either case the raw bytes are
|
|
// cached without any encoding.
|
|
//
|
|
// The input is cached in filters that have very cheap rewrites, and
|
|
// vary the output based on things like the base URL. Output is cached
|
|
// when the rewrite is expensive, with different base URLs being instead
|
|
// incorporated into the key.
|
|
optional bytes inlined_data = 12;
|
|
|
|
// The result of a spriting operation, containing x/y coordinates for each
|
|
// subimage in the sprite.
|
|
// Used by image_combine_filter.
|
|
optional spriter.SpriterResult spriter_result = 13;
|
|
|
|
// Info about the input resources used to create the OutputResource that
|
|
// this CachedResult is based off of.
|
|
repeated InputInfo input = 14;
|
|
|
|
// The image type is actually a net_instaweb::ImageType. It permits image
|
|
// inlining to create an appropriate data: url from this and the inlined_data.
|
|
// It's set only if inlined_data contains an image.
|
|
optional int32 inlined_image_type = 15;
|
|
|
|
// This contains low resolution/quality image contents. This will be set only
|
|
// if DelayImagesFilter is enabled.
|
|
optional bytes low_resolution_inlined_data = 16;
|
|
|
|
// The image type is actually a net_instaweb::ImageType. It permits image
|
|
// inlining to create an appropriate data: url from this and the
|
|
// low_resolution_inlined_data. It's set only if low_resolution_inlined_data
|
|
// contains an image.
|
|
optional int32 low_resolution_inlined_image_type = 17;
|
|
|
|
// When this is false we have previously processed the URL and marked down
|
|
// that the resource could potentially break if its url were changed.
|
|
optional bool url_relocatable = 18 [ default = true ];
|
|
|
|
// When this is true, the filter should canonicalize the url to the contents
|
|
// of url and skip the default resource-based rendering (eg when we recognize
|
|
// a JS library and canonicalize its URL).
|
|
optional bool canonicalize_url = 19;
|
|
|
|
// Stores the size of the rewritten resource.
|
|
optional int64 size = 20;
|
|
|
|
// Stores any debug messages for this result, which are injected into the
|
|
// HTML as comments if the debug filter is enabled.
|
|
repeated string debug_message = 21;
|
|
|
|
reserved 22;
|
|
|
|
// Information about any images indirectly included via this resource, or
|
|
// its dependencies.
|
|
repeated AssociatedImageInfo associated_image_info = 23;
|
|
|
|
// Does this CachedResult represent an InlineOutputResource?
|
|
// If false, this represents a plain OutputResource instead.
|
|
optional bool is_inline_output_resource = 24;
|
|
|
|
// Type of the optimized image. This is actually net_instaweb::ImageType.
|
|
optional int32 optimized_image_type = 25;
|
|
|
|
// Used by CollectDependenciesFilter
|
|
repeated Dependency collected_dependency = 26;
|
|
}
|
|
|
|
// Contains the mapping of input URLs to output URLs. In the general
|
|
// case, multiple inputs may map to multiple outputs.
|
|
//
|
|
// Consider combine_css (slightly more capable than it is today) over
|
|
// the links:
|
|
// <link media="print" href="p0.css"/>
|
|
// <link media="screen" href="p1.css"/>
|
|
// <link media="print" href="p2.css"/>
|
|
// <link media="screen" href="p3.css"/>
|
|
// Combining these would result in two partitions.
|
|
// partition0 = {result="p0+p2.css", input={0,2}}
|
|
// partition1 = {result="p1+p3.css", input={1,3}}
|
|
// Thus the CSS combiner can, as the result of one cache lookup, get
|
|
// back enough information to perform the HTML element substitutions.
|
|
//
|
|
// If this resource depends on inputs that are not mentioned in the partition
|
|
// table above (such as inputs to nested rewrites or those that failed to
|
|
// fetch properly) we add them to other_dependency to know when to invalidate.
|
|
message OutputPartitions {
|
|
repeated CachedResult partition = 1;
|
|
repeated InputInfo other_dependency = 2;
|
|
// Debug messages which can be used even if there are no partitions.
|
|
repeated string debug_message = 3;
|
|
}
|
|
|
|
// Encapsulates all the data needed to rewrite a resource. Any filter needing
|
|
// additional information should add it as optional fields here.
|
|
// Next free tag: 9
|
|
message ResourceContext {
|
|
optional ImageDim desired_image_dims = 1;
|
|
reserved 2;
|
|
optional bool inline_images = 3 [ default = true ];
|
|
optional bool mobile_user_agent = 4;
|
|
|
|
enum LibWebpLevel {
|
|
LIBWEBP_NONE = 0;
|
|
LIBWEBP_LOSSY_ONLY = 1;
|
|
LIBWEBP_LOSSY_LOSSLESS_ALPHA = 2;
|
|
LIBWEBP_ANIMATED = 3;
|
|
}
|
|
optional LibWebpLevel libwebp_level = 5 [default = LIBWEBP_NONE];
|
|
|
|
reserved 6;
|
|
|
|
// Set to true if we may use the image qualities set for small screen.
|
|
optional bool may_use_small_screen_quality = 7;
|
|
|
|
// Set to true if we may use the image qualities set for save-data. The
|
|
// request must have "Save-Data: on" header to make this true. If true,
|
|
// we'll add a unique identifier to the cache key.
|
|
optional bool may_use_save_data_quality = 8;
|
|
}
|