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

Side by Side Diff: chrome/browser/history/in_memory_url_index_unittest.cc

Issue 352913002: Port HistoryService::ScheduleDBTask to CancelableTaskTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix lifetime of base::CancelableTaskTracker for HistoryModelWorker Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <fstream> 6 #include <fstream>
7 7
8 #include "base/auto_reset.h" 8 #include "base/auto_reset.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Validates that the given |term| is contained in |cache| and that it is 96 // Validates that the given |term| is contained in |cache| and that it is
97 // marked as in-use. 97 // marked as in-use.
98 void CheckTerm(const URLIndexPrivateData::SearchTermCacheMap& cache, 98 void CheckTerm(const URLIndexPrivateData::SearchTermCacheMap& cache,
99 base::string16 term) const; 99 base::string16 term) const;
100 100
101 // Pass-through function to simplify our friendship with HistoryService. 101 // Pass-through function to simplify our friendship with HistoryService.
102 sql::Connection& GetDB(); 102 sql::Connection& GetDB();
103 103
104 // Pass-through functions to simplify our friendship with InMemoryURLIndex. 104 // Pass-through functions to simplify our friendship with InMemoryURLIndex.
105 URLIndexPrivateData* GetPrivateData() const; 105 URLIndexPrivateData* GetPrivateData() const;
106 base::CancelableTaskTracker* GetPrivateDataTracker() const;
106 void ClearPrivateData(); 107 void ClearPrivateData();
107 void set_history_dir(const base::FilePath& dir_path); 108 void set_history_dir(const base::FilePath& dir_path);
108 bool GetCacheFilePath(base::FilePath* file_path) const; 109 bool GetCacheFilePath(base::FilePath* file_path) const;
109 void PostRestoreFromCacheFileTask(); 110 void PostRestoreFromCacheFileTask();
110 void PostSaveToCacheFileTask(); 111 void PostSaveToCacheFileTask();
111 void Observe(int notification_type, 112 void Observe(int notification_type,
112 const content::NotificationSource& source, 113 const content::NotificationSource& source,
113 const content::NotificationDetails& details); 114 const content::NotificationDetails& details);
114 const std::set<std::string>& scheme_whitelist(); 115 const std::set<std::string>& scheme_whitelist();
115 116
(...skipping 25 matching lines...) Expand all
141 142
142 sql::Connection& InMemoryURLIndexTest::GetDB() { 143 sql::Connection& InMemoryURLIndexTest::GetDB() {
143 return history_database_->GetDB(); 144 return history_database_->GetDB();
144 } 145 }
145 146
146 URLIndexPrivateData* InMemoryURLIndexTest::GetPrivateData() const { 147 URLIndexPrivateData* InMemoryURLIndexTest::GetPrivateData() const {
147 DCHECK(url_index_->private_data()); 148 DCHECK(url_index_->private_data());
148 return url_index_->private_data(); 149 return url_index_->private_data();
149 } 150 }
150 151
152 base::CancelableTaskTracker* InMemoryURLIndexTest::GetPrivateDataTracker()
153 const {
154 DCHECK(url_index_->private_data_tracker());
155 return url_index_->private_data_tracker();
156 }
157
151 void InMemoryURLIndexTest::ClearPrivateData() { 158 void InMemoryURLIndexTest::ClearPrivateData() {
152 return url_index_->ClearPrivateData(); 159 return url_index_->ClearPrivateData();
153 } 160 }
154 161
155 void InMemoryURLIndexTest::set_history_dir(const base::FilePath& dir_path) { 162 void InMemoryURLIndexTest::set_history_dir(const base::FilePath& dir_path) {
156 return url_index_->set_history_dir(dir_path); 163 return url_index_->set_history_dir(dir_path);
157 } 164 }
158 165
159 bool InMemoryURLIndexTest::GetCacheFilePath(base::FilePath* file_path) const { 166 bool InMemoryURLIndexTest::GetCacheFilePath(base::FilePath* file_path) const {
160 DCHECK(file_path); 167 DCHECK(file_path);
(...skipping 13 matching lines...) Expand all
174 const content::NotificationSource& source, 181 const content::NotificationSource& source,
175 const content::NotificationDetails& details) { 182 const content::NotificationDetails& details) {
176 url_index_->Observe(notification_type, source, details); 183 url_index_->Observe(notification_type, source, details);
177 } 184 }
178 185
179 const std::set<std::string>& InMemoryURLIndexTest::scheme_whitelist() { 186 const std::set<std::string>& InMemoryURLIndexTest::scheme_whitelist() {
180 return url_index_->scheme_whitelist(); 187 return url_index_->scheme_whitelist();
181 } 188 }
182 189
183 bool InMemoryURLIndexTest::UpdateURL(const URLRow& row) { 190 bool InMemoryURLIndexTest::UpdateURL(const URLRow& row) {
184 return GetPrivateData()->UpdateURL( 191 return GetPrivateData()->UpdateURL(history_service_,
185 history_service_, row, url_index_->languages_, 192 row,
186 url_index_->scheme_whitelist_); 193 url_index_->languages_,
194 url_index_->scheme_whitelist_,
195 GetPrivateDataTracker());
187 } 196 }
188 197
189 bool InMemoryURLIndexTest::DeleteURL(const GURL& url) { 198 bool InMemoryURLIndexTest::DeleteURL(const GURL& url) {
190 return GetPrivateData()->DeleteURL(url); 199 return GetPrivateData()->DeleteURL(url);
191 } 200 }
192 201
193 void InMemoryURLIndexTest::SetUp() { 202 void InMemoryURLIndexTest::SetUp() {
194 // We cannot access the database until the backend has been loaded. 203 // We cannot access the database until the backend has been loaded.
195 ASSERT_TRUE(profile_.CreateHistoryService(true, false)); 204 ASSERT_TRUE(profile_.CreateHistoryService(true, false));
196 profile_.CreateBookmarkModel(true); 205 profile_.CreateBookmarkModel(true);
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 full_file_path.GetComponents(&actual_parts); 1209 full_file_path.GetComponents(&actual_parts);
1201 ASSERT_EQ(expected_parts.size(), actual_parts.size()); 1210 ASSERT_EQ(expected_parts.size(), actual_parts.size());
1202 size_t count = expected_parts.size(); 1211 size_t count = expected_parts.size();
1203 for (size_t i = 0; i < count; ++i) 1212 for (size_t i = 0; i < count; ++i)
1204 EXPECT_EQ(expected_parts[i], actual_parts[i]); 1213 EXPECT_EQ(expected_parts[i], actual_parts[i]);
1205 // Must clear the history_dir_ to satisfy the dtor's DCHECK. 1214 // Must clear the history_dir_ to satisfy the dtor's DCHECK.
1206 set_history_dir(base::FilePath()); 1215 set_history_dir(base::FilePath());
1207 } 1216 }
1208 1217
1209 } // namespace history 1218 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/in_memory_url_index.cc ('k') | chrome/browser/history/top_sites_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698