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

Side by Side Diff: net/sdch/sdch_owner_unittest.cc

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: REBASE Created 4 years, 3 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 "net/sdch/sdch_owner.h" 5 #include "net/sdch/sdch_owner.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 for (std::vector<PendingRequest>::iterator it = requests_.begin(); 257 for (std::vector<PendingRequest>::iterator it = requests_.begin();
258 it != requests_.end(); ++it) { 258 it != requests_.end(); ++it) {
259 if (it->url_ == dictionary_url) 259 if (it->url_ == dictionary_url)
260 return true; 260 return true;
261 } 261 }
262 return false; 262 return false;
263 } 263 }
264 264
265 bool CompletePendingRequest(const GURL& dictionary_url, 265 bool CompletePendingRequest(const GURL& dictionary_url,
266 const std::string& dictionary_text, 266 const std::string& dictionary_text,
267 const BoundNetLog& net_log, 267 const NetLogWithSource& net_log,
268 bool was_from_cache) { 268 bool was_from_cache) {
269 for (std::vector<PendingRequest>::iterator it = requests_.begin(); 269 for (std::vector<PendingRequest>::iterator it = requests_.begin();
270 it != requests_.end(); ++it) { 270 it != requests_.end(); ++it) {
271 if (it->url_ == dictionary_url) { 271 if (it->url_ == dictionary_url) {
272 it->callback_.Run(dictionary_text, dictionary_url, net_log, 272 it->callback_.Run(dictionary_text, dictionary_url, net_log,
273 was_from_cache); 273 was_from_cache);
274 requests_.erase(it); 274 requests_.erase(it);
275 return true; 275 return true;
276 } 276 }
277 } 277 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 // which leaves the test in control of signals to SdchOwner. 317 // which leaves the test in control of signals to SdchOwner.
318 url_request_context_.set_job_factory(&job_factory_); 318 url_request_context_.set_job_factory(&job_factory_);
319 319
320 // Reduce sizes to reduce time for string operations. 320 // Reduce sizes to reduce time for string operations.
321 sdch_owner_->SetMaxTotalDictionarySize(kMaxSizeForTesting); 321 sdch_owner_->SetMaxTotalDictionarySize(kMaxSizeForTesting);
322 sdch_owner_->SetMinSpaceForDictionaryFetch(kMinFetchSpaceForTesting); 322 sdch_owner_->SetMinSpaceForDictionaryFetch(kMinFetchSpaceForTesting);
323 } 323 }
324 324
325 SdchManager& sdch_manager() { return sdch_manager_; } 325 SdchManager& sdch_manager() { return sdch_manager_; }
326 SdchOwner& sdch_owner() { return *(sdch_owner_.get()); } 326 SdchOwner& sdch_owner() { return *(sdch_owner_.get()); }
327 BoundNetLog& bound_net_log() { return net_log_; } 327 NetLogWithSource& bound_net_log() { return net_log_; }
328 328
329 int JobsRecentlyCreated() { 329 int JobsRecentlyCreated() {
330 int result = error_jobs_created - last_jobs_created_; 330 int result = error_jobs_created - last_jobs_created_;
331 last_jobs_created_ = error_jobs_created; 331 last_jobs_created_ = error_jobs_created;
332 return result; 332 return result;
333 } 333 }
334 334
335 bool DictionaryPresentInManager(const std::string& server_hash) { 335 bool DictionaryPresentInManager(const std::string& server_hash) {
336 // Presumes all tests use generic url. 336 // Presumes all tests use generic url.
337 SdchProblemCode tmp; 337 SdchProblemCode tmp;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 return CreateAndAddDictionary(size, last_used_time, base::Time(), 390 return CreateAndAddDictionary(size, last_used_time, base::Time(),
391 server_hash_p); 391 server_hash_p);
392 } 392 }
393 393
394 void ResetOwner() { 394 void ResetOwner() {
395 sdch_owner_.reset(new SdchOwner(&sdch_manager_, &url_request_context_)); 395 sdch_owner_.reset(new SdchOwner(&sdch_manager_, &url_request_context_));
396 } 396 }
397 397
398 private: 398 private:
399 int last_jobs_created_; 399 int last_jobs_created_;
400 BoundNetLog net_log_; 400 NetLogWithSource net_log_;
401 int dictionary_creation_index_; 401 int dictionary_creation_index_;
402 402
403 // The dependencies of these objects (sdch_owner_ -> {sdch_manager_, 403 // The dependencies of these objects (sdch_owner_ -> {sdch_manager_,
404 // url_request_context_}, url_request_context_->job_factory_) require 404 // url_request_context_}, url_request_context_->job_factory_) require
405 // this order for correct destruction semantics. 405 // this order for correct destruction semantics.
406 MockURLRequestJobFactory job_factory_; 406 MockURLRequestJobFactory job_factory_;
407 URLRequestContext url_request_context_; 407 URLRequestContext url_request_context_;
408 SdchManager sdch_manager_; 408 SdchManager sdch_manager_;
409 std::unique_ptr<SdchOwner> sdch_owner_; 409 std::unique_ptr<SdchOwner> sdch_owner_;
410 410
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 std::string dict; 835 std::string dict;
836 dict.append("Domain: "); 836 dict.append("Domain: ");
837 dict.append(url.host()); 837 dict.append(url.host());
838 dict.append("\n\n"); 838 dict.append("\n\n");
839 dict.append(url.spec()); 839 dict.append(url.spec());
840 dict.append(nonce); 840 dict.append(nonce);
841 return dict; 841 return dict;
842 } 842 }
843 843
844 protected: 844 protected:
845 BoundNetLog net_log_; 845 NetLogWithSource net_log_;
846 std::unique_ptr<SdchManager> manager_; 846 std::unique_ptr<SdchManager> manager_;
847 MockSdchDictionaryFetcher* fetcher_; 847 MockSdchDictionaryFetcher* fetcher_;
848 std::unique_ptr<SdchOwner> owner_; 848 std::unique_ptr<SdchOwner> owner_;
849 TestURLRequestContext url_request_context_; 849 TestURLRequestContext url_request_context_;
850 }; 850 };
851 851
852 // Test an empty persistence store. 852 // Test an empty persistence store.
853 TEST_F(SdchOwnerPersistenceTest, Empty) { 853 TEST_F(SdchOwnerPersistenceTest, Empty) {
854 ResetOwner(base::WrapUnique(new TestPrefStorage(true))); 854 ResetOwner(base::WrapUnique(new TestPrefStorage(true)));
855 EXPECT_EQ(0, owner_->GetDictionaryCountForTesting()); 855 EXPECT_EQ(0, owner_->GetDictionaryCountForTesting());
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 1013
1014 EXPECT_TRUE(CompleteLoadFromURL(url0, "0", true)); 1014 EXPECT_TRUE(CompleteLoadFromURL(url0, "0", true));
1015 EXPECT_TRUE(CompleteLoadFromURL(url1, "1", false)); 1015 EXPECT_TRUE(CompleteLoadFromURL(url1, "1", false));
1016 1016
1017 tester.ExpectTotalCount("Sdch3.NetworkBytesSpent", 1); 1017 tester.ExpectTotalCount("Sdch3.NetworkBytesSpent", 1);
1018 tester.ExpectUniqueSample("Sdch3.NetworkBytesSpent", 1018 tester.ExpectUniqueSample("Sdch3.NetworkBytesSpent",
1019 CreateDictionary(url1, "1").size(), 1); 1019 CreateDictionary(url1, "1").size(), 1);
1020 } 1020 }
1021 1021
1022 } // namespace net 1022 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698