Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: net/filter/sdch_filter_unittest.cc

Issue 1133763003: SdchObserver: add OnDictionary{Added,Removed} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove manager parameter from SdchObserver Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698