| 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 <set> | 5 #include <set> | 
| 6 #include <vector> | 6 #include <vector> | 
| 7 | 7 | 
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" | 
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" | 
| 10 #include "chrome/browser/download/download_history.h" | 10 #include "chrome/browser/download/download_history.h" | 
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 164 | 164 | 
| 165   void ExpectNoDownloadsRemoved() { | 165   void ExpectNoDownloadsRemoved() { | 
| 166     DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 166     DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 
| 167     content::RunAllPendingInMessageLoop(content::BrowserThread::UI); | 167     content::RunAllPendingInMessageLoop(content::BrowserThread::UI); | 
| 168     EXPECT_EQ(0, static_cast<int>(remove_downloads_.size())); | 168     EXPECT_EQ(0, static_cast<int>(remove_downloads_.size())); | 
| 169   } | 169   } | 
| 170 | 170 | 
| 171   void ExpectDownloadsRemoved(const IdSet& ids) { | 171   void ExpectDownloadsRemoved(const IdSet& ids) { | 
| 172     DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 172     DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 
| 173     content::RunAllPendingInMessageLoop(content::BrowserThread::UI); | 173     content::RunAllPendingInMessageLoop(content::BrowserThread::UI); | 
| 174     IdSet differences; | 174     IdSet differences = base::STLSetDifference<IdSet>(ids, remove_downloads_); | 
| 175     std::insert_iterator<IdSet> differences_iter( |  | 
| 176         differences, differences.begin()); |  | 
| 177     std::set_difference(ids.begin(), ids.end(), |  | 
| 178                         remove_downloads_.begin(), |  | 
| 179                         remove_downloads_.end(), |  | 
| 180                         differences_iter); |  | 
| 181     for (IdSet::const_iterator different = differences.begin(); | 175     for (IdSet::const_iterator different = differences.begin(); | 
| 182          different != differences.end(); ++different) { | 176          different != differences.end(); ++different) { | 
| 183       EXPECT_TRUE(false) << *different; | 177       EXPECT_TRUE(false) << *different; | 
| 184     } | 178     } | 
| 185     remove_downloads_.clear(); | 179     remove_downloads_.clear(); | 
| 186   } | 180   } | 
| 187 | 181 | 
| 188  private: | 182  private: | 
| 189   bool slow_create_download_; | 183   bool slow_create_download_; | 
| 190   bool fail_create_download_; | 184   bool fail_create_download_; | 
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 793   item_observer()->OnDownloadUpdated(&item(0)); | 787   item_observer()->OnDownloadUpdated(&item(0)); | 
| 794 | 788 | 
| 795   FinishCreateDownload(); | 789   FinishCreateDownload(); | 
| 796   EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0))); | 790   EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0))); | 
| 797 | 791 | 
| 798   // ItemAdded should call OnDownloadUpdated, which should detect that the item | 792   // ItemAdded should call OnDownloadUpdated, which should detect that the item | 
| 799   // changed while it was being added and call UpdateDownload immediately. | 793   // changed while it was being added and call UpdateDownload immediately. | 
| 800   info.opened = true; | 794   info.opened = true; | 
| 801   ExpectDownloadUpdated(info); | 795   ExpectDownloadUpdated(info); | 
| 802 } | 796 } | 
| OLD | NEW | 
|---|