| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 MessageLoop::current()->Quit(); | 142 MessageLoop::current()->Quit(); |
| 143 start_ = false; | 143 start_ = false; |
| 144 } else { | 144 } else { |
| 145 DCHECK(!already_quit_); | 145 DCHECK(!already_quit_); |
| 146 already_quit_ = true; | 146 already_quit_ = true; |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 protected: | 150 protected: |
| 151 // BrowsingDataRemover::Observer implementation. | 151 // BrowsingDataRemover::Observer implementation. |
| 152 virtual void OnBrowsingDataRemoverDone() { | 152 virtual void OnBrowsingDataRemoverDone() OVERRIDE { |
| 153 Notify(); | 153 Notify(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 private: | 156 private: |
| 157 // Helps prevent from running message_loop, if the callback invoked | 157 // Helps prevent from running message_loop, if the callback invoked |
| 158 // immediately. | 158 // immediately. |
| 159 bool start_; | 159 bool start_; |
| 160 bool already_quit_; | 160 bool already_quit_; |
| 161 | 161 |
| 162 DISALLOW_COPY_AND_ASSIGN(AwaitCompletionHelper); | 162 DISALLOW_COPY_AND_ASSIGN(AwaitCompletionHelper); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 BrowserThread::FILE_USER_BLOCKING, &message_loop_), | 508 BrowserThread::FILE_USER_BLOCKING, &message_loop_), |
| 509 io_thread_(BrowserThread::IO, &message_loop_), | 509 io_thread_(BrowserThread::IO, &message_loop_), |
| 510 profile_(new TestingProfile()) { | 510 profile_(new TestingProfile()) { |
| 511 registrar_.Add(this, chrome::NOTIFICATION_BROWSING_DATA_REMOVED, | 511 registrar_.Add(this, chrome::NOTIFICATION_BROWSING_DATA_REMOVED, |
| 512 content::Source<Profile>(profile_.get())); | 512 content::Source<Profile>(profile_.get())); |
| 513 } | 513 } |
| 514 | 514 |
| 515 virtual ~BrowsingDataRemoverTest() { | 515 virtual ~BrowsingDataRemoverTest() { |
| 516 } | 516 } |
| 517 | 517 |
| 518 void TearDown() { | 518 virtual void TearDown() { |
| 519 // TestingProfile contains a DOMStorageContext. BrowserContext's destructor | 519 // TestingProfile contains a DOMStorageContext. BrowserContext's destructor |
| 520 // posts a message to the WEBKIT thread to delete some of its member | 520 // posts a message to the WEBKIT thread to delete some of its member |
| 521 // variables. We need to ensure that the profile is destroyed, and that | 521 // variables. We need to ensure that the profile is destroyed, and that |
| 522 // the message loop is cleared out, before destroying the threads and loop. | 522 // the message loop is cleared out, before destroying the threads and loop. |
| 523 // Otherwise we leak memory. | 523 // Otherwise we leak memory. |
| 524 profile_.reset(); | 524 profile_.reset(); |
| 525 message_loop_.RunUntilIdle(); | 525 message_loop_.RunUntilIdle(); |
| 526 } | 526 } |
| 527 | 527 |
| 528 void BlockUntilBrowsingDataRemoved(BrowsingDataRemover::TimePeriod period, | 528 void BlockUntilBrowsingDataRemoved(BrowsingDataRemover::TimePeriod period, |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 ASSERT_TRUE(tester.HasProfile()); | 1246 ASSERT_TRUE(tester.HasProfile()); |
| 1247 | 1247 |
| 1248 BlockUntilBrowsingDataRemoved( | 1248 BlockUntilBrowsingDataRemoved( |
| 1249 BrowsingDataRemover::EVERYTHING, | 1249 BrowsingDataRemover::EVERYTHING, |
| 1250 BrowsingDataRemover::REMOVE_FORM_DATA, false); | 1250 BrowsingDataRemover::REMOVE_FORM_DATA, false); |
| 1251 | 1251 |
| 1252 EXPECT_EQ(BrowsingDataRemover::REMOVE_FORM_DATA, GetRemovalMask()); | 1252 EXPECT_EQ(BrowsingDataRemover::REMOVE_FORM_DATA, GetRemovalMask()); |
| 1253 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); | 1253 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); |
| 1254 ASSERT_FALSE(tester.HasProfile()); | 1254 ASSERT_FALSE(tester.HasProfile()); |
| 1255 } | 1255 } |
| OLD | NEW |