| 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 "components/search_provider_logos/logo_tracker.h" | 5 #include "components/search_provider_logos/logo_tracker.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/base64.h" | 12 #include "base/base64.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
| 17 #include "base/location.h" | |
| 18 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 19 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 20 #include "base/memory/scoped_vector.h" | 19 #include "base/memory/scoped_vector.h" |
| 21 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 22 #include "base/single_thread_task_runner.h" | |
| 23 #include "base/strings/string_piece.h" | 21 #include "base/strings/string_piece.h" |
| 24 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
| 25 #include "base/test/simple_test_clock.h" | 23 #include "base/test/simple_test_clock.h" |
| 26 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
| 27 #include "base/time/time.h" | 25 #include "base/time/time.h" |
| 28 #include "base/values.h" | 26 #include "base/values.h" |
| 29 #include "components/search_provider_logos/google_logo_api.h" | 27 #include "components/search_provider_logos/google_logo_api.h" |
| 30 #include "net/base/url_util.h" | 28 #include "net/base/url_util.h" |
| 31 #include "net/http/http_response_headers.h" | 29 #include "net/http/http_response_headers.h" |
| 32 #include "net/http/http_status_code.h" | 30 #include "net/http/http_status_code.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 logo_tracker_->SetClockForTests(std::unique_ptr<base::Clock>(test_clock_)); | 332 logo_tracker_->SetClockForTests(std::unique_ptr<base::Clock>(test_clock_)); |
| 335 logo_tracker_->SetLogoCacheForTests( | 333 logo_tracker_->SetLogoCacheForTests( |
| 336 std::unique_ptr<LogoCache>(logo_cache_)); | 334 std::unique_ptr<LogoCache>(logo_cache_)); |
| 337 } | 335 } |
| 338 | 336 |
| 339 virtual void TearDown() { | 337 virtual void TearDown() { |
| 340 // logo_tracker_ owns logo_cache_, which gets destructed on the file thread | 338 // logo_tracker_ owns logo_cache_, which gets destructed on the file thread |
| 341 // after logo_tracker_'s destruction. Ensure that logo_cache_ is actually | 339 // after logo_tracker_'s destruction. Ensure that logo_cache_ is actually |
| 342 // destructed before the test ends to make gmock happy. | 340 // destructed before the test ends to make gmock happy. |
| 343 delete logo_tracker_; | 341 delete logo_tracker_; |
| 344 message_loop_->RunUntilIdle(); | 342 base::RunLoop().RunUntilIdle(); |
| 345 } | 343 } |
| 346 | 344 |
| 347 // Returns the response that the server would send for the given logo. | 345 // Returns the response that the server would send for the given logo. |
| 348 std::string ServerResponse(const Logo& logo) const; | 346 std::string ServerResponse(const Logo& logo) const; |
| 349 | 347 |
| 350 // Sets the response to be returned when the LogoTracker fetches the logo. | 348 // Sets the response to be returned when the LogoTracker fetches the logo. |
| 351 void SetServerResponse(const std::string& response, | 349 void SetServerResponse(const std::string& response, |
| 352 net::URLRequestStatus::Status request_status = | 350 net::URLRequestStatus::Status request_status = |
| 353 net::URLRequestStatus::SUCCESS, | 351 net::URLRequestStatus::SUCCESS, |
| 354 net::HttpStatusCode response_code = net::HTTP_OK); | 352 net::HttpStatusCode response_code = net::HTTP_OK); |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 MockLogoObserver listener2; | 752 MockLogoObserver listener2; |
| 755 listener2.ExpectFreshLogo(&logo); | 753 listener2.ExpectFreshLogo(&logo); |
| 756 logo_tracker_->GetLogo(&listener2); | 754 logo_tracker_->GetLogo(&listener2); |
| 757 | 755 |
| 758 base::RunLoop().RunUntilIdle(); | 756 base::RunLoop().RunUntilIdle(); |
| 759 } | 757 } |
| 760 | 758 |
| 761 } // namespace | 759 } // namespace |
| 762 | 760 |
| 763 } // namespace search_provider_logos | 761 } // namespace search_provider_logos |
| OLD | NEW |