Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit 3ac0192

Browse files
committed
backport various changes to make #1050 work
1 parent 741a865 commit 3ac0192

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

‎net/instaweb/automatic/proxy_interface_test.cc‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -749,22 +749,25 @@ TEST_F(ProxyInterfaceTest, PassThroughEmptyResource) {
749749
ResponseHeaders response_headers;
750750
FetchFromProxy("text.txt", true, &text, &response_headers);
751751
EXPECT_EQ(kContent, text);
752+
// HTTP resource not found the first time.
753+
EXPECT_EQ(1, http_cache()->cache_misses()->Get());
754+
EXPECT_EQ(0, http_cache()->cache_hits()->Get());
752755
// One lookup for ajax metadata and one for the HTTP response. Neither are
753756
// found.
754757
EXPECT_EQ(2, lru_cache()->num_misses());
755-
EXPECT_EQ(1, http_cache()->cache_misses()->Get());
756758
EXPECT_EQ(0, lru_cache()->num_hits());
757759

758760
ClearStats();
759761
GoogleString text2;
760762
ResponseHeaders response_headers2;
761763
FetchFromProxy("text.txt", true, &text2, &response_headers2);
762764
EXPECT_EQ(kContent, text2);
763-
// The HTTP response is found but the ajax metadata is not found.
764-
EXPECT_EQ(1, lru_cache()->num_hits());
765-
EXPECT_EQ(1, http_cache()->cache_hits()->Get());
766-
EXPECT_EQ(1, lru_cache()->num_misses());
767-
EXPECT_EQ(0, http_cache()->cache_misses()->Get());
765+
// Empty resources are not remembered in this flow, so stats are exactly the
766+
// same on second load.
767+
EXPECT_EQ(1, http_cache()->cache_misses()->Get());
768+
EXPECT_EQ(0, http_cache()->cache_hits()->Get());
769+
EXPECT_EQ(2, lru_cache()->num_misses());
770+
EXPECT_EQ(0, lru_cache()->num_hits());
768771
}
769772

770773
TEST_F(ProxyInterfaceTest, SetCookieNotCached) {

‎net/instaweb/rewriter/css_flatten_imports_test.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ TEST_F(CssFlattenImportsTest, DontFlattenOverTinyLimit) {
605605
TEST_F(CssFlattenImportsTest, FlattenEmpty) {
606606
// We intentionally do not inline any empty resources.
607607
const char kFilename[] = "empty.css";
608-
const char css_in[] = "@import url(http://test.com/empty.css);";
608+
const char css_in[] = "@import url(http://test.com/empty.css) ;";
609609
const char empty_content[] = "";
610610

611611
SetResponseWithDefaultHeaders(kFilename, kContentTypeCss, empty_content, 100);

‎net/instaweb/rewriter/inline_rewrite_context.cc‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,8 @@ bool InlineRewriteContext::Partition(OutputPartitions* partitions,
8484

8585
bool ok = false;
8686
GoogleString reason_for_failure;
87-
if (!resource->IsSafeToRewrite(rewrite_uncacheable())) {
87+
if (!resource->IsSafeToRewrite(rewrite_uncacheable(), &reason_for_failure)) {
8888
AddRecheckDependency();
89-
// TODO(morlovich): Follow up by integrating with jmaessen's instrumentation
90-
// of IsSafeToRewrite?
91-
reason_for_failure =
92-
"Can't inline since resource not fetchable or cacheable";
9389
} else {
9490
resource->AddInputInfoToPartition(Resource::kOmitInputHash, 0, partition);
9591
if (ShouldInline(resource, &reason_for_failure)) {

0 commit comments

Comments
 (0)