OLD | NEW |
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/browsing_data/browsing_data_remover.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 #if defined(ENABLE_SAFE_BROWSING) | 230 #if defined(ENABLE_SAFE_BROWSING) |
231 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { | 231 class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { |
232 public: | 232 public: |
233 RemoveSafeBrowsingCookieTester() | 233 RemoveSafeBrowsingCookieTester() |
234 : browser_process_( | 234 : browser_process_( |
235 static_cast<TestingBrowserProcess*>(g_browser_process)) { | 235 static_cast<TestingBrowserProcess*>(g_browser_process)) { |
236 scoped_refptr<SafeBrowsingService> sb_service = | 236 scoped_refptr<SafeBrowsingService> sb_service = |
237 SafeBrowsingService::CreateSafeBrowsingService(); | 237 SafeBrowsingService::CreateSafeBrowsingService(); |
238 browser_process_->SetSafeBrowsingService(sb_service); | 238 browser_process_->SetSafeBrowsingService(sb_service); |
239 sb_service->Initialize(); | 239 sb_service->Initialize(); |
240 MessageLoop::current()->RunAllPending(); | 240 MessageLoop::current()->RunUntilIdle(); |
241 | 241 |
242 // Create a cookiemonster that does not have persistant storage, and replace | 242 // Create a cookiemonster that does not have persistant storage, and replace |
243 // the SafeBrowsingService created one with it. | 243 // the SafeBrowsingService created one with it. |
244 net::CookieStore* monster = new net::CookieMonster(NULL, NULL); | 244 net::CookieStore* monster = new net::CookieMonster(NULL, NULL); |
245 sb_service->url_request_context()->GetURLRequestContext()-> | 245 sb_service->url_request_context()->GetURLRequestContext()-> |
246 set_cookie_store(monster); | 246 set_cookie_store(monster); |
247 SetMonster(monster); | 247 SetMonster(monster); |
248 } | 248 } |
249 | 249 |
250 virtual ~RemoveSafeBrowsingCookieTester() { | 250 virtual ~RemoveSafeBrowsingCookieTester() { |
251 browser_process_->safe_browsing_service()->ShutDown(); | 251 browser_process_->safe_browsing_service()->ShutDown(); |
252 MessageLoop::current()->RunAllPending(); | 252 MessageLoop::current()->RunUntilIdle(); |
253 browser_process_->SetSafeBrowsingService(NULL); | 253 browser_process_->SetSafeBrowsingService(NULL); |
254 } | 254 } |
255 | 255 |
256 private: | 256 private: |
257 TestingBrowserProcess* browser_process_; | 257 TestingBrowserProcess* browser_process_; |
258 | 258 |
259 DISALLOW_COPY_AND_ASSIGN(RemoveSafeBrowsingCookieTester); | 259 DISALLOW_COPY_AND_ASSIGN(RemoveSafeBrowsingCookieTester); |
260 }; | 260 }; |
261 #endif | 261 #endif |
262 | 262 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 virtual ~BrowsingDataRemoverTest() { | 491 virtual ~BrowsingDataRemoverTest() { |
492 } | 492 } |
493 | 493 |
494 void TearDown() { | 494 void TearDown() { |
495 // TestingProfile contains a DOMStorageContext. BrowserContext's destructor | 495 // TestingProfile contains a DOMStorageContext. BrowserContext's destructor |
496 // posts a message to the WEBKIT thread to delete some of its member | 496 // posts a message to the WEBKIT thread to delete some of its member |
497 // variables. We need to ensure that the profile is destroyed, and that | 497 // variables. We need to ensure that the profile is destroyed, and that |
498 // the message loop is cleared out, before destroying the threads and loop. | 498 // the message loop is cleared out, before destroying the threads and loop. |
499 // Otherwise we leak memory. | 499 // Otherwise we leak memory. |
500 profile_.reset(); | 500 profile_.reset(); |
501 message_loop_.RunAllPending(); | 501 message_loop_.RunUntilIdle(); |
502 } | 502 } |
503 | 503 |
504 void BlockUntilBrowsingDataRemoved(BrowsingDataRemover::TimePeriod period, | 504 void BlockUntilBrowsingDataRemoved(BrowsingDataRemover::TimePeriod period, |
505 int remove_mask, | 505 int remove_mask, |
506 bool include_protected_origins) { | 506 bool include_protected_origins) { |
507 BrowsingDataRemover* remover = BrowsingDataRemover::CreateForPeriod( | 507 BrowsingDataRemover* remover = BrowsingDataRemover::CreateForPeriod( |
508 profile_.get(), period); | 508 profile_.get(), period); |
509 remover->OverrideQuotaManagerForTesting(GetMockManager()); | 509 remover->OverrideQuotaManagerForTesting(GetMockManager()); |
510 | 510 |
511 AwaitCompletionHelper await_completion; | 511 AwaitCompletionHelper await_completion; |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 ASSERT_TRUE(tester.HasProfile()); | 1217 ASSERT_TRUE(tester.HasProfile()); |
1218 | 1218 |
1219 BlockUntilBrowsingDataRemoved( | 1219 BlockUntilBrowsingDataRemoved( |
1220 BrowsingDataRemover::EVERYTHING, | 1220 BrowsingDataRemover::EVERYTHING, |
1221 BrowsingDataRemover::REMOVE_FORM_DATA, false); | 1221 BrowsingDataRemover::REMOVE_FORM_DATA, false); |
1222 | 1222 |
1223 EXPECT_EQ(BrowsingDataRemover::REMOVE_FORM_DATA, GetRemovalMask()); | 1223 EXPECT_EQ(BrowsingDataRemover::REMOVE_FORM_DATA, GetRemovalMask()); |
1224 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); | 1224 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); |
1225 ASSERT_FALSE(tester.HasProfile()); | 1225 ASSERT_FALSE(tester.HasProfile()); |
1226 } | 1226 } |
OLD | NEW |