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

Side by Side Diff: components/precache/core/precache_fetcher_unittest.cc

Issue 2104363004: Remove remaining calls to deprecated MessageLoop methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR gab Created 4 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/precache/core/precache_fetcher.h" 5 #include "components/precache/core/precache_fetcher.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <cstring> 9 #include <cstring>
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
19 #include "base/memory/ptr_util.h" 19 #include "base/memory/ptr_util.h"
20 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
21 #include "base/memory/weak_ptr.h" 21 #include "base/memory/weak_ptr.h"
22 #include "base/run_loop.h" 22 #include "base/run_loop.h"
23 #include "base/single_thread_task_runner.h"
23 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
24 #include "base/test/histogram_tester.h" 25 #include "base/test/histogram_tester.h"
25 #include "base/threading/thread_task_runner_handle.h" 26 #include "base/threading/thread_task_runner_handle.h"
26 #include "components/precache/core/precache_switches.h" 27 #include "components/precache/core/precache_switches.h"
27 #include "components/precache/core/proto/precache.pb.h" 28 #include "components/precache/core/proto/precache.pb.h"
28 #include "components/precache/core/proto/unfinished_work.pb.h" 29 #include "components/precache/core/proto/unfinished_work.pb.h"
29 #include "net/base/load_flags.h" 30 #include "net/base/load_flags.h"
30 #include "net/http/http_response_headers.h" 31 #include "net/http/http_response_headers.h"
31 #include "net/http/http_status_code.h" 32 #include "net/http/http_status_code.h"
32 #include "net/url_request/test_url_fetcher_factory.h" 33 #include "net/url_request/test_url_fetcher_factory.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 void CheckUntilParallelFetchesBeyondCapacity( 355 void CheckUntilParallelFetchesBeyondCapacity(
355 const PrecacheFetcher* precache_fetcher) { 356 const PrecacheFetcher* precache_fetcher) {
356 if (!precache_fetcher->pool_.IsAvailable() && 357 if (!precache_fetcher->pool_.IsAvailable() &&
357 !precache_fetcher->resource_urls_to_fetch_.empty() && 358 !precache_fetcher->resource_urls_to_fetch_.empty() &&
358 !precache_fetcher->manifest_urls_to_fetch_.empty()) { 359 !precache_fetcher->manifest_urls_to_fetch_.empty()) {
359 parallel_fetches_beyond_capacity_ = true; 360 parallel_fetches_beyond_capacity_ = true;
360 return; 361 return;
361 } 362 }
362 363
363 // Check again after allowing the message loop to process some messages. 364 // Check again after allowing the message loop to process some messages.
364 loop_.PostTask( 365 loop_.task_runner()->PostTask(
365 FROM_HERE, 366 FROM_HERE,
366 base::Bind( 367 base::Bind(
367 &PrecacheFetcherTest::CheckUntilParallelFetchesBeyondCapacity, 368 &PrecacheFetcherTest::CheckUntilParallelFetchesBeyondCapacity,
368 base::Unretained(this), precache_fetcher)); 369 base::Unretained(this), precache_fetcher));
369 } 370 }
370 371
371 base::MessageLoopForUI loop_; 372 base::MessageLoopForUI loop_;
372 scoped_refptr<net::TestURLRequestContextGetter> request_context_; 373 scoped_refptr<net::TestURLRequestContextGetter> request_context_;
373 TestURLFetcherCallback url_callback_; 374 TestURLFetcherCallback url_callback_;
374 net::FakeURLFetcherFactory factory_; 375 net::FakeURLFetcherFactory factory_;
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 1145
1145 EXPECT_TRUE(precache_delegate_.was_on_done_called()); 1146 EXPECT_TRUE(precache_delegate_.was_on_done_called());
1146 1147
1147 // bad-manifest.com will have been completed. 1148 // bad-manifest.com will have been completed.
1148 EXPECT_THAT(histogram.GetAllSamples("Precache.Fetch.PercentCompleted"), 1149 EXPECT_THAT(histogram.GetAllSamples("Precache.Fetch.PercentCompleted"),
1149 ElementsAre(base::Bucket(100, 1))); 1150 ElementsAre(base::Bucket(100, 1)));
1150 histogram.ExpectTotalCount("Precache.Fetch.TimeToComplete", 1); 1151 histogram.ExpectTotalCount("Precache.Fetch.TimeToComplete", 1);
1151 } 1152 }
1152 1153
1153 } // namespace precache 1154 } // namespace precache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698