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

Side by Side Diff: chrome/browser/safe_browsing/protocol_manager_unittest.cc

Issue 1870003002: Convert //chrome/browser/safe_browsing from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and address comments Created 4 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
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 "chrome/browser/safe_browsing/protocol_manager.h"
6
7 #include <memory>
5 #include <vector> 8 #include <vector>
6 9
7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
9 #include "base/test/test_simple_task_runner.h" 11 #include "base/test/test_simple_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 12 #include "base/thread_task_runner_handle.h"
11 #include "base/time/time.h" 13 #include "base/time/time.h"
12 #include "chrome/browser/safe_browsing/chunk.pb.h" 14 #include "chrome/browser/safe_browsing/chunk.pb.h"
13 #include "chrome/browser/safe_browsing/protocol_manager.h"
14 #include "components/safe_browsing_db/safebrowsing.pb.h" 15 #include "components/safe_browsing_db/safebrowsing.pb.h"
15 #include "components/safe_browsing_db/util.h" 16 #include "components/safe_browsing_db/util.h"
16 #include "google_apis/google_api_keys.h" 17 #include "google_apis/google_api_keys.h"
17 #include "net/base/escape.h" 18 #include "net/base/escape.h"
18 #include "net/base/load_flags.h" 19 #include "net/base/load_flags.h"
19 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
20 #include "net/url_request/test_url_fetcher_factory.h" 21 #include "net/url_request/test_url_fetcher_factory.h"
21 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gmock_mutant.h" 23 #include "testing/gmock_mutant.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 74
74 void SetUp() override { 75 void SetUp() override {
75 std::string key = google_apis::GetAPIKey(); 76 std::string key = google_apis::GetAPIKey();
76 if (!key.empty()) { 77 if (!key.empty()) {
77 key_param_ = base::StringPrintf( 78 key_param_ = base::StringPrintf(
78 "&key=%s", 79 "&key=%s",
79 net::EscapeQueryParamValue(key, true).c_str()); 80 net::EscapeQueryParamValue(key, true).c_str());
80 } 81 }
81 } 82 }
82 83
83 scoped_ptr<SafeBrowsingProtocolManager> CreateProtocolManager( 84 std::unique_ptr<SafeBrowsingProtocolManager> CreateProtocolManager(
84 SafeBrowsingProtocolManagerDelegate* delegate) { 85 SafeBrowsingProtocolManagerDelegate* delegate) {
85 SafeBrowsingProtocolConfig config; 86 SafeBrowsingProtocolConfig config;
86 config.client_name = kClient; 87 config.client_name = kClient;
87 config.url_prefix = kUrlPrefix; 88 config.url_prefix = kUrlPrefix;
88 config.backup_connect_error_url_prefix = kBackupConnectUrlPrefix; 89 config.backup_connect_error_url_prefix = kBackupConnectUrlPrefix;
89 config.backup_http_error_url_prefix = kBackupHttpUrlPrefix; 90 config.backup_http_error_url_prefix = kBackupHttpUrlPrefix;
90 config.backup_network_error_url_prefix = kBackupNetworkUrlPrefix; 91 config.backup_network_error_url_prefix = kBackupNetworkUrlPrefix;
91 config.version = kAppVer; 92 config.version = kAppVer;
92 return scoped_ptr<SafeBrowsingProtocolManager>( 93 return std::unique_ptr<SafeBrowsingProtocolManager>(
93 SafeBrowsingProtocolManager::Create(delegate, NULL, config)); 94 SafeBrowsingProtocolManager::Create(delegate, NULL, config));
94 } 95 }
95 96
96 void ValidateUpdateFetcherRequest(const net::TestURLFetcher* url_fetcher, 97 void ValidateUpdateFetcherRequest(const net::TestURLFetcher* url_fetcher,
97 const std::string& expected_prefix, 98 const std::string& expected_prefix,
98 const std::string& expected_suffix) { 99 const std::string& expected_suffix) {
99 ASSERT_TRUE(url_fetcher); 100 ASSERT_TRUE(url_fetcher);
100 EXPECT_EQ(net::LOAD_DISABLE_CACHE, url_fetcher->GetLoadFlags()); 101 EXPECT_EQ(net::LOAD_DISABLE_CACHE, url_fetcher->GetLoadFlags());
101 102
102 std::string expected_lists(base::StringPrintf("%s;\n%s;\n", 103 std::string expected_lists(base::StringPrintf("%s;\n%s;\n",
(...skipping 14 matching lines...) Expand all
117 const std::string& expected_url) { 118 const std::string& expected_url) {
118 ASSERT_TRUE(url_fetcher); 119 ASSERT_TRUE(url_fetcher);
119 EXPECT_EQ(net::LOAD_DISABLE_CACHE, url_fetcher->GetLoadFlags()); 120 EXPECT_EQ(net::LOAD_DISABLE_CACHE, url_fetcher->GetLoadFlags());
120 EXPECT_EQ("", url_fetcher->upload_data()); 121 EXPECT_EQ("", url_fetcher->upload_data());
121 EXPECT_EQ(GURL(expected_url), url_fetcher->GetOriginalURL()); 122 EXPECT_EQ(GURL(expected_url), url_fetcher->GetOriginalURL());
122 } 123 }
123 }; 124 };
124 125
125 // Ensure that we respect section 5 of the SafeBrowsing protocol specification. 126 // Ensure that we respect section 5 of the SafeBrowsing protocol specification.
126 TEST_F(SafeBrowsingProtocolManagerTest, TestBackOffTimes) { 127 TEST_F(SafeBrowsingProtocolManagerTest, TestBackOffTimes) {
127 scoped_ptr<SafeBrowsingProtocolManager> pm(CreateProtocolManager(NULL)); 128 std::unique_ptr<SafeBrowsingProtocolManager> pm(CreateProtocolManager(NULL));
128 129
129 pm->next_update_interval_ = TimeDelta::FromSeconds(1800); 130 pm->next_update_interval_ = TimeDelta::FromSeconds(1800);
130 ASSERT_TRUE(pm->back_off_fuzz_ >= 0.0 && pm->back_off_fuzz_ <= 1.0); 131 ASSERT_TRUE(pm->back_off_fuzz_ >= 0.0 && pm->back_off_fuzz_ <= 1.0);
131 132
132 TimeDelta next; 133 TimeDelta next;
133 134
134 // No errors received so far. 135 // No errors received so far.
135 next = pm->GetNextUpdateInterval(false); 136 next = pm->GetNextUpdateInterval(false);
136 EXPECT_EQ(next, TimeDelta::FromSeconds(1800)); 137 EXPECT_EQ(next, TimeDelta::FromSeconds(1800));
137 138
(...skipping 28 matching lines...) Expand all
166 // 7 errors. 167 // 7 errors.
167 next = pm->GetNextUpdateInterval(true); 168 next = pm->GetNextUpdateInterval(true);
168 EXPECT_EQ(next, TimeDelta::FromMinutes(480)); 169 EXPECT_EQ(next, TimeDelta::FromMinutes(480));
169 170
170 // Received a successful response. 171 // Received a successful response.
171 next = pm->GetNextUpdateInterval(false); 172 next = pm->GetNextUpdateInterval(false);
172 EXPECT_EQ(next, TimeDelta::FromSeconds(1800)); 173 EXPECT_EQ(next, TimeDelta::FromSeconds(1800));
173 } 174 }
174 175
175 TEST_F(SafeBrowsingProtocolManagerTest, TestChunkStrings) { 176 TEST_F(SafeBrowsingProtocolManagerTest, TestChunkStrings) {
176 scoped_ptr<SafeBrowsingProtocolManager> pm(CreateProtocolManager(NULL)); 177 std::unique_ptr<SafeBrowsingProtocolManager> pm(CreateProtocolManager(NULL));
177 178
178 // Add and Sub chunks. 179 // Add and Sub chunks.
179 SBListChunkRanges phish(kDefaultPhishList); 180 SBListChunkRanges phish(kDefaultPhishList);
180 phish.adds = "1,4,6,8-20,99"; 181 phish.adds = "1,4,6,8-20,99";
181 phish.subs = "16,32,64-96"; 182 phish.subs = "16,32,64-96";
182 EXPECT_EQ(base::StringPrintf("%s;a:1,4,6,8-20,99:s:16,32,64-96\n", 183 EXPECT_EQ(base::StringPrintf("%s;a:1,4,6,8-20,99:s:16,32,64-96\n",
183 kDefaultPhishList), 184 kDefaultPhishList),
184 FormatList(phish)); 185 FormatList(phish));
185 186
186 // Add chunks only. 187 // Add chunks only.
187 phish.subs = ""; 188 phish.subs = "";
188 EXPECT_EQ(base::StringPrintf("%s;a:1,4,6,8-20,99\n", kDefaultPhishList), 189 EXPECT_EQ(base::StringPrintf("%s;a:1,4,6,8-20,99\n", kDefaultPhishList),
189 FormatList(phish)); 190 FormatList(phish));
190 191
191 // Sub chunks only. 192 // Sub chunks only.
192 phish.adds = ""; 193 phish.adds = "";
193 phish.subs = "16,32,64-96"; 194 phish.subs = "16,32,64-96";
194 EXPECT_EQ(base::StringPrintf("%s;s:16,32,64-96\n", kDefaultPhishList), 195 EXPECT_EQ(base::StringPrintf("%s;s:16,32,64-96\n", kDefaultPhishList),
195 FormatList(phish)); 196 FormatList(phish));
196 197
197 // No chunks of either type. 198 // No chunks of either type.
198 phish.adds = ""; 199 phish.adds = "";
199 phish.subs = ""; 200 phish.subs = "";
200 EXPECT_EQ(base::StringPrintf("%s;\n", kDefaultPhishList), FormatList(phish)); 201 EXPECT_EQ(base::StringPrintf("%s;\n", kDefaultPhishList), FormatList(phish));
201 } 202 }
202 203
203 TEST_F(SafeBrowsingProtocolManagerTest, TestGetHashBackOffTimes) { 204 TEST_F(SafeBrowsingProtocolManagerTest, TestGetHashBackOffTimes) {
204 scoped_ptr<SafeBrowsingProtocolManager> pm(CreateProtocolManager(NULL)); 205 std::unique_ptr<SafeBrowsingProtocolManager> pm(CreateProtocolManager(NULL));
205 206
206 // No errors or back off time yet. 207 // No errors or back off time yet.
207 EXPECT_EQ(0U, pm->gethash_error_count_); 208 EXPECT_EQ(0U, pm->gethash_error_count_);
208 EXPECT_TRUE(pm->next_gethash_time_.is_null()); 209 EXPECT_TRUE(pm->next_gethash_time_.is_null());
209 210
210 Time now = Time::Now(); 211 Time now = Time::Now();
211 212
212 // 1 error. 213 // 1 error.
213 pm->HandleGetHashError(now); 214 pm->HandleGetHashError(now);
214 EXPECT_EQ(1U, pm->gethash_error_count_); 215 EXPECT_EQ(1U, pm->gethash_error_count_);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 EXPECT_EQ(6U, pm->gethash_error_count_); 247 EXPECT_EQ(6U, pm->gethash_error_count_);
247 EXPECT_TRUE(pm->next_gethash_time_ == now + TimeDelta::FromMinutes(480)); 248 EXPECT_TRUE(pm->next_gethash_time_ == now + TimeDelta::FromMinutes(480));
248 249
249 // 7 errors. 250 // 7 errors.
250 pm->HandleGetHashError(now); 251 pm->HandleGetHashError(now);
251 EXPECT_EQ(7U, pm->gethash_error_count_); 252 EXPECT_EQ(7U, pm->gethash_error_count_);
252 EXPECT_TRUE(pm->next_gethash_time_== now + TimeDelta::FromMinutes(480)); 253 EXPECT_TRUE(pm->next_gethash_time_== now + TimeDelta::FromMinutes(480));
253 } 254 }
254 255
255 TEST_F(SafeBrowsingProtocolManagerTest, TestGetHashUrl) { 256 TEST_F(SafeBrowsingProtocolManagerTest, TestGetHashUrl) {
256 scoped_ptr<SafeBrowsingProtocolManager> pm(CreateProtocolManager(NULL)); 257 std::unique_ptr<SafeBrowsingProtocolManager> pm(CreateProtocolManager(NULL));
257 258
258 EXPECT_EQ( 259 EXPECT_EQ(
259 "https://prefix.com/foo/gethash?client=unittest&appver=1.0&" 260 "https://prefix.com/foo/gethash?client=unittest&appver=1.0&"
260 "pver=3.0" + 261 "pver=3.0" +
261 key_param_ + "&ext=0", 262 key_param_ + "&ext=0",
262 pm->GetHashUrl(false).spec()); 263 pm->GetHashUrl(false).spec());
263 264
264 pm->set_additional_query(kAdditionalQuery); 265 pm->set_additional_query(kAdditionalQuery);
265 EXPECT_EQ( 266 EXPECT_EQ(
266 "https://prefix.com/foo/gethash?client=unittest&appver=1.0&" 267 "https://prefix.com/foo/gethash?client=unittest&appver=1.0&"
267 "pver=3.0" + 268 "pver=3.0" +
268 key_param_ + "&additional_query&ext=1", 269 key_param_ + "&additional_query&ext=1",
269 pm->GetHashUrl(true).spec()); 270 pm->GetHashUrl(true).spec());
270 } 271 }
271 272
272 TEST_F(SafeBrowsingProtocolManagerTest, TestUpdateUrl) { 273 TEST_F(SafeBrowsingProtocolManagerTest, TestUpdateUrl) {
273 scoped_ptr<SafeBrowsingProtocolManager> pm(CreateProtocolManager(NULL)); 274 std::unique_ptr<SafeBrowsingProtocolManager> pm(CreateProtocolManager(NULL));
274 275
275 EXPECT_EQ( 276 EXPECT_EQ(
276 "https://prefix.com/foo/downloads?client=unittest&appver=1.0&" 277 "https://prefix.com/foo/downloads?client=unittest&appver=1.0&"
277 "pver=3.0" + 278 "pver=3.0" +
278 key_param_ + "&ext=1", 279 key_param_ + "&ext=1",
279 pm->UpdateUrl(true).spec()); 280 pm->UpdateUrl(true).spec());
280 281
281 pm->set_additional_query(kAdditionalQuery); 282 pm->set_additional_query(kAdditionalQuery);
282 EXPECT_EQ( 283 EXPECT_EQ(
283 "https://prefix.com/foo/downloads?client=unittest&appver=1.0&" 284 "https://prefix.com/foo/downloads?client=unittest&appver=1.0&"
284 "pver=3.0" + 285 "pver=3.0" +
285 key_param_ + "&additional_query&ext=0", 286 key_param_ + "&additional_query&ext=0",
286 pm->UpdateUrl(false).spec()); 287 pm->UpdateUrl(false).spec());
287 } 288 }
288 289
289 TEST_F(SafeBrowsingProtocolManagerTest, TestNextChunkUrl) { 290 TEST_F(SafeBrowsingProtocolManagerTest, TestNextChunkUrl) {
290 scoped_ptr<SafeBrowsingProtocolManager> pm(CreateProtocolManager(NULL)); 291 std::unique_ptr<SafeBrowsingProtocolManager> pm(CreateProtocolManager(NULL));
291 292
292 std::string url_partial = "localhost:1234/foo/bar?foo"; 293 std::string url_partial = "localhost:1234/foo/bar?foo";
293 std::string url_http_full = "http://localhost:1234/foo/bar?foo"; 294 std::string url_http_full = "http://localhost:1234/foo/bar?foo";
294 std::string url_https_full = "https://localhost:1234/foo/bar?foo"; 295 std::string url_https_full = "https://localhost:1234/foo/bar?foo";
295 std::string url_https_no_query = "https://localhost:1234/foo/bar"; 296 std::string url_https_no_query = "https://localhost:1234/foo/bar";
296 297
297 EXPECT_EQ("https://localhost:1234/foo/bar?foo", 298 EXPECT_EQ("https://localhost:1234/foo/bar?foo",
298 pm->NextChunkUrl(url_partial).spec()); 299 pm->NextChunkUrl(url_partial).spec());
299 EXPECT_EQ("http://localhost:1234/foo/bar?foo", 300 EXPECT_EQ("http://localhost:1234/foo/bar?foo",
300 pm->NextChunkUrl(url_http_full).spec()); 301 pm->NextChunkUrl(url_http_full).spec());
(...skipping 18 matching lines...) Expand all
319 class MockProtocolDelegate : public SafeBrowsingProtocolManagerDelegate { 320 class MockProtocolDelegate : public SafeBrowsingProtocolManagerDelegate {
320 public: 321 public:
321 MockProtocolDelegate() {} 322 MockProtocolDelegate() {}
322 ~MockProtocolDelegate() override {} 323 ~MockProtocolDelegate() override {}
323 324
324 MOCK_METHOD0(UpdateStarted, void()); 325 MOCK_METHOD0(UpdateStarted, void());
325 MOCK_METHOD1(UpdateFinished, void(bool)); 326 MOCK_METHOD1(UpdateFinished, void(bool));
326 MOCK_METHOD0(ResetDatabase, void()); 327 MOCK_METHOD0(ResetDatabase, void());
327 MOCK_METHOD1(GetChunks, void(GetChunksCallback)); 328 MOCK_METHOD1(GetChunks, void(GetChunksCallback));
328 329
329 // gmock does not work with scoped_ptr<> at this time. Add a local method to 330 // gmock does not work with std::unique_ptr<> at this time. Add a local
331 // method to
330 // mock, then call that from an override. Beware of object ownership when 332 // mock, then call that from an override. Beware of object ownership when
331 // making changes here. 333 // making changes here.
332 MOCK_METHOD3(AddChunksRaw, 334 MOCK_METHOD3(AddChunksRaw,
333 void(const std::string& lists, 335 void(const std::string& lists,
334 const std::vector<scoped_ptr<SBChunkData>>& chunks, 336 const std::vector<std::unique_ptr<SBChunkData>>& chunks,
335 AddChunksCallback)); 337 AddChunksCallback));
336 void AddChunks(const std::string& list, 338 void AddChunks(
337 scoped_ptr<std::vector<scoped_ptr<SBChunkData>>> chunks, 339 const std::string& list,
338 AddChunksCallback callback) override { 340 std::unique_ptr<std::vector<std::unique_ptr<SBChunkData>>> chunks,
341 AddChunksCallback callback) override {
339 AddChunksRaw(list, *chunks, callback); 342 AddChunksRaw(list, *chunks, callback);
340 } 343 }
341 344
342 // TODO(shess): Actually test this case somewhere. 345 // TODO(shess): Actually test this case somewhere.
343 MOCK_METHOD1(DeleteChunksRaw, 346 MOCK_METHOD1(DeleteChunksRaw,
344 void(const std::vector<SBChunkDelete>& chunk_deletes)); 347 void(const std::vector<SBChunkDelete>& chunk_deletes));
345 void DeleteChunks( 348 void DeleteChunks(
346 scoped_ptr<std::vector<SBChunkDelete>> chunk_deletes) override { 349 std::unique_ptr<std::vector<SBChunkDelete>> chunk_deletes) override {
347 DeleteChunksRaw(*chunk_deletes); 350 DeleteChunksRaw(*chunk_deletes);
348 } 351 }
349 }; 352 };
350 353
351 // |InvokeGetChunksCallback| is required because GMock's InvokeArgument action 354 // |InvokeGetChunksCallback| is required because GMock's InvokeArgument action
352 // expects to use operator(), and a Callback only provides Run(). 355 // expects to use operator(), and a Callback only provides Run().
353 // TODO(cbentzel): Use ACTION or ACTION_TEMPLATE instead? 356 // TODO(cbentzel): Use ACTION or ACTION_TEMPLATE instead?
354 void InvokeGetChunksCallback( 357 void InvokeGetChunksCallback(
355 const std::vector<SBListChunkRanges>& ranges, 358 const std::vector<SBListChunkRanges>& ranges,
356 bool database_error, 359 bool database_error,
357 SafeBrowsingProtocolManagerDelegate::GetChunksCallback callback) { 360 SafeBrowsingProtocolManagerDelegate::GetChunksCallback callback) {
358 callback.Run(ranges, database_error, false); 361 callback.Run(ranges, database_error, false);
359 } 362 }
360 363
361 // |HandleAddChunks| deletes the chunks and asynchronously invokes 364 // |HandleAddChunks| deletes the chunks and asynchronously invokes
362 // |callback| since SafeBrowsingProtocolManager is not re-entrant at the time 365 // |callback| since SafeBrowsingProtocolManager is not re-entrant at the time
363 // this is called. This guarantee is part of the 366 // this is called. This guarantee is part of the
364 // SafeBrowsingProtocolManagerDelegate contract. 367 // SafeBrowsingProtocolManagerDelegate contract.
365 void HandleAddChunks( 368 void HandleAddChunks(
366 const std::string& unused_list, 369 const std::string& unused_list,
367 const std::vector<scoped_ptr<SBChunkData>>& chunks, 370 const std::vector<std::unique_ptr<SBChunkData>>& chunks,
368 SafeBrowsingProtocolManagerDelegate::AddChunksCallback callback) { 371 SafeBrowsingProtocolManagerDelegate::AddChunksCallback callback) {
369 scoped_refptr<base::SingleThreadTaskRunner> task_runner( 372 scoped_refptr<base::SingleThreadTaskRunner> task_runner(
370 base::ThreadTaskRunnerHandle::Get()); 373 base::ThreadTaskRunnerHandle::Get());
371 if (!task_runner.get()) 374 if (!task_runner.get())
372 return; 375 return;
373 task_runner->PostTask(FROM_HERE, callback); 376 task_runner->PostTask(FROM_HERE, callback);
374 } 377 }
375 378
376 } // namespace 379 } // namespace
377 380
378 // Tests that the Update protocol will be skipped if there are problems 381 // Tests that the Update protocol will be skipped if there are problems
379 // accessing the database. 382 // accessing the database.
380 TEST_F(SafeBrowsingProtocolManagerTest, ProblemAccessingDatabase) { 383 TEST_F(SafeBrowsingProtocolManagerTest, ProblemAccessingDatabase) {
381 scoped_refptr<base::TestSimpleTaskRunner> runner( 384 scoped_refptr<base::TestSimpleTaskRunner> runner(
382 new base::TestSimpleTaskRunner()); 385 new base::TestSimpleTaskRunner());
383 base::ThreadTaskRunnerHandle runner_handler(runner); 386 base::ThreadTaskRunnerHandle runner_handler(runner);
384 387
385 testing::StrictMock<MockProtocolDelegate> test_delegate; 388 testing::StrictMock<MockProtocolDelegate> test_delegate;
386 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 389 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
387 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 390 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
388 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 391 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
389 std::vector<SBListChunkRanges>(), 392 std::vector<SBListChunkRanges>(),
390 true))); 393 true)));
391 EXPECT_CALL(test_delegate, UpdateFinished(false)).Times(1); 394 EXPECT_CALL(test_delegate, UpdateFinished(false)).Times(1);
392 395
393 scoped_ptr<SafeBrowsingProtocolManager> pm( 396 std::unique_ptr<SafeBrowsingProtocolManager> pm(
394 CreateProtocolManager(&test_delegate)); 397 CreateProtocolManager(&test_delegate));
395 398
396 pm->ForceScheduleNextUpdate(TimeDelta()); 399 pm->ForceScheduleNextUpdate(TimeDelta());
397 runner->RunPendingTasks(); 400 runner->RunPendingTasks();
398 401
399 EXPECT_TRUE(pm->IsUpdateScheduled()); 402 EXPECT_TRUE(pm->IsUpdateScheduled());
400 } 403 }
401 404
402 // Tests the contents of the POST body when there are contents in the 405 // Tests the contents of the POST body when there are contents in the
403 // local database. This is not exhaustive, as the actual list formatting 406 // local database. This is not exhaustive, as the actual list formatting
(...skipping 16 matching lines...) Expand all
420 ranges.push_back(range_unknown); 423 ranges.push_back(range_unknown);
421 424
422 testing::StrictMock<MockProtocolDelegate> test_delegate; 425 testing::StrictMock<MockProtocolDelegate> test_delegate;
423 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 426 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
424 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 427 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
425 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 428 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
426 ranges, 429 ranges,
427 false))); 430 false)));
428 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1); 431 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1);
429 432
430 scoped_ptr<SafeBrowsingProtocolManager> pm( 433 std::unique_ptr<SafeBrowsingProtocolManager> pm(
431 CreateProtocolManager(&test_delegate)); 434 CreateProtocolManager(&test_delegate));
432 435
433 // Kick off initialization. This returns chunks from the DB synchronously. 436 // Kick off initialization. This returns chunks from the DB synchronously.
434 pm->ForceScheduleNextUpdate(TimeDelta()); 437 pm->ForceScheduleNextUpdate(TimeDelta());
435 runner->RunPendingTasks(); 438 runner->RunPendingTasks();
436 439
437 // We should have an URLFetcher at this point in time. 440 // We should have an URLFetcher at this point in time.
438 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 441 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
439 ASSERT_TRUE(url_fetcher); 442 ASSERT_TRUE(url_fetcher);
440 EXPECT_EQ(net::LOAD_DISABLE_CACHE, url_fetcher->GetLoadFlags()); 443 EXPECT_EQ(net::LOAD_DISABLE_CACHE, url_fetcher->GetLoadFlags());
(...skipping 22 matching lines...) Expand all
463 net::TestURLFetcherFactory url_fetcher_factory; 466 net::TestURLFetcherFactory url_fetcher_factory;
464 467
465 testing::StrictMock<MockProtocolDelegate> test_delegate; 468 testing::StrictMock<MockProtocolDelegate> test_delegate;
466 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 469 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
467 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 470 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
468 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 471 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
469 std::vector<SBListChunkRanges>(), 472 std::vector<SBListChunkRanges>(),
470 false))); 473 false)));
471 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1); 474 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1);
472 475
473 scoped_ptr<SafeBrowsingProtocolManager> pm( 476 std::unique_ptr<SafeBrowsingProtocolManager> pm(
474 CreateProtocolManager(&test_delegate)); 477 CreateProtocolManager(&test_delegate));
475 478
476 // Kick off initialization. This returns chunks from the DB synchronously. 479 // Kick off initialization. This returns chunks from the DB synchronously.
477 pm->ForceScheduleNextUpdate(TimeDelta()); 480 pm->ForceScheduleNextUpdate(TimeDelta());
478 runner->RunPendingTasks(); 481 runner->RunPendingTasks();
479 482
480 // We should have an URLFetcher at this point in time. 483 // We should have an URLFetcher at this point in time.
481 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 484 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
482 ValidateUpdateFetcherRequest(url_fetcher); 485 ValidateUpdateFetcherRequest(url_fetcher);
483 486
(...skipping 26 matching lines...) Expand all
510 net::TestURLFetcherFactory url_fetcher_factory; 513 net::TestURLFetcherFactory url_fetcher_factory;
511 514
512 testing::StrictMock<MockProtocolDelegate> test_delegate; 515 testing::StrictMock<MockProtocolDelegate> test_delegate;
513 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 516 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
514 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 517 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
515 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 518 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
516 std::vector<SBListChunkRanges>(), 519 std::vector<SBListChunkRanges>(),
517 false))); 520 false)));
518 EXPECT_CALL(test_delegate, UpdateFinished(false)).Times(1); 521 EXPECT_CALL(test_delegate, UpdateFinished(false)).Times(1);
519 522
520 scoped_ptr<SafeBrowsingProtocolManager> pm( 523 std::unique_ptr<SafeBrowsingProtocolManager> pm(
521 CreateProtocolManager(&test_delegate)); 524 CreateProtocolManager(&test_delegate));
522 525
523 // Kick off initialization. This returns chunks from the DB synchronously. 526 // Kick off initialization. This returns chunks from the DB synchronously.
524 pm->ForceScheduleNextUpdate(TimeDelta()); 527 pm->ForceScheduleNextUpdate(TimeDelta());
525 runner->RunPendingTasks(); 528 runner->RunPendingTasks();
526 529
527 // We should have an URLFetcher at this point in time. 530 // We should have an URLFetcher at this point in time.
528 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 531 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
529 ValidateUpdateFetcherRequest(url_fetcher); 532 ValidateUpdateFetcherRequest(url_fetcher);
530 533
(...skipping 26 matching lines...) Expand all
557 net::TestURLFetcherFactory url_fetcher_factory; 560 net::TestURLFetcherFactory url_fetcher_factory;
558 561
559 testing::StrictMock<MockProtocolDelegate> test_delegate; 562 testing::StrictMock<MockProtocolDelegate> test_delegate;
560 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 563 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
561 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 564 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
562 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 565 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
563 std::vector<SBListChunkRanges>(), 566 std::vector<SBListChunkRanges>(),
564 false))); 567 false)));
565 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1); 568 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1);
566 569
567 scoped_ptr<SafeBrowsingProtocolManager> pm( 570 std::unique_ptr<SafeBrowsingProtocolManager> pm(
568 CreateProtocolManager(&test_delegate)); 571 CreateProtocolManager(&test_delegate));
569 572
570 // Kick off initialization. This returns chunks from the DB synchronously. 573 // Kick off initialization. This returns chunks from the DB synchronously.
571 pm->ForceScheduleNextUpdate(TimeDelta()); 574 pm->ForceScheduleNextUpdate(TimeDelta());
572 runner->RunPendingTasks(); 575 runner->RunPendingTasks();
573 576
574 // We should have an URLFetcher at this point in time. 577 // We should have an URLFetcher at this point in time.
575 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 578 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
576 ValidateUpdateFetcherRequest(url_fetcher); 579 ValidateUpdateFetcherRequest(url_fetcher);
577 580
(...skipping 26 matching lines...) Expand all
604 net::TestURLFetcherFactory url_fetcher_factory; 607 net::TestURLFetcherFactory url_fetcher_factory;
605 608
606 testing::StrictMock<MockProtocolDelegate> test_delegate; 609 testing::StrictMock<MockProtocolDelegate> test_delegate;
607 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 610 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
608 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 611 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
609 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 612 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
610 std::vector<SBListChunkRanges>(), 613 std::vector<SBListChunkRanges>(),
611 false))); 614 false)));
612 EXPECT_CALL(test_delegate, UpdateFinished(false)).Times(1); 615 EXPECT_CALL(test_delegate, UpdateFinished(false)).Times(1);
613 616
614 scoped_ptr<SafeBrowsingProtocolManager> pm( 617 std::unique_ptr<SafeBrowsingProtocolManager> pm(
615 CreateProtocolManager(&test_delegate)); 618 CreateProtocolManager(&test_delegate));
616 619
617 // Kick off initialization. This returns chunks from the DB synchronously. 620 // Kick off initialization. This returns chunks from the DB synchronously.
618 pm->ForceScheduleNextUpdate(TimeDelta()); 621 pm->ForceScheduleNextUpdate(TimeDelta());
619 runner->RunPendingTasks(); 622 runner->RunPendingTasks();
620 623
621 // We should have an URLFetcher at this point in time. 624 // We should have an URLFetcher at this point in time.
622 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 625 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
623 ValidateUpdateFetcherRequest(url_fetcher); 626 ValidateUpdateFetcherRequest(url_fetcher);
624 627
(...skipping 30 matching lines...) Expand all
655 net::TestURLFetcherFactory url_fetcher_factory; 658 net::TestURLFetcherFactory url_fetcher_factory;
656 659
657 testing::StrictMock<MockProtocolDelegate> test_delegate; 660 testing::StrictMock<MockProtocolDelegate> test_delegate;
658 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 661 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
659 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 662 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
660 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 663 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
661 std::vector<SBListChunkRanges>(), 664 std::vector<SBListChunkRanges>(),
662 false))); 665 false)));
663 EXPECT_CALL(test_delegate, UpdateFinished(false)).Times(1); 666 EXPECT_CALL(test_delegate, UpdateFinished(false)).Times(1);
664 667
665 scoped_ptr<SafeBrowsingProtocolManager> pm( 668 std::unique_ptr<SafeBrowsingProtocolManager> pm(
666 CreateProtocolManager(&test_delegate)); 669 CreateProtocolManager(&test_delegate));
667 670
668 // Kick off initialization. This returns chunks from the DB synchronously. 671 // Kick off initialization. This returns chunks from the DB synchronously.
669 pm->ForceScheduleNextUpdate(TimeDelta()); 672 pm->ForceScheduleNextUpdate(TimeDelta());
670 runner->RunPendingTasks(); 673 runner->RunPendingTasks();
671 674
672 // We should have an URLFetcher at this point in time. 675 // We should have an URLFetcher at this point in time.
673 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 676 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
674 ValidateUpdateFetcherRequest(url_fetcher); 677 ValidateUpdateFetcherRequest(url_fetcher);
675 678
(...skipping 26 matching lines...) Expand all
702 net::TestURLFetcherFactory url_fetcher_factory; 705 net::TestURLFetcherFactory url_fetcher_factory;
703 706
704 testing::StrictMock<MockProtocolDelegate> test_delegate; 707 testing::StrictMock<MockProtocolDelegate> test_delegate;
705 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 708 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
706 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 709 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
707 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 710 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
708 std::vector<SBListChunkRanges>(), 711 std::vector<SBListChunkRanges>(),
709 false))); 712 false)));
710 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1); 713 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1);
711 714
712 scoped_ptr<SafeBrowsingProtocolManager> pm( 715 std::unique_ptr<SafeBrowsingProtocolManager> pm(
713 CreateProtocolManager(&test_delegate)); 716 CreateProtocolManager(&test_delegate));
714 717
715 // Kick off initialization. This returns chunks from the DB synchronously. 718 // Kick off initialization. This returns chunks from the DB synchronously.
716 pm->ForceScheduleNextUpdate(TimeDelta()); 719 pm->ForceScheduleNextUpdate(TimeDelta());
717 runner->RunPendingTasks(); 720 runner->RunPendingTasks();
718 721
719 // We should have an URLFetcher at this point in time. 722 // We should have an URLFetcher at this point in time.
720 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 723 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
721 ValidateUpdateFetcherRequest(url_fetcher); 724 ValidateUpdateFetcherRequest(url_fetcher);
722 725
(...skipping 25 matching lines...) Expand all
748 net::TestURLFetcherFactory url_fetcher_factory; 751 net::TestURLFetcherFactory url_fetcher_factory;
749 752
750 testing::StrictMock<MockProtocolDelegate> test_delegate; 753 testing::StrictMock<MockProtocolDelegate> test_delegate;
751 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 754 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
752 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 755 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
753 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 756 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
754 std::vector<SBListChunkRanges>(), 757 std::vector<SBListChunkRanges>(),
755 false))); 758 false)));
756 EXPECT_CALL(test_delegate, UpdateFinished(false)).Times(1); 759 EXPECT_CALL(test_delegate, UpdateFinished(false)).Times(1);
757 760
758 scoped_ptr<SafeBrowsingProtocolManager> pm( 761 std::unique_ptr<SafeBrowsingProtocolManager> pm(
759 CreateProtocolManager(&test_delegate)); 762 CreateProtocolManager(&test_delegate));
760 763
761 // Kick off initialization. This returns chunks from the DB synchronously. 764 // Kick off initialization. This returns chunks from the DB synchronously.
762 pm->ForceScheduleNextUpdate(TimeDelta()); 765 pm->ForceScheduleNextUpdate(TimeDelta());
763 runner->RunPendingTasks(); 766 runner->RunPendingTasks();
764 767
765 // We should have an URLFetcher at this point in time. 768 // We should have an URLFetcher at this point in time.
766 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 769 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
767 ValidateUpdateFetcherRequest(url_fetcher); 770 ValidateUpdateFetcherRequest(url_fetcher);
768 771
(...skipping 27 matching lines...) Expand all
796 net::TestURLFetcherFactory url_fetcher_factory; 799 net::TestURLFetcherFactory url_fetcher_factory;
797 800
798 testing::StrictMock<MockProtocolDelegate> test_delegate; 801 testing::StrictMock<MockProtocolDelegate> test_delegate;
799 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 802 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
800 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 803 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
801 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 804 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
802 std::vector<SBListChunkRanges>(), 805 std::vector<SBListChunkRanges>(),
803 false))); 806 false)));
804 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1); 807 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1);
805 808
806 scoped_ptr<SafeBrowsingProtocolManager> pm( 809 std::unique_ptr<SafeBrowsingProtocolManager> pm(
807 CreateProtocolManager(&test_delegate)); 810 CreateProtocolManager(&test_delegate));
808 811
809 // Kick off initialization. This returns chunks from the DB synchronously. 812 // Kick off initialization. This returns chunks from the DB synchronously.
810 pm->ForceScheduleNextUpdate(TimeDelta()); 813 pm->ForceScheduleNextUpdate(TimeDelta());
811 runner->RunPendingTasks(); 814 runner->RunPendingTasks();
812 815
813 // We should have an URLFetcher at this point in time. 816 // We should have an URLFetcher at this point in time.
814 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 817 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
815 ValidateUpdateFetcherRequest(url_fetcher); 818 ValidateUpdateFetcherRequest(url_fetcher);
816 819
(...skipping 25 matching lines...) Expand all
842 net::TestURLFetcherFactory url_fetcher_factory; 845 net::TestURLFetcherFactory url_fetcher_factory;
843 846
844 testing::StrictMock<MockProtocolDelegate> test_delegate; 847 testing::StrictMock<MockProtocolDelegate> test_delegate;
845 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 848 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
846 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 849 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
847 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 850 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
848 std::vector<SBListChunkRanges>(), 851 std::vector<SBListChunkRanges>(),
849 false))); 852 false)));
850 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1); 853 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1);
851 854
852 scoped_ptr<SafeBrowsingProtocolManager> pm( 855 std::unique_ptr<SafeBrowsingProtocolManager> pm(
853 CreateProtocolManager(&test_delegate)); 856 CreateProtocolManager(&test_delegate));
854 857
855 // Kick off initialization. This returns chunks from the DB synchronously. 858 // Kick off initialization. This returns chunks from the DB synchronously.
856 pm->ForceScheduleNextUpdate(TimeDelta()); 859 pm->ForceScheduleNextUpdate(TimeDelta());
857 runner->RunPendingTasks(); 860 runner->RunPendingTasks();
858 861
859 // We should have an URLFetcher at this point in time. 862 // We should have an URLFetcher at this point in time.
860 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 863 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
861 ValidateUpdateFetcherRequest(url_fetcher); 864 ValidateUpdateFetcherRequest(url_fetcher);
862 865
(...skipping 24 matching lines...) Expand all
887 890
888 testing::StrictMock<MockProtocolDelegate> test_delegate; 891 testing::StrictMock<MockProtocolDelegate> test_delegate;
889 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 892 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
890 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 893 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
891 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 894 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
892 std::vector<SBListChunkRanges>(), 895 std::vector<SBListChunkRanges>(),
893 false))); 896 false)));
894 EXPECT_CALL(test_delegate, ResetDatabase()).Times(1); 897 EXPECT_CALL(test_delegate, ResetDatabase()).Times(1);
895 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1); 898 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1);
896 899
897 scoped_ptr<SafeBrowsingProtocolManager> pm( 900 std::unique_ptr<SafeBrowsingProtocolManager> pm(
898 CreateProtocolManager(&test_delegate)); 901 CreateProtocolManager(&test_delegate));
899 902
900 // Kick off initialization. This returns chunks from the DB synchronously. 903 // Kick off initialization. This returns chunks from the DB synchronously.
901 pm->ForceScheduleNextUpdate(TimeDelta()); 904 pm->ForceScheduleNextUpdate(TimeDelta());
902 runner->RunPendingTasks(); 905 runner->RunPendingTasks();
903 906
904 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 907 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
905 ValidateUpdateFetcherRequest(url_fetcher); 908 ValidateUpdateFetcherRequest(url_fetcher);
906 909
907 // The update response is successful, and has a reset command. 910 // The update response is successful, and has a reset command.
(...skipping 14 matching lines...) Expand all
922 net::TestURLFetcherFactory url_fetcher_factory; 925 net::TestURLFetcherFactory url_fetcher_factory;
923 926
924 testing::StrictMock<MockProtocolDelegate> test_delegate; 927 testing::StrictMock<MockProtocolDelegate> test_delegate;
925 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 928 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
926 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 929 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
927 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 930 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
928 std::vector<SBListChunkRanges>(), 931 std::vector<SBListChunkRanges>(),
929 false))); 932 false)));
930 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1); 933 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1);
931 934
932 scoped_ptr<SafeBrowsingProtocolManager> pm( 935 std::unique_ptr<SafeBrowsingProtocolManager> pm(
933 CreateProtocolManager(&test_delegate)); 936 CreateProtocolManager(&test_delegate));
934 937
935 // Kick off initialization. This returns chunks from the DB synchronously. 938 // Kick off initialization. This returns chunks from the DB synchronously.
936 pm->ForceScheduleNextUpdate(TimeDelta()); 939 pm->ForceScheduleNextUpdate(TimeDelta());
937 runner->RunPendingTasks(); 940 runner->RunPendingTasks();
938 941
939 // The update response contains a single redirect command. 942 // The update response contains a single redirect command.
940 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 943 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
941 ValidateUpdateFetcherRequest(url_fetcher); 944 ValidateUpdateFetcherRequest(url_fetcher);
942 url_fetcher->set_status(net::URLRequestStatus()); 945 url_fetcher->set_status(net::URLRequestStatus());
(...skipping 26 matching lines...) Expand all
969 net::TestURLFetcherFactory url_fetcher_factory; 972 net::TestURLFetcherFactory url_fetcher_factory;
970 973
971 testing::StrictMock<MockProtocolDelegate> test_delegate; 974 testing::StrictMock<MockProtocolDelegate> test_delegate;
972 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 975 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
973 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 976 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
974 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 977 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
975 std::vector<SBListChunkRanges>(), 978 std::vector<SBListChunkRanges>(),
976 false))); 979 false)));
977 EXPECT_CALL(test_delegate, UpdateFinished(false)).Times(1); 980 EXPECT_CALL(test_delegate, UpdateFinished(false)).Times(1);
978 981
979 scoped_ptr<SafeBrowsingProtocolManager> pm( 982 std::unique_ptr<SafeBrowsingProtocolManager> pm(
980 CreateProtocolManager(&test_delegate)); 983 CreateProtocolManager(&test_delegate));
981 984
982 // Kick off initialization. This returns chunks from the DB synchronously. 985 // Kick off initialization. This returns chunks from the DB synchronously.
983 pm->ForceScheduleNextUpdate(TimeDelta()); 986 pm->ForceScheduleNextUpdate(TimeDelta());
984 runner->RunPendingTasks(); 987 runner->RunPendingTasks();
985 988
986 // The update response contains a single redirect command. 989 // The update response contains a single redirect command.
987 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 990 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
988 ValidateUpdateFetcherRequest(url_fetcher); 991 ValidateUpdateFetcherRequest(url_fetcher);
989 url_fetcher->set_status(net::URLRequestStatus()); 992 url_fetcher->set_status(net::URLRequestStatus());
(...skipping 28 matching lines...) Expand all
1018 testing::StrictMock<MockProtocolDelegate> test_delegate; 1021 testing::StrictMock<MockProtocolDelegate> test_delegate;
1019 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 1022 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
1020 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 1023 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
1021 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 1024 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
1022 std::vector<SBListChunkRanges>(), 1025 std::vector<SBListChunkRanges>(),
1023 false))); 1026 false)));
1024 EXPECT_CALL(test_delegate, AddChunksRaw(kDefaultPhishList, _, _)).WillOnce( 1027 EXPECT_CALL(test_delegate, AddChunksRaw(kDefaultPhishList, _, _)).WillOnce(
1025 Invoke(HandleAddChunks)); 1028 Invoke(HandleAddChunks));
1026 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1); 1029 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1);
1027 1030
1028 scoped_ptr<SafeBrowsingProtocolManager> pm( 1031 std::unique_ptr<SafeBrowsingProtocolManager> pm(
1029 CreateProtocolManager(&test_delegate)); 1032 CreateProtocolManager(&test_delegate));
1030 1033
1031 // Kick off initialization. This returns chunks from the DB synchronously. 1034 // Kick off initialization. This returns chunks from the DB synchronously.
1032 pm->ForceScheduleNextUpdate(TimeDelta()); 1035 pm->ForceScheduleNextUpdate(TimeDelta());
1033 runner->RunPendingTasks(); 1036 runner->RunPendingTasks();
1034 1037
1035 // The update response contains a single redirect command. 1038 // The update response contains a single redirect command.
1036 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 1039 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
1037 ValidateUpdateFetcherRequest(url_fetcher); 1040 ValidateUpdateFetcherRequest(url_fetcher);
1038 url_fetcher->set_status(net::URLRequestStatus()); 1041 url_fetcher->set_status(net::URLRequestStatus());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 testing::StrictMock<MockProtocolDelegate> test_delegate; 1075 testing::StrictMock<MockProtocolDelegate> test_delegate;
1073 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1); 1076 EXPECT_CALL(test_delegate, UpdateStarted()).Times(1);
1074 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce( 1077 EXPECT_CALL(test_delegate, GetChunks(_)).WillOnce(
1075 Invoke(testing::CreateFunctor(InvokeGetChunksCallback, 1078 Invoke(testing::CreateFunctor(InvokeGetChunksCallback,
1076 std::vector<SBListChunkRanges>(), 1079 std::vector<SBListChunkRanges>(),
1077 false))); 1080 false)));
1078 EXPECT_CALL(test_delegate, AddChunksRaw(kDefaultPhishList, _, _)). 1081 EXPECT_CALL(test_delegate, AddChunksRaw(kDefaultPhishList, _, _)).
1079 WillRepeatedly(Invoke(HandleAddChunks)); 1082 WillRepeatedly(Invoke(HandleAddChunks));
1080 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1); 1083 EXPECT_CALL(test_delegate, UpdateFinished(true)).Times(1);
1081 1084
1082 scoped_ptr<SafeBrowsingProtocolManager> pm( 1085 std::unique_ptr<SafeBrowsingProtocolManager> pm(
1083 CreateProtocolManager(&test_delegate)); 1086 CreateProtocolManager(&test_delegate));
1084 1087
1085 // Kick off initialization. This returns chunks from the DB synchronously. 1088 // Kick off initialization. This returns chunks from the DB synchronously.
1086 pm->ForceScheduleNextUpdate(TimeDelta()); 1089 pm->ForceScheduleNextUpdate(TimeDelta());
1087 runner->RunPendingTasks(); 1090 runner->RunPendingTasks();
1088 1091
1089 // The update response contains multiple redirect commands. 1092 // The update response contains multiple redirect commands.
1090 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0); 1093 net::TestURLFetcher* url_fetcher = url_fetcher_factory.GetFetcherByID(0);
1091 ValidateUpdateFetcherRequest(url_fetcher); 1094 ValidateUpdateFetcherRequest(url_fetcher);
1092 url_fetcher->set_status(net::URLRequestStatus()); 1095 url_fetcher->set_status(net::URLRequestStatus());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 1130
1128 EXPECT_FALSE(pm->IsUpdateScheduled()); 1131 EXPECT_FALSE(pm->IsUpdateScheduled());
1129 1132
1130 // Invoke the AddChunksCallback to finish the update. 1133 // Invoke the AddChunksCallback to finish the update.
1131 runner->RunPendingTasks(); 1134 runner->RunPendingTasks();
1132 1135
1133 EXPECT_TRUE(pm->IsUpdateScheduled()); 1136 EXPECT_TRUE(pm->IsUpdateScheduled());
1134 } 1137 }
1135 1138
1136 } // namespace safe_browsing 1139 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/protocol_manager_helper.h ('k') | chrome/browser/safe_browsing/protocol_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698