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

Side by Side Diff: chrome/browser/browsing_data/site_data_counting_helper_unittest.cc

Issue 2826783003: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/browsing_data (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « chrome/browser/browsing_data/site_data_counting_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 <algorithm> 5 #include <algorithm>
6 #include <memory> 6 #include <memory>
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 if (run_loop_) 50 if (run_loop_)
51 run_loop_->Quit(); 51 run_loop_->Quit();
52 } 52 }
53 53
54 void DoneOnIOThread(bool success) { 54 void DoneOnIOThread(bool success) {
55 DCHECK(success); 55 DCHECK(success);
56 if (--tasks_ > 0) 56 if (--tasks_ > 0)
57 return; 57 return;
58 BrowserThread::PostTask( 58 BrowserThread::PostTask(
59 BrowserThread::UI, FROM_HERE, 59 BrowserThread::UI, FROM_HERE,
60 base::Bind(&SiteDataCountingHelperTest::DoneCallback, 60 base::BindOnce(&SiteDataCountingHelperTest::DoneCallback,
61 base::Unretained(this))); 61 base::Unretained(this)));
62 } 62 }
63 63
64 void DoneCallback() { 64 void DoneCallback() {
65 DCHECK_CURRENTLY_ON(BrowserThread::UI); 65 DCHECK_CURRENTLY_ON(BrowserThread::UI);
66 if (run_loop_) 66 if (run_loop_)
67 run_loop_->Quit(); 67 run_loop_->Quit();
68 } 68 }
69 69
70 void WaitForTasksOnIOThread() { 70 void WaitForTasksOnIOThread() {
71 DCHECK_CURRENTLY_ON(BrowserThread::UI); 71 DCHECK_CURRENTLY_ON(BrowserThread::UI);
72 run_loop_.reset(new base::RunLoop()); 72 run_loop_.reset(new base::RunLoop());
73 run_loop_->Run(); 73 run_loop_->Run();
74 } 74 }
75 75
76 void CreateCookies(base::Time creation_time, 76 void CreateCookies(base::Time creation_time,
77 const std::vector<std::string>& urls) { 77 const std::vector<std::string>& urls) {
78 content::StoragePartition* partition = 78 content::StoragePartition* partition =
79 content::BrowserContext::GetDefaultStoragePartition(profile()); 79 content::BrowserContext::GetDefaultStoragePartition(profile());
80 net::URLRequestContextGetter* rq_context = 80 net::URLRequestContextGetter* rq_context =
81 partition->GetURLRequestContext(); 81 partition->GetURLRequestContext();
82 BrowserThread::PostTask( 82 BrowserThread::PostTask(
83 BrowserThread::IO, FROM_HERE, 83 BrowserThread::IO, FROM_HERE,
84 base::Bind(&SiteDataCountingHelperTest::CreateCookiesOnIOThread, 84 base::BindOnce(&SiteDataCountingHelperTest::CreateCookiesOnIOThread,
85 base::Unretained(this), make_scoped_refptr(rq_context), 85 base::Unretained(this), make_scoped_refptr(rq_context),
86 creation_time, urls)); 86 creation_time, urls));
87 } 87 }
88 88
89 void CreateLocalStorage( 89 void CreateLocalStorage(
90 base::Time creation_time, 90 base::Time creation_time,
91 const std::vector<base::FilePath::StringPieceType>& storage_origins) { 91 const std::vector<base::FilePath::StringPieceType>& storage_origins) {
92 // Note: This test depends on details of how the dom_storage library 92 // Note: This test depends on details of how the dom_storage library
93 // stores data in the host file system. 93 // stores data in the host file system.
94 base::FilePath storage_path = 94 base::FilePath storage_path =
95 profile()->GetPath().AppendASCII("Local Storage"); 95 profile()->GetPath().AppendASCII("Local Storage");
96 base::CreateDirectory(storage_path); 96 base::CreateDirectory(storage_path);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 CreateCookies(now, {"https://example.com", "https://google.com"}); 203 CreateCookies(now, {"https://example.com", "https://google.com"});
204 CreateLocalStorage(now, 204 CreateLocalStorage(now,
205 {FILE_PATH_LITERAL("https_example.com_443.localstorage"), 205 {FILE_PATH_LITERAL("https_example.com_443.localstorage"),
206 FILE_PATH_LITERAL("https_bing.com_443.localstorage")}); 206 FILE_PATH_LITERAL("https_bing.com_443.localstorage")});
207 WaitForTasksOnIOThread(); 207 WaitForTasksOnIOThread();
208 208
209 CountEntries(base::Time()); 209 CountEntries(base::Time());
210 WaitForTasksOnIOThread(); 210 WaitForTasksOnIOThread();
211 DCHECK_EQ(3, GetResult()); 211 DCHECK_EQ(3, GetResult());
212 } 212 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/site_data_counting_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698