| OLD | NEW | 
|    1 // Copyright 2013 The Chromium Authors. All rights reserved. |    1 // Copyright 2013 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include <string> |    5 #include <string> | 
|    6  |    6  | 
|    7 #include "base/files/file_path.h" |    7 #include "base/files/file_path.h" | 
|    8 #include "base/memory/singleton.h" |    8 #include "base/memory/singleton.h" | 
|    9 #include "base/path_service.h" |    9 #include "base/path_service.h" | 
|   10 #include "base/stl_util.h" |   10 #include "base/stl_util.h" | 
|   11 #include "base/strings/string_number_conversions.h" |   11 #include "base/strings/string_number_conversions.h" | 
|   12 #include "base/strings/string_piece.h" |   12 #include "base/strings/string_piece.h" | 
|   13 #include "net/spdy/spdy_framer.h" |   13 #include "net/spdy/spdy_framer.h" | 
|   14 #include "net/tools/quic/quic_in_memory_cache.h" |   14 #include "net/tools/quic/quic_in_memory_cache.h" | 
|   15 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h" |  | 
|   16 #include "testing/gtest/include/gtest/gtest.h" |   15 #include "testing/gtest/include/gtest/gtest.h" | 
|   17  |   16  | 
|   18 using base::ContainsKey; |   17 using base::ContainsKey; | 
|   19 using base::IntToString; |   18 using base::IntToString; | 
|   20 using base::StringPiece; |   19 using base::StringPiece; | 
|   21 using net::SpdyHeaderBlock; |   20 using net::SpdyHeaderBlock; | 
|   22 using std::list; |   21 using std::list; | 
|   23 using std::string; |   22 using std::string; | 
|   24  |   23  | 
|   25 namespace net { |   24 namespace net { | 
|   26 namespace test { |   25 namespace test { | 
|   27  |   26  | 
|   28 namespace { |   27 namespace { | 
|   29 typedef QuicInMemoryCache::Response Response; |   28 typedef QuicInMemoryCache::Response Response; | 
|   30 typedef QuicInMemoryCache::ServerPushInfo ServerPushInfo; |   29 typedef QuicInMemoryCache::ServerPushInfo ServerPushInfo; | 
|   31 };  // namespace |   30 };  // namespace | 
|   32  |   31  | 
|   33 class QuicInMemoryCacheTest : public ::testing::Test { |   32 class QuicInMemoryCacheTest : public ::testing::Test { | 
|   34  protected: |   33  protected: | 
|   35   QuicInMemoryCacheTest() { QuicInMemoryCachePeer::ResetForTests(); } |  | 
|   36  |  | 
|   37   ~QuicInMemoryCacheTest() override { QuicInMemoryCachePeer::ResetForTests(); } |  | 
|   38  |  | 
|   39   void CreateRequest(string host, string path, SpdyHeaderBlock* headers) { |   34   void CreateRequest(string host, string path, SpdyHeaderBlock* headers) { | 
|   40     (*headers)[":method"] = "GET"; |   35     (*headers)[":method"] = "GET"; | 
|   41     (*headers)[":path"] = path; |   36     (*headers)[":path"] = path; | 
|   42     (*headers)[":authority"] = host; |   37     (*headers)[":authority"] = host; | 
|   43     (*headers)[":scheme"] = "https"; |   38     (*headers)[":scheme"] = "https"; | 
|   44   } |   39   } | 
|   45  |   40  | 
|   46   string CacheDirectory() { |   41   string CacheDirectory() { | 
|   47     base::FilePath path; |   42     base::FilePath path; | 
|   48     PathService::Get(base::DIR_SOURCE_ROOT, &path); |   43     PathService::Get(base::DIR_SOURCE_ROOT, &path); | 
|   49     path = path.AppendASCII("net").AppendASCII("data").AppendASCII( |   44     path = path.AppendASCII("net").AppendASCII("data").AppendASCII( | 
|   50         "quic_in_memory_cache_data"); |   45         "quic_in_memory_cache_data"); | 
|   51     // The file path is known to be an ascii string. |   46     // The file path is known to be an ascii string. | 
|   52     return path.MaybeAsASCII(); |   47     return path.MaybeAsASCII(); | 
|   53   } |   48   } | 
 |   49  | 
 |   50   QuicInMemoryCache cache_; | 
|   54 }; |   51 }; | 
|   55  |   52  | 
|   56 TEST_F(QuicInMemoryCacheTest, GetResponseNoMatch) { |   53 TEST_F(QuicInMemoryCacheTest, GetResponseNoMatch) { | 
|   57   const QuicInMemoryCache::Response* response = |   54   const QuicInMemoryCache::Response* response = | 
|   58       QuicInMemoryCache::GetInstance()->GetResponse("mail.google.com", |   55       cache_.GetResponse("mail.google.com", "/index.html"); | 
|   59                                                     "/index.html"); |  | 
|   60   ASSERT_FALSE(response); |   56   ASSERT_FALSE(response); | 
|   61 } |   57 } | 
|   62  |   58  | 
|   63 TEST_F(QuicInMemoryCacheTest, AddSimpleResponseGetResponse) { |   59 TEST_F(QuicInMemoryCacheTest, AddSimpleResponseGetResponse) { | 
|   64   string response_body("hello response"); |   60   string response_body("hello response"); | 
|   65   QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); |   61   cache_.AddSimpleResponse("www.google.com", "/", 200, response_body); | 
|   66   cache->AddSimpleResponse("www.google.com", "/", 200, response_body); |  | 
|   67  |   62  | 
|   68   SpdyHeaderBlock request_headers; |   63   SpdyHeaderBlock request_headers; | 
|   69   CreateRequest("www.google.com", "/", &request_headers); |   64   CreateRequest("www.google.com", "/", &request_headers); | 
|   70   const QuicInMemoryCache::Response* response = |   65   const QuicInMemoryCache::Response* response = | 
|   71       cache->GetResponse("www.google.com", "/"); |   66       cache_.GetResponse("www.google.com", "/"); | 
|   72   ASSERT_TRUE(response); |   67   ASSERT_TRUE(response); | 
|   73   ASSERT_TRUE(ContainsKey(response->headers(), ":status")); |   68   ASSERT_TRUE(ContainsKey(response->headers(), ":status")); | 
|   74   EXPECT_EQ("200", response->headers().find(":status")->second); |   69   EXPECT_EQ("200", response->headers().find(":status")->second); | 
|   75   EXPECT_EQ(response_body.size(), response->body().length()); |   70   EXPECT_EQ(response_body.size(), response->body().length()); | 
|   76 } |   71 } | 
|   77  |   72  | 
|   78 TEST_F(QuicInMemoryCacheTest, AddResponse) { |   73 TEST_F(QuicInMemoryCacheTest, AddResponse) { | 
|   79   const string kRequestHost = "www.foo.com"; |   74   const string kRequestHost = "www.foo.com"; | 
|   80   const string kRequestPath = "/"; |   75   const string kRequestPath = "/"; | 
|   81   const string kResponseBody("hello response"); |   76   const string kResponseBody("hello response"); | 
|   82  |   77  | 
|   83   SpdyHeaderBlock response_headers; |   78   SpdyHeaderBlock response_headers; | 
|   84   response_headers[":version"] = "HTTP/1.1"; |   79   response_headers[":version"] = "HTTP/1.1"; | 
|   85   response_headers[":status"] = "200"; |   80   response_headers[":status"] = "200"; | 
|   86   response_headers["content-length"] = IntToString(kResponseBody.size()); |   81   response_headers["content-length"] = IntToString(kResponseBody.size()); | 
|   87  |   82  | 
|   88   SpdyHeaderBlock response_trailers; |   83   SpdyHeaderBlock response_trailers; | 
|   89   response_trailers["key-1"] = "value-1"; |   84   response_trailers["key-1"] = "value-1"; | 
|   90   response_trailers["key-2"] = "value-2"; |   85   response_trailers["key-2"] = "value-2"; | 
|   91   response_trailers["key-3"] = "value-3"; |   86   response_trailers["key-3"] = "value-3"; | 
|   92  |   87  | 
|   93   QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); |   88   cache_.AddResponse(kRequestHost, "/", response_headers.Clone(), kResponseBody, | 
|   94   cache->AddResponse(kRequestHost, "/", response_headers.Clone(), kResponseBody, |  | 
|   95                      response_trailers.Clone()); |   89                      response_trailers.Clone()); | 
|   96  |   90  | 
|   97   const QuicInMemoryCache::Response* response = |   91   const QuicInMemoryCache::Response* response = | 
|   98       cache->GetResponse(kRequestHost, kRequestPath); |   92       cache_.GetResponse(kRequestHost, kRequestPath); | 
|   99   EXPECT_EQ(response->headers(), response_headers); |   93   EXPECT_EQ(response->headers(), response_headers); | 
|  100   EXPECT_EQ(response->body(), kResponseBody); |   94   EXPECT_EQ(response->body(), kResponseBody); | 
|  101   EXPECT_EQ(response->trailers(), response_trailers); |   95   EXPECT_EQ(response->trailers(), response_trailers); | 
|  102 } |   96 } | 
|  103  |   97  | 
|  104 TEST_F(QuicInMemoryCacheTest, ReadsCacheDir) { |   98 TEST_F(QuicInMemoryCacheTest, ReadsCacheDir) { | 
|  105   QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory()); |   99   cache_.InitializeFromDirectory(CacheDirectory()); | 
|  106   const QuicInMemoryCache::Response* response = |  100   const QuicInMemoryCache::Response* response = | 
|  107       QuicInMemoryCache::GetInstance()->GetResponse("quic.test.url", |  101       cache_.GetResponse("quic.test.url", "/index.html"); | 
|  108                                                     "/index.html"); |  | 
|  109   ASSERT_TRUE(response); |  102   ASSERT_TRUE(response); | 
|  110   ASSERT_TRUE(ContainsKey(response->headers(), ":status")); |  103   ASSERT_TRUE(ContainsKey(response->headers(), ":status")); | 
|  111   EXPECT_EQ("200", response->headers().find(":status")->second); |  104   EXPECT_EQ("200", response->headers().find(":status")->second); | 
|  112   // Connection headers are not valid in HTTP/2. |  105   // Connection headers are not valid in HTTP/2. | 
|  113   EXPECT_FALSE(ContainsKey(response->headers(), "connection")); |  106   EXPECT_FALSE(ContainsKey(response->headers(), "connection")); | 
|  114   EXPECT_LT(0U, response->body().length()); |  107   EXPECT_LT(0U, response->body().length()); | 
|  115 } |  108 } | 
|  116  |  109  | 
|  117 TEST_F(QuicInMemoryCacheTest, ReadsCacheDirWithServerPushResource) { |  110 TEST_F(QuicInMemoryCacheTest, ReadsCacheDirWithServerPushResource) { | 
|  118   QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory() + |  111   cache_.InitializeFromDirectory(CacheDirectory() + "_with_push"); | 
|  119                                                             "_with_push"); |  | 
|  120   QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); |  | 
|  121   list<ServerPushInfo> resources = |  112   list<ServerPushInfo> resources = | 
|  122       cache->GetServerPushResources("quic.test.url/"); |  113       cache_.GetServerPushResources("quic.test.url/"); | 
|  123   ASSERT_EQ(1UL, resources.size()); |  114   ASSERT_EQ(1UL, resources.size()); | 
|  124 } |  115 } | 
|  125  |  116  | 
|  126 TEST_F(QuicInMemoryCacheTest, ReadsCacheDirWithServerPushResources) { |  117 TEST_F(QuicInMemoryCacheTest, ReadsCacheDirWithServerPushResources) { | 
|  127   QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory() + |  118   cache_.InitializeFromDirectory(CacheDirectory() + "_with_push"); | 
|  128                                                             "_with_push"); |  | 
|  129   QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); |  | 
|  130   list<ServerPushInfo> resources = |  119   list<ServerPushInfo> resources = | 
|  131       cache->GetServerPushResources("quic.test.url/index2.html"); |  120       cache_.GetServerPushResources("quic.test.url/index2.html"); | 
|  132   ASSERT_EQ(2UL, resources.size()); |  121   ASSERT_EQ(2UL, resources.size()); | 
|  133 } |  122 } | 
|  134  |  123  | 
|  135 TEST_F(QuicInMemoryCacheTest, UsesOriginalUrl) { |  124 TEST_F(QuicInMemoryCacheTest, UsesOriginalUrl) { | 
|  136   QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory()); |  125   cache_.InitializeFromDirectory(CacheDirectory()); | 
|  137   const QuicInMemoryCache::Response* response = |  126   const QuicInMemoryCache::Response* response = | 
|  138       QuicInMemoryCache::GetInstance()->GetResponse("quic.test.url", |  127       cache_.GetResponse("quic.test.url", "/index.html"); | 
|  139                                                     "/index.html"); |  | 
|  140   ASSERT_TRUE(response); |  128   ASSERT_TRUE(response); | 
|  141   ASSERT_TRUE(ContainsKey(response->headers(), ":status")); |  129   ASSERT_TRUE(ContainsKey(response->headers(), ":status")); | 
|  142   EXPECT_EQ("200", response->headers().find(":status")->second); |  130   EXPECT_EQ("200", response->headers().find(":status")->second); | 
|  143   // Connection headers are not valid in HTTP/2. |  131   // Connection headers are not valid in HTTP/2. | 
|  144   EXPECT_FALSE(ContainsKey(response->headers(), "connection")); |  132   EXPECT_FALSE(ContainsKey(response->headers(), "connection")); | 
|  145   EXPECT_LT(0U, response->body().length()); |  133   EXPECT_LT(0U, response->body().length()); | 
|  146 } |  134 } | 
|  147  |  135  | 
|  148 TEST_F(QuicInMemoryCacheTest, DefaultResponse) { |  136 TEST_F(QuicInMemoryCacheTest, DefaultResponse) { | 
|  149   // Verify GetResponse returns nullptr when no default is set. |  137   // Verify GetResponse returns nullptr when no default is set. | 
|  150   QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); |  | 
|  151   const QuicInMemoryCache::Response* response = |  138   const QuicInMemoryCache::Response* response = | 
|  152       cache->GetResponse("www.google.com", "/"); |  139       cache_.GetResponse("www.google.com", "/"); | 
|  153   ASSERT_FALSE(response); |  140   ASSERT_FALSE(response); | 
|  154  |  141  | 
|  155   // Add a default response. |  142   // Add a default response. | 
|  156   SpdyHeaderBlock response_headers; |  143   SpdyHeaderBlock response_headers; | 
|  157   response_headers[":version"] = "HTTP/1.1"; |  144   response_headers[":version"] = "HTTP/1.1"; | 
|  158   response_headers[":status"] = "200"; |  145   response_headers[":status"] = "200"; | 
|  159   response_headers["content-length"] = "0"; |  146   response_headers["content-length"] = "0"; | 
|  160   QuicInMemoryCache::Response* default_response = |  147   QuicInMemoryCache::Response* default_response = | 
|  161       new QuicInMemoryCache::Response; |  148       new QuicInMemoryCache::Response; | 
|  162   default_response->set_headers(std::move(response_headers)); |  149   default_response->set_headers(std::move(response_headers)); | 
|  163   cache->AddDefaultResponse(default_response); |  150   cache_.AddDefaultResponse(default_response); | 
|  164  |  151  | 
|  165   // Now we should get the default response for the original request. |  152   // Now we should get the default response for the original request. | 
|  166   response = cache->GetResponse("www.google.com", "/"); |  153   response = cache_.GetResponse("www.google.com", "/"); | 
|  167   ASSERT_TRUE(response); |  154   ASSERT_TRUE(response); | 
|  168   ASSERT_TRUE(ContainsKey(response->headers(), ":status")); |  155   ASSERT_TRUE(ContainsKey(response->headers(), ":status")); | 
|  169   EXPECT_EQ("200", response->headers().find(":status")->second); |  156   EXPECT_EQ("200", response->headers().find(":status")->second); | 
|  170  |  157  | 
|  171   // Now add a set response for / and make sure it is returned |  158   // Now add a set response for / and make sure it is returned | 
|  172   cache->AddSimpleResponse("www.google.com", "/", 302, ""); |  159   cache_.AddSimpleResponse("www.google.com", "/", 302, ""); | 
|  173   response = cache->GetResponse("www.google.com", "/"); |  160   response = cache_.GetResponse("www.google.com", "/"); | 
|  174   ASSERT_TRUE(response); |  161   ASSERT_TRUE(response); | 
|  175   ASSERT_TRUE(ContainsKey(response->headers(), ":status")); |  162   ASSERT_TRUE(ContainsKey(response->headers(), ":status")); | 
|  176   EXPECT_EQ("302", response->headers().find(":status")->second); |  163   EXPECT_EQ("302", response->headers().find(":status")->second); | 
|  177  |  164  | 
|  178   // We should get the default response for other requests. |  165   // We should get the default response for other requests. | 
|  179   response = cache->GetResponse("www.google.com", "/asd"); |  166   response = cache_.GetResponse("www.google.com", "/asd"); | 
|  180   ASSERT_TRUE(response); |  167   ASSERT_TRUE(response); | 
|  181   ASSERT_TRUE(ContainsKey(response->headers(), ":status")); |  168   ASSERT_TRUE(ContainsKey(response->headers(), ":status")); | 
|  182   EXPECT_EQ("200", response->headers().find(":status")->second); |  169   EXPECT_EQ("200", response->headers().find(":status")->second); | 
|  183 } |  170 } | 
|  184  |  171  | 
|  185 TEST_F(QuicInMemoryCacheTest, AddSimpleResponseWithServerPushResources) { |  172 TEST_F(QuicInMemoryCacheTest, AddSimpleResponseWithServerPushResources) { | 
|  186   string request_host = "www.foo.com"; |  173   string request_host = "www.foo.com"; | 
|  187   string response_body("hello response"); |  174   string response_body("hello response"); | 
|  188   const size_t kNumResources = 5; |  175   const size_t kNumResources = 5; | 
|  189   int NumResources = 5; |  176   int NumResources = 5; | 
|  190   list<QuicInMemoryCache::ServerPushInfo> push_resources; |  177   list<QuicInMemoryCache::ServerPushInfo> push_resources; | 
|  191   string scheme = "http"; |  178   string scheme = "http"; | 
|  192   for (int i = 0; i < NumResources; ++i) { |  179   for (int i = 0; i < NumResources; ++i) { | 
|  193     string path = "/server_push_src" + base::IntToString(i); |  180     string path = "/server_push_src" + base::IntToString(i); | 
|  194     string url = scheme + "://" + request_host + path; |  181     string url = scheme + "://" + request_host + path; | 
|  195     GURL resource_url(url); |  182     GURL resource_url(url); | 
|  196     string body = "This is server push response body for " + path; |  183     string body = "This is server push response body for " + path; | 
|  197     SpdyHeaderBlock response_headers; |  184     SpdyHeaderBlock response_headers; | 
|  198     response_headers[":version"] = "HTTP/1.1"; |  185     response_headers[":version"] = "HTTP/1.1"; | 
|  199     response_headers[":status"] = "200"; |  186     response_headers[":status"] = "200"; | 
|  200     response_headers["content-length"] = base::UintToString(body.size()); |  187     response_headers["content-length"] = base::UintToString(body.size()); | 
|  201     push_resources.push_back( |  188     push_resources.push_back( | 
|  202         ServerPushInfo(resource_url, response_headers.Clone(), i, body)); |  189         ServerPushInfo(resource_url, response_headers.Clone(), i, body)); | 
|  203   } |  190   } | 
|  204  |  191  | 
|  205   QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); |  192   cache_.AddSimpleResponseWithServerPushResources( | 
|  206   cache->AddSimpleResponseWithServerPushResources( |  | 
|  207       request_host, "/", 200, response_body, push_resources); |  193       request_host, "/", 200, response_body, push_resources); | 
|  208   string request_url = request_host + "/"; |  194   string request_url = request_host + "/"; | 
|  209   list<ServerPushInfo> resources = cache->GetServerPushResources(request_url); |  195   list<ServerPushInfo> resources = cache_.GetServerPushResources(request_url); | 
|  210   ASSERT_EQ(kNumResources, resources.size()); |  196   ASSERT_EQ(kNumResources, resources.size()); | 
|  211   for (const auto& push_resource : push_resources) { |  197   for (const auto& push_resource : push_resources) { | 
|  212     ServerPushInfo resource = resources.front(); |  198     ServerPushInfo resource = resources.front(); | 
|  213     EXPECT_EQ(resource.request_url.spec(), push_resource.request_url.spec()); |  199     EXPECT_EQ(resource.request_url.spec(), push_resource.request_url.spec()); | 
|  214     EXPECT_EQ(resource.priority, push_resource.priority); |  200     EXPECT_EQ(resource.priority, push_resource.priority); | 
|  215     resources.pop_front(); |  201     resources.pop_front(); | 
|  216   } |  202   } | 
|  217 } |  203 } | 
|  218  |  204  | 
|  219 TEST_F(QuicInMemoryCacheTest, GetServerPushResourcesAndPushResponses) { |  205 TEST_F(QuicInMemoryCacheTest, GetServerPushResourcesAndPushResponses) { | 
|  220   string request_host = "www.foo.com"; |  206   string request_host = "www.foo.com"; | 
|  221   string response_body("hello response"); |  207   string response_body("hello response"); | 
|  222   const size_t kNumResources = 4; |  208   const size_t kNumResources = 4; | 
|  223   int NumResources = 4; |  209   int NumResources = 4; | 
|  224   string scheme = "http"; |  210   string scheme = "http"; | 
|  225   string push_response_status[kNumResources] = {"200", "200", "301", "404"}; |  211   string push_response_status[kNumResources] = {"200", "200", "301", "404"}; | 
|  226   list<QuicInMemoryCache::ServerPushInfo> push_resources; |  212   list<QuicInMemoryCache::ServerPushInfo> push_resources; | 
|  227   for (int i = 0; i < NumResources; ++i) { |  213   for (int i = 0; i < NumResources; ++i) { | 
|  228     string path = "/server_push_src" + base::IntToString(i); |  214     string path = "/server_push_src" + base::IntToString(i); | 
|  229     string url = scheme + "://" + request_host + path; |  215     string url = scheme + "://" + request_host + path; | 
|  230     GURL resource_url(url); |  216     GURL resource_url(url); | 
|  231     string body = "This is server push response body for " + path; |  217     string body = "This is server push response body for " + path; | 
|  232     SpdyHeaderBlock response_headers; |  218     SpdyHeaderBlock response_headers; | 
|  233     response_headers[":version"] = "HTTP/1.1"; |  219     response_headers[":version"] = "HTTP/1.1"; | 
|  234     response_headers[":status"] = push_response_status[i]; |  220     response_headers[":status"] = push_response_status[i]; | 
|  235     response_headers["content-length"] = base::UintToString(body.size()); |  221     response_headers["content-length"] = base::UintToString(body.size()); | 
|  236     push_resources.push_back( |  222     push_resources.push_back( | 
|  237         ServerPushInfo(resource_url, response_headers.Clone(), i, body)); |  223         ServerPushInfo(resource_url, response_headers.Clone(), i, body)); | 
|  238   } |  224   } | 
|  239   QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); |  225   cache_.AddSimpleResponseWithServerPushResources( | 
|  240   cache->AddSimpleResponseWithServerPushResources( |  | 
|  241       request_host, "/", 200, response_body, push_resources); |  226       request_host, "/", 200, response_body, push_resources); | 
|  242   string request_url = request_host + "/"; |  227   string request_url = request_host + "/"; | 
|  243   list<ServerPushInfo> resources = cache->GetServerPushResources(request_url); |  228   list<ServerPushInfo> resources = cache_.GetServerPushResources(request_url); | 
|  244   ASSERT_EQ(kNumResources, resources.size()); |  229   ASSERT_EQ(kNumResources, resources.size()); | 
|  245   int i = 0; |  230   int i = 0; | 
|  246   for (const auto& push_resource : push_resources) { |  231   for (const auto& push_resource : push_resources) { | 
|  247     GURL url = resources.front().request_url; |  232     GURL url = resources.front().request_url; | 
|  248     string host = url.host(); |  233     string host = url.host(); | 
|  249     string path = url.path(); |  234     string path = url.path(); | 
|  250     const QuicInMemoryCache::Response* response = |  235     const QuicInMemoryCache::Response* response = | 
|  251         cache->GetResponse(host, path); |  236         cache_.GetResponse(host, path); | 
|  252     ASSERT_TRUE(response); |  237     ASSERT_TRUE(response); | 
|  253     ASSERT_TRUE(ContainsKey(response->headers(), ":status")); |  238     ASSERT_TRUE(ContainsKey(response->headers(), ":status")); | 
|  254     EXPECT_EQ(push_response_status[i++], |  239     EXPECT_EQ(push_response_status[i++], | 
|  255               response->headers().find(":status")->second); |  240               response->headers().find(":status")->second); | 
|  256     EXPECT_EQ(push_resource.body, response->body()); |  241     EXPECT_EQ(push_resource.body, response->body()); | 
|  257     resources.pop_front(); |  242     resources.pop_front(); | 
|  258   } |  243   } | 
|  259 } |  244 } | 
|  260  |  245  | 
|  261 }  // namespace test |  246 }  // namespace test | 
|  262 }  // namespace net |  247 }  // namespace net | 
| OLD | NEW |