Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
data_url_input_resource.h
Go to the documentation of this file.
1 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_DATA_URL_INPUT_RESOURCE_H_
2 #define NET_INSTAWEB_REWRITER_PUBLIC_DATA_URL_INPUT_RESOURCE_H_
3 
4 /*
5  * Copyright 2010 Google Inc.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http:///www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
25 
26 #include "net/instaweb/http/public/request_context.h"
33 
34 namespace net_instaweb {
35 
36 class InputInfo;
37 class RewriteDriver;
38 struct ContentType;
39 
41  public:
43  static ResourcePtr Make(const StringPiece& url, const RewriteDriver* driver) {
44  ResourcePtr resource;
45  const ContentType* type;
46  Encoding encoding;
47  StringPiece encoded_contents;
51  GoogleString* url_copy = new GoogleString();
52  url.CopyToString(url_copy);
53  if (ParseDataUrl(*url_copy, &type, &encoding, &encoded_contents)) {
54  resource.reset(new DataUrlInputResource(url_copy, encoding, type,
55  encoded_contents, driver));
56  }
57  return resource;
58  }
59 
60  virtual ~DataUrlInputResource();
61 
62  virtual bool IsValidAndCacheable() const;
63 
65  virtual void FillInPartitionInputInfo(HashHint include_content_hash,
66  InputInfo* input);
67 
68  virtual GoogleString url() const { return *url_.get(); }
69 
70  virtual bool UseHttpCache() const { return false; }
71 
72  protected:
73  virtual void LoadAndCallback(NotCacheablePolicy not_cacheable_policy,
74  const RequestContextPtr& request_context,
75  AsyncCallback* callback);
76 
77  private:
79  Encoding encoding,
80  const ContentType* type,
81  const StringPiece& encoded_contents,
82  const RewriteDriver* driver);
83 
85  const Encoding encoding_;
86  const StringPiece encoded_contents_;
87  GoogleString decoded_contents_;
88 
89 
90 };
91 
92 }
93 
94 #endif
bool ParseDataUrl(const StringPiece &url, const ContentType **content_type, Encoding *encoding, StringPiece *encoded_content)
virtual GoogleString url() const
Gets the absolute URL of the resource.
Definition: data_url_input_resource.h:68
Encoding
Definition: data_url.h:28
Definition: data_url_input_resource.h:40
Definition: resource.h:57
NotCacheablePolicy
Definition: resource.h:68
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
static ResourcePtr Make(const StringPiece &url, const RewriteDriver *driver)
We expose a factory; parse failure returns NULL.
Definition: data_url_input_resource.h:43
Definition: rewrite_driver.h:100
virtual bool UseHttpCache() const
Definition: data_url_input_resource.h:70
Definition: content_type.h:31
virtual void FillInPartitionInputInfo(HashHint include_content_hash, InputInfo *input)
Set OutputPartition's input info used for expiration validation.
virtual void LoadAndCallback(NotCacheablePolicy not_cacheable_policy, const RequestContextPtr &request_context, AsyncCallback *callback)
virtual bool IsValidAndCacheable() const