2
* Copyright 2010 Google Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
// Author: sligocki@google.com (Shawn Ligocki)
19
// Input resource created based on a local file.
21
#ifndef NET_INSTAWEB_REWRITER_PUBLIC_FILE_INPUT_RESOURCE_H_
22
#define NET_INSTAWEB_REWRITER_PUBLIC_FILE_INPUT_RESOURCE_H_
24
#include "net/instaweb/http/public/request_context.h"
25
#include "net/instaweb/rewriter/public/resource.h"
26
#include "net/instaweb/util/public/basictypes.h"
27
#include "net/instaweb/util/public/string.h"
28
#include "net/instaweb/util/public/string_util.h"
30
namespace net_instaweb {
35
class ResponseHeaders;
38
class FileInputResource : public Resource {
40
FileInputResource(const RewriteDriver* driver,
41
const ContentType* type,
43
StringPiece filename);
44
virtual ~FileInputResource();
46
// Uses default no-op Freshen implementation because file-based resources
47
// are fetched each time they are needed.
49
virtual bool IsValidAndCacheable() const;
51
// Set OutputPartition's input info used for expiration validation.
52
virtual void FillInPartitionInputInfo(HashHint include_content_hash,
55
virtual GoogleString url() const { return url_; }
57
virtual bool UseHttpCache() const { return false; }
60
void SetDefaultHeaders(const ContentType* content_type,
61
ResponseHeaders* header, MessageHandler* handler);
63
virtual void LoadAndCallback(NotCacheablePolicy not_cacheable_policy,
64
const RequestContextPtr& request_context,
65
AsyncCallback* callback);
69
GoogleString filename_;
70
int64 last_modified_time_sec_; // Loaded from file mtime.
71
int64 load_from_file_cache_ttl_ms_;
72
bool load_from_file_ttl_set_;
74
DISALLOW_COPY_AND_ASSIGN(FileInputResource);
77
} // namespace net_instaweb
79
#endif // NET_INSTAWEB_REWRITER_PUBLIC_FILE_INPUT_RESOURCE_H_