OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // End-to-end SDCH tests. Uses the embedded test server to return SDCH | 5 // End-to-end SDCH tests. Uses the embedded test server to return SDCH |
6 // results | 6 // results |
7 | 7 |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 DCHECK_NE(sdch_dictionary_contents_, ""); | 218 DCHECK_NE(sdch_dictionary_contents_, ""); |
219 response->set_content_type("application/x-sdch-dictionary"); | 219 response->set_content_type("application/x-sdch-dictionary"); |
220 response->set_content(sdch_dictionary_contents_); | 220 response->set_content(sdch_dictionary_contents_); |
221 } | 221 } |
222 std::vector<base::Closure> callbacks; | 222 std::vector<base::Closure> callbacks; |
223 callbacks.swap(callback_vector_); | 223 callbacks.swap(callback_vector_); |
224 for (std::vector<base::Closure>::iterator it = callbacks.begin(); | 224 for (std::vector<base::Closure>::iterator it = callbacks.begin(); |
225 it != callbacks.end(); ++it) { | 225 it != callbacks.end(); ++it) { |
226 it->Run(); | 226 it->Run(); |
227 } | 227 } |
228 return response.PassAs<net::test_server::HttpResponse>(); | 228 return response.Pass(); |
229 } | 229 } |
230 | 230 |
231 void WaitAndGetRequestVector(int num_requests, | 231 void WaitAndGetRequestVector(int num_requests, |
232 base::Closure callback, | 232 base::Closure callback, |
233 RequestVector* v) { | 233 RequestVector* v) { |
234 DCHECK_LT(0, num_requests); | 234 DCHECK_LT(0, num_requests); |
235 if (static_cast<size_t>(num_requests) > request_vector_.size()) { | 235 if (static_cast<size_t>(num_requests) > request_vector_.size()) { |
236 callback_vector_.push_back( | 236 callback_vector_.push_back( |
237 base::Bind(&SdchResponseHandler::WaitAndGetRequestVector, | 237 base::Bind(&SdchResponseHandler::WaitAndGetRequestVector, |
238 weak_ptr_factory_.GetWeakPtr(), num_requests, | 238 weak_ptr_factory_.GetWeakPtr(), num_requests, |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 Browser* incognito_browser = CreateIncognitoBrowser(); | 608 Browser* incognito_browser = CreateIncognitoBrowser(); |
609 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser)); | 609 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser)); |
610 | 610 |
611 // Data fetches on main browser should not be SDCH encoded. | 611 // Data fetches on main browser should not be SDCH encoded. |
612 bool sdch_encoding_used = true; | 612 bool sdch_encoding_used = true; |
613 ASSERT_TRUE(GetData(&sdch_encoding_used)); | 613 ASSERT_TRUE(GetData(&sdch_encoding_used)); |
614 EXPECT_FALSE(sdch_encoding_used); | 614 EXPECT_FALSE(sdch_encoding_used); |
615 } | 615 } |
616 | 616 |
617 } // namespace | 617 } // namespace |
OLD | NEW |