| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <utility> |
| 10 | 11 |
| 11 #include "base/base64.h" | 12 #include "base/base64.h" |
| 12 #include "base/bind.h" | 13 #include "base/bind.h" |
| 13 #include "base/callback.h" | 14 #include "base/callback.h" |
| 14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 15 #include "base/files/scoped_temp_dir.h" | 16 #include "base/files/scoped_temp_dir.h" |
| 16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 18 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
| 19 #include "base/strings/string_tokenizer.h" | 20 #include "base/strings/string_tokenizer.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 response->AddCustomHeader("Cache-Control", "max-age=3600"); | 224 response->AddCustomHeader("Cache-Control", "max-age=3600"); |
| 224 response->set_content_type("application/x-sdch-dictionary"); | 225 response->set_content_type("application/x-sdch-dictionary"); |
| 225 response->set_content(sdch_dictionary_contents_); | 226 response->set_content(sdch_dictionary_contents_); |
| 226 } | 227 } |
| 227 std::vector<base::Closure> callbacks; | 228 std::vector<base::Closure> callbacks; |
| 228 callbacks.swap(callback_vector_); | 229 callbacks.swap(callback_vector_); |
| 229 for (std::vector<base::Closure>::iterator it = callbacks.begin(); | 230 for (std::vector<base::Closure>::iterator it = callbacks.begin(); |
| 230 it != callbacks.end(); ++it) { | 231 it != callbacks.end(); ++it) { |
| 231 it->Run(); | 232 it->Run(); |
| 232 } | 233 } |
| 233 return response.Pass(); | 234 return std::move(response); |
| 234 } | 235 } |
| 235 | 236 |
| 236 void WaitAndGetRequestVector(int num_requests, | 237 void WaitAndGetRequestVector(int num_requests, |
| 237 base::Closure callback, | 238 base::Closure callback, |
| 238 RequestVector* v) { | 239 RequestVector* v) { |
| 239 DCHECK_LT(0, num_requests); | 240 DCHECK_LT(0, num_requests); |
| 240 if (static_cast<size_t>(num_requests) > request_vector_.size()) { | 241 if (static_cast<size_t>(num_requests) > request_vector_.size()) { |
| 241 callback_vector_.push_back( | 242 callback_vector_.push_back( |
| 242 base::Bind(&SdchResponseHandler::WaitAndGetRequestVector, | 243 base::Bind(&SdchResponseHandler::WaitAndGetRequestVector, |
| 243 weak_ptr_factory_.GetWeakPtr(), num_requests, | 244 weak_ptr_factory_.GetWeakPtr(), num_requests, |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 ASSERT_TRUE(SetupIncognitoBrowser()); | 711 ASSERT_TRUE(SetupIncognitoBrowser()); |
| 711 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); | 712 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); |
| 712 | 713 |
| 713 // Data fetches on main browser should not be SDCH encoded. | 714 // Data fetches on main browser should not be SDCH encoded. |
| 714 bool sdch_encoding_used = true; | 715 bool sdch_encoding_used = true; |
| 715 ASSERT_TRUE(GetData(&sdch_encoding_used)); | 716 ASSERT_TRUE(GetData(&sdch_encoding_used)); |
| 716 EXPECT_FALSE(sdch_encoding_used); | 717 EXPECT_FALSE(sdch_encoding_used); |
| 717 } | 718 } |
| 718 | 719 |
| 719 } // namespace | 720 } // namespace |
| OLD | NEW |