| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 std::replace(output->begin(), output->end(), '+', '-'); | 124 std::replace(output->begin(), output->end(), '+', '-'); |
| 125 std::replace(output->begin(), output->end(), '/', '_'); | 125 std::replace(output->begin(), output->end(), '/', '_'); |
| 126 } | 126 } |
| 127 | 127 |
| 128 // Class that bundles responses for an EmbeddedTestServer(). | 128 // Class that bundles responses for an EmbeddedTestServer(). |
| 129 // Dictionary is at <domain>/dict, data at <domain>/data. | 129 // Dictionary is at <domain>/dict, data at <domain>/data. |
| 130 // The data is sent SDCH encoded if that's allowed by protoocol. | 130 // The data is sent SDCH encoded if that's allowed by protoocol. |
| 131 class SdchResponseHandler { | 131 class SdchResponseHandler { |
| 132 public: | 132 public: |
| 133 // Do initial preparation so that SDCH requests can be handled. | 133 // Do initial preparation so that SDCH requests can be handled. |
| 134 explicit SdchResponseHandler(std::string domain) | 134 explicit SdchResponseHandler(const std::string& domain) |
| 135 : cache_sdch_response_(false), | 135 : cache_sdch_response_(false), weak_ptr_factory_(this) { |
| 136 weak_ptr_factory_(this) { | |
| 137 // Dictionary | 136 // Dictionary |
| 138 sdch_dictionary_contents_ = "Domain: "; | 137 sdch_dictionary_contents_ = "Domain: "; |
| 139 sdch_dictionary_contents_ += domain; | 138 sdch_dictionary_contents_ += domain; |
| 140 sdch_dictionary_contents_ += "\n\n"; | 139 sdch_dictionary_contents_ += "\n\n"; |
| 141 sdch_dictionary_contents_ += kDictionaryContents; | 140 sdch_dictionary_contents_ += kDictionaryContents; |
| 142 | 141 |
| 143 // Dictionary hash for client and server. | 142 // Dictionary hash for client and server. |
| 144 char binary_hash[32]; | 143 char binary_hash[32]; |
| 145 crypto::SHA256HashString(sdch_dictionary_contents_, binary_hash, | 144 crypto::SHA256HashString(sdch_dictionary_contents_, binary_hash, |
| 146 sizeof(binary_hash)); | 145 sizeof(binary_hash)); |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 ASSERT_TRUE(SetupIncognitoBrowser()); | 706 ASSERT_TRUE(SetupIncognitoBrowser()); |
| 708 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); | 707 ASSERT_TRUE(ForceSdchDictionaryLoad(incognito_browser())); |
| 709 | 708 |
| 710 // Data fetches on main browser should not be SDCH encoded. | 709 // Data fetches on main browser should not be SDCH encoded. |
| 711 bool sdch_encoding_used = true; | 710 bool sdch_encoding_used = true; |
| 712 ASSERT_TRUE(GetData(&sdch_encoding_used)); | 711 ASSERT_TRUE(GetData(&sdch_encoding_used)); |
| 713 EXPECT_FALSE(sdch_encoding_used); | 712 EXPECT_FALSE(sdch_encoding_used); |
| 714 } | 713 } |
| 715 | 714 |
| 716 } // namespace | 715 } // namespace |
| OLD | NEW |