| 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 #include <limits.h> | 5 #include <limits.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 | 1229 |
| 1230 class SimpleSdchObserver : public SdchObserver { | 1230 class SimpleSdchObserver : public SdchObserver { |
| 1231 public: | 1231 public: |
| 1232 explicit SimpleSdchObserver(SdchManager* manager) | 1232 explicit SimpleSdchObserver(SdchManager* manager) |
| 1233 : dictionary_used_(0), manager_(manager) { | 1233 : dictionary_used_(0), manager_(manager) { |
| 1234 manager_->AddObserver(this); | 1234 manager_->AddObserver(this); |
| 1235 } | 1235 } |
| 1236 ~SimpleSdchObserver() override { manager_->RemoveObserver(this); } | 1236 ~SimpleSdchObserver() override { manager_->RemoveObserver(this); } |
| 1237 | 1237 |
| 1238 // SdchObserver | 1238 // SdchObserver |
| 1239 void OnDictionaryUsed(SdchManager* manager, | 1239 void OnDictionaryUsed(const std::string& server_hash) override { |
| 1240 const std::string& server_hash) override { | |
| 1241 dictionary_used_++; | 1240 dictionary_used_++; |
| 1242 last_server_hash_ = server_hash; | 1241 last_server_hash_ = server_hash; |
| 1243 } | 1242 } |
| 1244 | 1243 |
| 1245 int dictionary_used_calls() const { return dictionary_used_; } | 1244 int dictionary_used_calls() const { return dictionary_used_; } |
| 1246 std::string last_server_hash() const { return last_server_hash_; } | 1245 std::string last_server_hash() const { return last_server_hash_; } |
| 1247 | 1246 |
| 1248 void OnGetDictionary(SdchManager* /* manager */, | 1247 void OnDictionaryAdded(const GURL& /* dictionary_url */, |
| 1249 const GURL& /* request_url */, | 1248 const std::string& /* server_hash */) override {} |
| 1249 void OnDictionaryRemoved(const std::string& /* server_hash */) override {} |
| 1250 void OnGetDictionary(const GURL& /* request_url */, |
| 1250 const GURL& /* dictionary_url */) override {} | 1251 const GURL& /* dictionary_url */) override {} |
| 1251 void OnClearDictionaries(SdchManager* /* manager */) override {} | 1252 void OnClearDictionaries() override {} |
| 1252 | 1253 |
| 1253 private: | 1254 private: |
| 1254 int dictionary_used_; | 1255 int dictionary_used_; |
| 1255 std::string last_server_hash_; | 1256 std::string last_server_hash_; |
| 1256 SdchManager* manager_; | 1257 SdchManager* manager_; |
| 1257 | 1258 |
| 1258 DISALLOW_COPY_AND_ASSIGN(SimpleSdchObserver); | 1259 DISALLOW_COPY_AND_ASSIGN(SimpleSdchObserver); |
| 1259 }; | 1260 }; |
| 1260 | 1261 |
| 1261 TEST_F(SdchFilterTest, DictionaryUsedSignaled) { | 1262 TEST_F(SdchFilterTest, DictionaryUsedSignaled) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1291 | 1292 |
| 1292 filter.reset(nullptr); | 1293 filter.reset(nullptr); |
| 1293 | 1294 |
| 1294 // Confirm that we got a "DictionaryUsed" signal from the SdchManager | 1295 // Confirm that we got a "DictionaryUsed" signal from the SdchManager |
| 1295 // for our dictionary. | 1296 // for our dictionary. |
| 1296 EXPECT_EQ(1, observer.dictionary_used_calls()); | 1297 EXPECT_EQ(1, observer.dictionary_used_calls()); |
| 1297 EXPECT_EQ(server_hash, observer.last_server_hash()); | 1298 EXPECT_EQ(server_hash, observer.last_server_hash()); |
| 1298 } | 1299 } |
| 1299 | 1300 |
| 1300 } // namespace net | 1301 } // namespace net |
| OLD | NEW |